In all the cases I have seen this it has to do with Array initializers. If you look at the types created in you'll notice that the compiler has just created a different struct for each size array you have initialized. The compiler does this to reduce IL size, speed memory allocation for the array elements and to keep the array elements stored in memory together and in order. Without getting to deep in the weeds I'll just mention that doing it this way means any size array initialization happens in a known and constant number of IL instructions. I can't remember from my digging in ILDasm but I think it was 4. Assigning one at a time means 4 instructions per element.
Now to your specific problem. It's not that bad once you realize you're just dealing with value type instances that need to be renamed. Some searching in reflector should reveal the instances where the compiler generated objects are used. The original declaration and initialization will be intact in source. That's all you need to follow though with a global rename for that object. Pick any name you want and replace the compiler's generated name. I put some other code below that illustrates this. For Dictionaries that need initialization as well it optimizes and creates a new instance for each Dictionary called <>f_switch$mapn where n is a counter again.
You'll also deal with similar nonsense for any properties the backing fields were autogenerated for. Same fix though. Create your own backing 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)
.
.
.
if (new[] { 16, 32, 42, 64, 314, 1337 }.Contains(something)) { ... }
. – Mcelhaney