The ConditionalAttribute can be used to remove calls to a marked method depending on the compiler symbols defined. I’m assuming we could not create this class ourselves since the compiler must be looking for it specifically.
I was wondering what other classes there are that the compiler, or language uses that we could not code ourselves.
The compiler looks for
[ExtensionAttribute]to indicate extension methods (and classes containing extension methods).[DynamicAttribute]is used to indicate that a member should be treated as typedynamic(even though the member type itself will just beobject)[InternalsVisibleTo]allows one assembly to access the internal members of another.Basically look through the
System.Runtime.CompilerServicesnamespace, and examine the attributes in there… many of them will be handled specially by a compiler, even if it’s not the C# compiler (e.g.DateTimeConstantAttributeisn’t used by the C# compiler as far as I’m aware, butDecimalConstantAttributeis. It’s possible that the C# compiler will consume constantDateTimevalues even though it won’t produce them…)