Total .NET Analyzer Rule Documentation  

SealedAttribute Rule

Seal attribute classes whenever possible.

Remarks

For performance reasons, you should seal attribute classes whenever possible, so that classes cannot be derived from them. Sealing attribute classes results in better lookup performance when accessing the class.

Resolution

Unless you need to derive classes from the attribute class, it should be sealed.

In Visual Basic, use the "NotInheritable" keyword to seal an attribute class:

<AttributeUsage(AttributeTargets.Class)> _ Public NotInheritable Class SimpleAttribute Inherits System.Attribute End Class

In C#, use the "sealed" keyword to seal an attribute class:

[AttributeUsage(AttributeTargets.All)]
public sealed class SimpleAttribute : Attribute
{

}

See Also

Base Class Usage Guidelines