tags:

views:

546

answers:

4

Note that the following are examples of the rare cases where dotNet reflector does not disassemble correctly. In the vast majority of cases it works perfectly, and I am not suggesting this is necessarily a bug in reflector. It may be a result of protection or obfuscation or unmanaged code on the assemblies in question.

I try to disassemble System.Web.UI.WebControls.XmlHierarchicalEnumerable in dotnet reflector. The generics seems all screwed up, eg:

// Nested Types
[CompilerGenerated]
private sealed class GetEnumerator>d__0 : IEnumerator<object>, 
    IEnumerator, IDisposable
{
    // Fields
    private int <>1__state;
    private object <>2__current;
    public XmlHierarchicalEnumerable <>4__this;
    public IEnumerator <>7__wrap2;
    public IDisposable <>7__wrap3;
    public XmlNode <node>5__1;

In other assemblies I sometimes get little squares (I know these usually stand for 'unknown symbol') in place of class names, eg:

    dictionary1.Add("autopostbackonselect", 0x34);
    ᜀ.ᜌ = dictionary1;
}

if (ᜀ.ᜌ.TryGetValue(key, out num))
{
    switch (num)

What gives ? Anyone know ?

+3  A: 

In the first example, this is completely expected. These classes are used for the implementation of IEnumerable<T> when using the yield return statements. It generates classes which store the state and get the new values when MoveNext is called on the IEnumerator<T> instance output by the IEnumerable<T> implementation (you will note they are one in the same).

It should be noted that what you are seeing is completely legal naming syntax from a CLR perspective. From a C# perspective though, it is not legal. However, since these classes are internal and you will never need access to them directly (only through interface implmentations), there is no need for them to be legal C# names.

As for the second, I haven't seen that behavior, it's possible that the assembly is obfuscated, but I've not seen that in .NET in any version. If you clarify the assemblies (.NET framework or not) in which version of the .NET framework you are looking at, as well as what version of reflector you are using, it would help.

casperOne
I believe I remember reading that there are some non-printable ASCII characters that are legal CLR identifiers that can be used for compiler-generated code
jeffora
casperOne: thanks for that clarification. The code didn't even look internally consistent to me (eg 'GetEnumerator>d__0'), but I'm not at all up with CLR rules so that explains it nicely.As you might expect, I'm just decompiling .NET 2.0 so that I can work around some of the more heinous bugs. I got sick of dong it piecemeal, so using FileDisassembler I just pulled the entire System.Web assembly. It almost compiles - there are just two or three classes like this one preventing it.The second sample was a brand of commercial UI AJAX controls (not Telerik but like them).
Ben McIntyre
Reflector ver 5.1.6.0.Net Framework 2.0.50727.3603
Ben McIntyre
+1  A: 

I have seen this before when looking at assemblies that have been Obfuscated. Quite often during this process variable names are unreadable to the human eye, thus resulting in a unknown character.

Rohan West
A: 

This assembly might have been Obfuscated, you can check these links http://cooprotector.com/ http://intelliside.com/

Ravia
A: 

There's quite a few things being autogenetated by the compiler. Auto properties, anonymous types/methods and emumerators based on enumerator blocks. They All need a name and that should be one that does not clash with something names by the developer. Since <>_ is a perfectly legal name in CLR terms but not in C# prefixing anything autogenetated and named with <>_ ensures that the compiler wont accidentally choose a name already used by the developer.

Rune FS
Thanks, I will have to check out CLR formatting rules.
Ben McIntyre