Skip to content

Latest commit

 

History

History
30 lines (25 loc) · 679 Bytes

README.md

File metadata and controls

30 lines (25 loc) · 679 Bytes

Example with custom attributes

Generating a custom attribute using 'AttributeUsage(...)'

AttributeUsage(Inherited = True, AllowMultiple = True)

internal class CustomMarkerAttribute(string Tag) : Attribute
{
  public string Tag { get; } = Tag;
}

Setting this attribute on a sample base class

[CustomMarker("Base Tag")]
class BaseClass { }

Setting this attribute on a sample sub class

[CustomMarker("Sub Tag")]
class SubClass { }

Reading the attributes of the sub class with 'Attribute.GetCustomAttributes(...)'
returns both the attribute set on the sub class and the attribute set on the base class.

Sub Tag
Base Tag