Is there any way of making a composite attribute in C# to provide equivalent metadata at compile time?
E.g, change:
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("MyProgId")]
[MyMefExport("MyProgId")]
public class MyClass
{
}
To:
[MyCompositeAttribute("MyProgId")]
public class MyClass
{
}
Attributes in and of themselves are meaningless. It is the code that enumerates the attributes attached to a class that may change its operation.
If you control the code that understands the attribute, you could create a composite attribute and act as though multiple separate attributes were applied.
That being said, I doubt you control ProgId nor the C# compiler that interprets it...
Say you had the following code to read your custom attribute:
Any code that relied on say:
will fail to return that attribute.