Browse Source

Fix object initializers directly accessing struct members + add initializer pretty tests.

pull/927/head
Siegfried Pammer 8 years ago
parent
commit
14b6c599c1
  1. 1
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  2. 6
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  3. 92
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs
  4. 245
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il
  5. 207
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il
  6. 195
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il
  7. 247
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il
  8. 16
      ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs

1
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -66,6 +66,7 @@ @@ -66,6 +66,7 @@
<Compile Include="TestCases\Correctness\Using.cs" />
<Compile Include="TestCases\ILPretty\Issue379.cs" />
<Compile Include="TestCases\Pretty\FixProxyCalls.cs" />
<Compile Include="TestCases\Pretty\InitializerTests.cs" />
<None Include="TestCases\ILPretty\Issue646.cs" />
<Compile Include="TestCases\Pretty\Async.cs" />
<Compile Include="TestCases\Pretty\CheckedUnchecked.cs" />

6
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -188,6 +188,12 @@ namespace ICSharpCode.Decompiler.Tests @@ -188,6 +188,12 @@ namespace ICSharpCode.Decompiler.Tests
Run(cscOptions: cscOptions, asmOptions: AssemblerOptions.UseOwnDisassembler);
}
[Test]
public void InitializerTests([ValueSource("defaultOptions")] CompilerOptions cscOptions)
{
Run(cscOptions: cscOptions);
}
[Test]
public void FixProxyCalls([Values(CompilerOptions.None, CompilerOptions.Optimize, CompilerOptions.UseRoslyn)] CompilerOptions cscOptions)
{

92
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs

@ -0,0 +1,92 @@ @@ -0,0 +1,92 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
public class InitializerTests
{
public class C
{
public int Z;
public S Y;
public List<S> L;
}
public struct S
{
public int A;
public int B;
public S(int a)
{
this.A = a;
this.B = 0;
}
}
public static C TestCall(int a, C c)
{
return c;
}
public C Test()
{
C c = new C();
c.L = new List<S>();
c.L.Add(new S(1));
return c;
}
public C Test2()
{
C c = new C();
c.Z = 1;
c.Z = 2;
return c;
}
public C Test3()
{
C c = new C();
c.Y = new S(1);
c.Y.A = 2;
return c;
}
public C Test3b()
{
return InitializerTests.TestCall(0, new C {
Z = 1,
Y = {
A = 2
}
});
}
public C Test4()
{
C c = new C();
c.Y.A = 1;
c.Y.B = 3;
c.Z = 2;
return c;
}
}
}

245
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il

@ -0,0 +1,245 @@ @@ -0,0 +1,245 @@
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly '0zopdghu'
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module '0zopdghu.dll'
// MVID: {56C873AC-FD1E-4808-A65A-845BA0A3C2B7}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x032A0000
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
extends [mscorlib]System.Object
{
.class auto ansi nested public beforefieldinit C
extends [mscorlib]System.Object
{
.field public int32 Z
.field public valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S Y
.field public class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S> L
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method C::.ctor
} // end of class C
.class sequential ansi sealed nested public beforefieldinit S
extends [mscorlib]System.ValueType
{
.field public int32 A
.field public int32 B
.method public hidebysig specialname rtspecialname
instance void .ctor(int32 a) cil managed
{
// Code size 16 (0x10)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldarg.1
IL_0003: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_0008: ldarg.0
IL_0009: ldc.i4.0
IL_000a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B
IL_000f: ret
} // end of method S::.ctor
} // end of class S
.method public hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
TestCall(int32 a,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C c) cil managed
{
// Code size 7 (0x7)
.maxstack 1
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: stloc.0
IL_0003: br.s IL_0005
IL_0005: ldloc.0
IL_0006: ret
} // end of method InitializerTests::TestCall
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test() cil managed
{
// Code size 42 (0x2a)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1)
IL_0000: nop
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: newobj instance void class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S>::.ctor()
IL_000d: stfld class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L
IL_0012: ldloc.0
IL_0013: ldfld class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L
IL_0018: ldc.i4.1
IL_0019: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32)
IL_001e: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S>::Add(!0)
IL_0023: nop
IL_0024: ldloc.0
IL_0025: stloc.1
IL_0026: br.s IL_0028
IL_0028: ldloc.1
IL_0029: ret
} // end of method InitializerTests::Test
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test2() cil managed
{
// Code size 27 (0x1b)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1)
IL_0000: nop
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldc.i4.1
IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_000e: ldloc.0
IL_000f: ldc.i4.2
IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_0015: ldloc.0
IL_0016: stloc.1
IL_0017: br.s IL_0019
IL_0019: ldloc.1
IL_001a: ret
} // end of method InitializerTests::Test2
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test3() cil managed
{
// Code size 37 (0x25)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1)
IL_0000: nop
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldc.i4.1
IL_0009: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32)
IL_000e: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0013: ldloc.0
IL_0014: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0019: ldc.i4.2
IL_001a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_001f: ldloc.0
IL_0020: stloc.1
IL_0021: br.s IL_0023
IL_0023: ldloc.1
IL_0024: ret
} // end of method InitializerTests::Test3
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test3b() cil managed
{
// Code size 38 (0x26)
.maxstack 3
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1)
IL_0000: nop
IL_0001: ldc.i4.0
IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0007: stloc.0
IL_0008: ldloc.0
IL_0009: ldc.i4.1
IL_000a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_000f: ldloc.0
IL_0010: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0015: ldc.i4.2
IL_0016: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_001b: ldloc.0
IL_001c: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C)
IL_0021: stloc.1
IL_0022: br.s IL_0024
IL_0024: ldloc.1
IL_0025: ret
} // end of method InitializerTests::Test3b
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test4() cil managed
{
// Code size 44 (0x2c)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1)
IL_0000: nop
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_000d: ldc.i4.1
IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_0013: ldloc.0
IL_0014: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0019: ldc.i4.3
IL_001a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B
IL_001f: ldloc.0
IL_0020: ldc.i4.2
IL_0021: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_0026: ldloc.0
IL_0027: stloc.1
IL_0028: br.s IL_002a
IL_002a: ldloc.1
IL_002b: ret
} // end of method InitializerTests::Test4
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method InitializerTests::.ctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************
// Warnung: Win32-Ressourcendatei "../../../TestCases/Pretty\InitializerTests.res" wurde erstellt.

207
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il

@ -0,0 +1,207 @@ @@ -0,0 +1,207 @@
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly xvcsxiw0
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module xvcsxiw0.dll
// MVID: {ADB73224-52C3-4DFE-AB87-E9CEDD4FB2C3}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x00D20000
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
extends [mscorlib]System.Object
{
.class auto ansi nested public beforefieldinit C
extends [mscorlib]System.Object
{
.field public int32 Z
.field public valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S Y
.field public class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S> L
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method C::.ctor
} // end of class C
.class sequential ansi sealed nested public beforefieldinit S
extends [mscorlib]System.ValueType
{
.field public int32 A
.field public int32 B
.method public hidebysig specialname rtspecialname
instance void .ctor(int32 a) cil managed
{
// Code size 15 (0xf)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_0007: ldarg.0
IL_0008: ldc.i4.0
IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B
IL_000e: ret
} // end of method S::.ctor
} // end of class S
.method public hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
TestCall(int32 a,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C c) cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: ldarg.1
IL_0001: ret
} // end of method InitializerTests::TestCall
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test() cil managed
{
// Code size 36 (0x24)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0)
IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: newobj instance void class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S>::.ctor()
IL_000c: stfld class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L
IL_0011: ldloc.0
IL_0012: ldfld class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L
IL_0017: ldc.i4.1
IL_0018: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32)
IL_001d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S>::Add(!0)
IL_0022: ldloc.0
IL_0023: ret
} // end of method InitializerTests::Test
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test2() cil managed
{
// Code size 22 (0x16)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0)
IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldc.i4.1
IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_000d: ldloc.0
IL_000e: ldc.i4.2
IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_0014: ldloc.0
IL_0015: ret
} // end of method InitializerTests::Test2
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test3() cil managed
{
// Code size 32 (0x20)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0)
IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldc.i4.1
IL_0008: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32)
IL_000d: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0012: ldloc.0
IL_0013: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0018: ldc.i4.2
IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_001e: ldloc.0
IL_001f: ret
} // end of method InitializerTests::Test3
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test3b() cil managed
{
// Code size 33 (0x21)
.maxstack 3
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0)
IL_0000: ldc.i4.0
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldc.i4.1
IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_000e: ldloc.0
IL_000f: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0014: ldc.i4.2
IL_0015: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_001a: ldloc.0
IL_001b: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C)
IL_0020: ret
} // end of method InitializerTests::Test3b
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test4() cil managed
{
// Code size 39 (0x27)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0)
IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_000c: ldc.i4.1
IL_000d: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_0012: ldloc.0
IL_0013: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0018: ldc.i4.3
IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B
IL_001e: ldloc.0
IL_001f: ldc.i4.2
IL_0020: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_0025: ldloc.0
IL_0026: ret
} // end of method InitializerTests::Test4
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method InitializerTests::.ctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************
// Warnung: Win32-Ressourcendatei "../../../TestCases/Pretty\InitializerTests.opt.res" wurde erstellt.

195
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il

@ -0,0 +1,195 @@ @@ -0,0 +1,195 @@
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly InitializerTests
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 )
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module InitializerTests.dll
// MVID: {73C118AC-648F-43DB-A2FB-1B159DF870BA}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x03230000
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
extends [mscorlib]System.Object
{
.class auto ansi nested public beforefieldinit C
extends [mscorlib]System.Object
{
.field public int32 Z
.field public valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S Y
.field public class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S> L
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method C::.ctor
} // end of class C
.class sequential ansi sealed nested public beforefieldinit S
extends [mscorlib]System.ValueType
{
.field public int32 A
.field public int32 B
.method public hidebysig specialname rtspecialname
instance void .ctor(int32 a) cil managed
{
// Code size 15 (0xf)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_0007: ldarg.0
IL_0008: ldc.i4.0
IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B
IL_000e: ret
} // end of method S::.ctor
} // end of class S
.method public hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
TestCall(int32 a,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C c) cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: ldarg.1
IL_0001: ret
} // end of method InitializerTests::TestCall
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test() cil managed
{
// Code size 34 (0x22)
.maxstack 8
IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0005: dup
IL_0006: newobj instance void class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S>::.ctor()
IL_000b: stfld class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L
IL_0010: dup
IL_0011: ldfld class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L
IL_0016: ldc.i4.1
IL_0017: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32)
IL_001c: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S>::Add(!0)
IL_0021: ret
} // end of method InitializerTests::Test
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test2() cil managed
{
// Code size 20 (0x14)
.maxstack 8
IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0005: dup
IL_0006: ldc.i4.1
IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_000c: dup
IL_000d: ldc.i4.2
IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_0013: ret
} // end of method InitializerTests::Test2
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test3() cil managed
{
// Code size 30 (0x1e)
.maxstack 8
IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0005: dup
IL_0006: ldc.i4.1
IL_0007: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32)
IL_000c: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0011: dup
IL_0012: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0017: ldc.i4.2
IL_0018: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_001d: ret
} // end of method InitializerTests::Test3
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test3b() cil managed
{
// Code size 31 (0x1f)
.maxstack 8
IL_0000: ldc.i4.0
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0006: dup
IL_0007: ldc.i4.1
IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_000d: dup
IL_000e: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0013: ldc.i4.2
IL_0014: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_0019: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C)
IL_001e: ret
} // end of method InitializerTests::Test3b
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test4() cil managed
{
// Code size 37 (0x25)
.maxstack 8
IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0005: dup
IL_0006: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_000b: ldc.i4.1
IL_000c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_0011: dup
IL_0012: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0017: ldc.i4.3
IL_0018: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B
IL_001d: dup
IL_001e: ldc.i4.2
IL_001f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_0024: ret
} // end of method InitializerTests::Test4
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method InitializerTests::.ctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************

247
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il

@ -0,0 +1,247 @@ @@ -0,0 +1,247 @@
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly InitializerTests
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 )
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module InitializerTests.dll
// MVID: {53F415C2-DC80-4EFA-8787-82F129B1AC28}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x002F0000
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
extends [mscorlib]System.Object
{
.class auto ansi nested public beforefieldinit C
extends [mscorlib]System.Object
{
.field public int32 Z
.field public valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S Y
.field public class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S> L
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method C::.ctor
} // end of class C
.class sequential ansi sealed nested public beforefieldinit S
extends [mscorlib]System.ValueType
{
.field public int32 A
.field public int32 B
.method public hidebysig specialname rtspecialname
instance void .ctor(int32 a) cil managed
{
// Code size 16 (0x10)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldarg.1
IL_0003: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_0008: ldarg.0
IL_0009: ldc.i4.0
IL_000a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B
IL_000f: ret
} // end of method S::.ctor
} // end of class S
.method public hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
TestCall(int32 a,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C c) cil managed
{
// Code size 7 (0x7)
.maxstack 1
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: stloc.0
IL_0003: br.s IL_0005
IL_0005: ldloc.0
IL_0006: ret
} // end of method InitializerTests::TestCall
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test() cil managed
{
// Code size 42 (0x2a)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1)
IL_0000: nop
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: newobj instance void class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S>::.ctor()
IL_000d: stfld class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L
IL_0012: ldloc.0
IL_0013: ldfld class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S> ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L
IL_0018: ldc.i4.1
IL_0019: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32)
IL_001e: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S>::Add(!0)
IL_0023: nop
IL_0024: ldloc.0
IL_0025: stloc.1
IL_0026: br.s IL_0028
IL_0028: ldloc.1
IL_0029: ret
} // end of method InitializerTests::Test
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test2() cil managed
{
// Code size 27 (0x1b)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1)
IL_0000: nop
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldc.i4.1
IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_000e: ldloc.0
IL_000f: ldc.i4.2
IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_0015: ldloc.0
IL_0016: stloc.1
IL_0017: br.s IL_0019
IL_0019: ldloc.1
IL_001a: ret
} // end of method InitializerTests::Test2
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test3() cil managed
{
// Code size 37 (0x25)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1)
IL_0000: nop
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldc.i4.1
IL_0009: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32)
IL_000e: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0013: ldloc.0
IL_0014: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0019: ldc.i4.2
IL_001a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_001f: ldloc.0
IL_0020: stloc.1
IL_0021: br.s IL_0023
IL_0023: ldloc.1
IL_0024: ret
} // end of method InitializerTests::Test3
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test3b() cil managed
{
// Code size 36 (0x24)
.maxstack 4
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0)
IL_0000: nop
IL_0001: ldc.i4.0
IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0007: dup
IL_0008: ldc.i4.1
IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_000e: dup
IL_000f: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0014: ldc.i4.2
IL_0015: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_001a: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C)
IL_001f: stloc.0
IL_0020: br.s IL_0022
IL_0022: ldloc.0
IL_0023: ret
} // end of method InitializerTests::Test3b
.method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C
Test4() cil managed
{
// Code size 44 (0x2c)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1)
IL_0000: nop
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_000d: ldc.i4.1
IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A
IL_0013: ldloc.0
IL_0014: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y
IL_0019: ldc.i4.3
IL_001a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B
IL_001f: ldloc.0
IL_0020: ldc.i4.2
IL_0021: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z
IL_0026: ldloc.0
IL_0027: stloc.1
IL_0028: br.s IL_002a
IL_002a: ldloc.1
IL_002b: ret
} // end of method InitializerTests::Test4
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method InitializerTests::.ctor
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************

16
ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs

@ -224,17 +224,18 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -224,17 +224,18 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
break;
case LdObj ldobj:
case LdObj ldobj: {
if (ldobj.Target is LdFlda ldflda) {
path.Insert(0, new AccessPathElement(ldflda.Field));
instruction = ldflda.Target;
break;
}
goto default;
case StObj stobj:
if (stobj.Target is LdFlda ldflda2) {
path.Insert(0, new AccessPathElement(ldflda2.Field));
instruction = ldflda2.Target;
}
case StObj stobj: {
if (stobj.Target is LdFlda ldflda) {
path.Insert(0, new AccessPathElement(ldflda.Field));
instruction = ldflda.Target;
if (values == null) {
values = new List<ILInstruction>(new[] { stobj.Value });
kind = AccessPathKind.Setter;
@ -242,6 +243,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -242,6 +243,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
break;
}
goto default;
}
case LdLoc ldloc:
target = ldloc.Variable;
instruction = null;
@ -250,6 +252,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -250,6 +252,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms
target = ldloca.Variable;
instruction = null;
break;
case LdFlda ldflda:
path.Insert(0, new AccessPathElement(ldflda.Field));
instruction = ldflda.Target;
break;
default:
kind = AccessPathKind.Invalid;
instruction = null;

Loading…
Cancel
Save