<PrivateImplementationDetails> {GUID} .method $$ **** in the code file. Not compiled!

We have a .NET assembly from another project, where in one of the generated files from Reflector there is .. snippet for the method.

Now VS 2010 C # compiler generates all kinds of unexpected $$ compilation errors. close braces, etc.

In ILDASM, I see this method along with many others mentioned, but in the generated code I find only one of these compiler-generated methods.

How to make a compilation?

+7
source share
4 answers

Usually they are created by static readonly arrays. You will not compile them. In addition, Reflector noticeably distorts everything except trivial code.

I suggest you get the source code.

+4
source

These files are automatically generated by the compiler, I believe that for things like lambda expression objects (for which you do not specify any name). I believe that they are incorrect names precisely because the compiler wants to make sure that there is no conflict with your own code; you just have to rename them before recompiling.

+2
source

In the browse menu, select options.

Check the Optimization selection. Since you are using the latest version of VS, you must specify optimizations for .Net 4.0 or at least 3.5 to get lambdas support.

0
source

In all cases that I saw this, this is due to Array initializers. If you look at the types you created, you will notice that the compiler has just created a different structure for each size array that you initialized. The compiler does this in order to reduce the size of the IL, speed up the allocation of memory for array elements and save the array elements stored in memory together and in order. Before reaching the depth of the weeds, I just mentioned that this is done so that the initialization of an array of any size occurs in a known and constant number of IL instructions. I don’t remember how it happened in my ILDasm, but I think it was 4. Assigning one at a time means 4 instructions for each element.

Now to your specific problem. This is not so bad if you understand that you are dealing with instances of the type of values ​​that you need to rename. Some search in the reflector should identify cases where the generated compiler objects are used. The original declaration and initialization will be intact at the source. This is all you need, at least with a global rename for this object. Select any name you want and replace the generated compiler name. I will provide another code below that illustrates this. For dictionaries that also need initialization, it optimizes and creates a new instance for each Dictionary called <> f_switch $ mapn, where n is again the counter.

You will also deal with similar stupidity for any properties for which auto-update fields have been created. Nevertheless. Create your own support field and use it.


 [CompilerGenerated] internal class <PrivateImplementationDetails> { // Fields internal static $ArrayType$4 $$field-0; // data size: 4 bytes internal static $ArrayType$4 $$field-1; // data size: 4 bytes internal static $ArrayType$4 $$field-2; // data size: 4 bytes internal static $ArrayType$4 $$field-3; // data size: 4 bytes internal static $ArrayType$44 $$field-4; // data size: 44 bytes internal static $ArrayType$4 $$field-5; // data size: 4 bytes // Nested Types [StructLayout(LayoutKind.Explicit, Size=4, Pack=1)] private struct $ArrayType$4 { } [StructLayout(LayoutKind.Explicit, Size=0x2c, Pack=1)] private struct $ArrayType$44 { } } 

 static GATWavHelper() { riffBytes = new byte[] { 0x52, 0x49, 70, 70 }; waveBytes = new byte[] { 0x57, 0x41, 0x56, 0x45 }; fmtBytes = new byte[] { 0x66, 0x6d, 0x74, 0x20 }; dataBytes = new byte[] { 100, 0x61, 0x74, 0x61 }; headerSize = 0x2c; floatToInt16RescaleFactor = 0x7fff; __canonicalHeader = new byte[] { 0x52, 0x49, 70, 70, 0, 0, 0, 0, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20, 0, 0, 0, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0x61, 0x74, 0x61, 0, 0, 0, 0 }; } 

 // Fields [CompilerGenerated] private static Dictionary<string, int> <>f__switch$map0; . . . if (<>f__switch$map0 == null) { Dictionary<string, int> dictionary = new Dictionary<string, int>(3); dictionary.Add("false", 0); dictionary.Add("true", 1); dictionary.Add("null", 2); <>f__switch$map0 = dictionary; } if (<>f__switch$map0.TryGetValue(nextWord, out num)) { switch (num) . . . 
0
source

All Articles