C#

C#

Made by DeepSource

Custom attribute is missing AttributeUsage attribute CS-W1070

Anti-pattern
Minor

The AttributeUsage attribute allows you to specify where your attribute can be used, whether it should be used for a class, struct, or some other entity. If you're defining your own attributes, consider using AttributeUsage.

Bad Practice

class MyCustomAttribute : Attribute
{
}

Recommended

[AttributeUsage(AttributeTargets.Class)] // Should be used ideally only for classes
class MyCustomAttribute : Attribute
{
}

Reference