Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is `_[....]` a valid identifier?

I've just installed the .NET 4.5 reference source from Microsoft as I'm trying to debug an issue I'm seeing and I stumbled across the following in HttpApplication.cs.

// execution step -- call asynchronous event
internal class AsyncEventExecutionStep : IExecutionStep { 
    private HttpApplication     _application;
    private BeginEventHandler   _beginHandler;
    private EndEventHandler     _endHandler;
    private Object              _state; 
    private AsyncCallback       _completionCallback;
    private AsyncStepCompletionInfo _asyncStepCompletionInfo; // per call 
    private bool                _[....];          // per call 
    private string              _targetTypeStr;

Notice the next-to-last line private bool _[....]; // per call.

Is _[....] a valid identifier (at any level of compilation, including IL) or has the source been changed since compilation?

like image 574
Greg B Avatar asked Dec 20 '12 15:12

Greg B


2 Answers

No; that's not valid.

Before releasing the source, Microsoft ran it through a poorly-written internal tool that replaces all employee names with [....].
Unfortunately, the tool replaces actual source as well.

This is actually counter-productive; you can find out what most of the hidden source actually was by looking in the compiled metadata (eg, in Reflector).

Your particular line should be private bool _sync

like image 91
SLaks Avatar answered Nov 20 '22 01:11

SLaks


While @SLaks answer is most likely the correct one, it's important to note that this IS a potentially valid identifier at the IL level, ECMA 335 Partition II, Section 5.3 states:

[T]he ILAsm syntax allows the use of any identifier that can be formed using the Unicode character set (see Partition I). To achieve this, an identifier shall be placed within single quotation marks.

The following is perfectly valid IL that prints out False on the console:

.assembly 'ValidIDTest'
{
}

   .class public TestClass
   {
    .field static public bool '_[...]'

    .method static void Main() cil managed
    {
        .entrypoint
        ldsfld bool TestClass::'_[...]'
        call void [mscorlib]System.Console::WriteLine(bool)
        ret    
    }
   }
like image 27
mletterle Avatar answered Nov 20 '22 01:11

mletterle