Code Analysis Code Analysis
Code Analysis Code Analysis
DocFX + Singulink = ♥

Search Results for

    Class NotNullRefAttribute

    Marks a ref, in, ref readonly or out parameter of a method that returns only if the reference that it is given refers to something: given a null reference, as Unsafe.NullRef makes one, the method throws.

    Inheritance
    object
    Attribute
    NotNullRefAttribute
    Inherited Members
    Attribute.Equals(object)
    Attribute.GetCustomAttribute(Assembly, Type)
    Attribute.GetCustomAttribute(Assembly, Type, bool)
    Attribute.GetCustomAttribute(MemberInfo, Type)
    Attribute.GetCustomAttribute(MemberInfo, Type, bool)
    Attribute.GetCustomAttribute(Module, Type)
    Attribute.GetCustomAttribute(Module, Type, bool)
    Attribute.GetCustomAttribute(ParameterInfo, Type)
    Attribute.GetCustomAttribute(ParameterInfo, Type, bool)
    Attribute.GetCustomAttributes(Assembly)
    Attribute.GetCustomAttributes(Assembly, bool)
    Attribute.GetCustomAttributes(Assembly, Type)
    Attribute.GetCustomAttributes(Assembly, Type, bool)
    Attribute.GetCustomAttributes(MemberInfo)
    Attribute.GetCustomAttributes(MemberInfo, bool)
    Attribute.GetCustomAttributes(MemberInfo, Type)
    Attribute.GetCustomAttributes(MemberInfo, Type, bool)
    Attribute.GetCustomAttributes(Module)
    Attribute.GetCustomAttributes(Module, bool)
    Attribute.GetCustomAttributes(Module, Type)
    Attribute.GetCustomAttributes(Module, Type, bool)
    Attribute.GetCustomAttributes(ParameterInfo)
    Attribute.GetCustomAttributes(ParameterInfo, bool)
    Attribute.GetCustomAttributes(ParameterInfo, Type)
    Attribute.GetCustomAttributes(ParameterInfo, Type, bool)
    Attribute.GetHashCode()
    Attribute.IsDefaultAttribute()
    Attribute.IsDefined(Assembly, Type)
    Attribute.IsDefined(Assembly, Type, bool)
    Attribute.IsDefined(MemberInfo, Type)
    Attribute.IsDefined(MemberInfo, Type, bool)
    Attribute.IsDefined(Module, Type)
    Attribute.IsDefined(Module, Type, bool)
    Attribute.IsDefined(ParameterInfo, Type)
    Attribute.IsDefined(ParameterInfo, Type, bool)
    Attribute.Match(object)
    Attribute.TypeId
    Namespace: Singulink.CodeAnalysis
    Assembly: Singulink.CodeAnalysis.dll
    Syntax
    [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
    public sealed class NotNullRefAttribute : Attribute
    Remarks

    A read or a write through a null reference fails, so the analyzer counts a read or a write through a reference as able to throw where it asks what can: between the read and the assignment of a [MovedFrom] parameter, and after a value was committed at the end of a try block. After a call of a method with this attribute that returns, the reference that was passed to the marked parameter is known to refer to something. ThrowIfNullRef<T>(ref readonly T, string?) and ThrowIfNullRefArgument<T>(ref readonly T, string?) are such methods.

    The attribute counts where a call names the code that runs: on a method that is not virtual, abstract or an override, static or not, an extension method included, and on a local function. Anywhere else it gets a warning.

    The analyzer does not check the body of the method. The attribute is a statement of its author, and every use of it in a project gets one warning, to be suppressed there when the method has been verified and tested.

    The analyzer recognizes the attribute by its full name, Singulink.CodeAnalysis.NotNullRefAttribute, in any assembly, public or internal.

    © Singulink. All rights reserved.