Compiler information as part of code.

*** #ClassName : gives you the name of the current class

Often I setup loggers and stuff, and always do something like:

class blah

   static Logger Log = new Logger( "blah");

what I'd like to do is have a context aware statement that got built at compile time (much like the old C++ __line and stuff) -

eg: static Logger Log = new Logger( #className )

 

We've talked about this, but haven't been able to come up with a clean way of doing it. We do understand the value.

 

*** #member : gives you the name of the member you are in

same as above, it'd be nice to be able to do things like put stuff about what procedure I'm in:

eg:

public void Blah()

{

    Log( #currentProcedure + ": first line");

}

 

ibid.

 

*** "meta" parameter definition

This is a little off the wall, but it'd be easy to do, and really cool - have a tag called "meta" which you can put on a parameter - which will actually compile to send information about the actual parameter

for instance, at the moment I have a thing called EnsureNotMissing( string, object), which just does a "if null throw exception (" parameter " + name + " is missing )

that means at the moment I have to say

      EnsureNotMissing( "myParam", MyParam );

I would like to build

      public void EnsureNotMissing( object MyParam, meta(MyParam) objectData )

      {

            if (myParam ==null)

                  throw new exception( (objectData as ParameterInfo).name + " is null");

      }

so I can just say

      EnsureNotMissing( MyParam ); - and the compiler will actually throw in the other stuff, like the name

 

This would be a nice feature. It's something we've touched on obliquely when we talked about __FILE__ and __LINE__