The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Compiler information as part of code.

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Gunnerson

Posts: 1006
Nickname: ericgu
Registered: Aug, 2003

Eric Gunnerson is a program manager on the Visual C# team
Compiler information as part of code. Posted: Apr 22, 2004 7:11 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Eric Gunnerson.
Original Post: Compiler information as part of code.
Feed Title: Eric Gunnerson's C# Compendium
Feed URL: /msdnerror.htm?aspxerrorpath=/ericgu/Rss.aspx
Feed Description: Eric comments on C#, programming and dotnet in general, and the aerodynamic characteristics of the red-nosed flying squirrel of the Lesser Antilles
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Eric Gunnerson
Latest Posts From Eric Gunnerson's C# Compendium

Advertisement

*** #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__

Read: Compiler information as part of code.

Topic: .NET Nightly 153 Previous Topic   Next Topic Topic: [Coding Contest] Wanna win some really cool prizes?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use