Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ConditionalAttribute and other special classes

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.

like image 624
George Duckett Avatar asked Jun 16 '11 07:06

George Duckett


1 Answers

in addition to those mentioned;

AttributeUsageAttribute

has special compiler support, since it restricts (at compile) how you can apply attributes

ObsoleteAttribute

is also used by the compiler to warn or error about usage.

I suspect though, that technically you could write all of these yourself - as long as you write your own core libarary and System.dll ;p The compiler is generally looking for a pattern/signature, since it must cater for different runtimes - and indeed you don't have to use the MS core libraries. The behaviour, however, is defined by the compiler, not the class - so you can't make it do anything different.

like image 185
Marc Gravell Avatar answered Sep 20 '22 23:09

Marc Gravell