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

Search Results for

    Class NonCopyableAttribute

    Marks a struct that must not be copied, such as one that holds a lock or another resource that only one instance may own, or a type parameter whose values a generic type or method does not copy. The rules of the Singulink.CodeAnalysis.Analyzers package, which this package depends on, warn about code that copies a value of a marked type.

    Inheritance
    object
    Attribute
    NonCopyableAttribute
    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.Struct|AttributeTargets.GenericParameter, Inherited = false)]
    public sealed class NonCopyableAttribute : Attribute
    Remarks

    The analyzer recognizes the attribute by its full name, Singulink.CodeAnalysis.NonCopyableAttribute, in any assembly, public or internal, so a project can declare its own in that namespace instead of using this one. An attribute of the name in another namespace is not recognized on what the project declares, and gets a warning. On a struct of a referenced assembly an attribute of the name is recognized whatever its namespace.

    A field of a non-copyable type can only be declared in a class or in a struct that is itself non-copyable, and not in a record, which copies its fields in with and in the members that the compiler writes for it. A non-copyable type cannot be the type of an auto-property.

    On a type parameter, the mark makes the type parameter a non-copyable type inside the generic that declares it, so the generic is checked like any other code, and callers can use it with a non-copyable type. A member of the generic that has to copy is marked with RequiresCopyableAttribute.

    © Singulink. All rights reserved.