-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Performance.AvoidUnsealedConcreteAttributesRule(2.10)
Assembly: Gendarme.Rules.Performance
Version: 2.10
This rule fires if an attribute is defined which is both concrete (i.e. not abstract) and unsealed. This is a performance problem because it means that System.Attribute.GetCustomAttribute has to search the attribute type hierarchy for derived types. To fix this either seal the type or make it abstract.
Bad example:
[AttributeUsage (AttributeTargets.All)]
public class BadAttribute : Attribute {
}
Good example (sealed):
[AttributeUsage (AttributeTargets.All)]
public sealed class SealedAttribute : Attribute {
}
Good example (abstract and sealed):
[AttributeUsage (AttributeTargets.All)]
public abstract class AbstractAttribute : Attribute {
}
[AttributeUsage (AttributeTargets.All)]
public sealed class ConcreteAttribute : AbstractAttribute {
}
- Before Gendarme 2.0 this rule was named AvoidUnsealedAttributesRule.
Note that this page was autogenerated (1/15/2011 12:27:16 PM) based on the xmldoc
comments inside the rules source code and cannot be edited from this wiki.
Please report any documentation errors, typos or suggestions to the
Gendarme Google Group. Thanks!
Note that this page was autogenerated (3/17/2011 9:31:58 PM) based on the xmldoc
comments inside the rules source code and cannot be edited from this wiki.
Please report any documentation errors, typos or suggestions to the
Gendarme Mailing List. Thanks!