From 17f42066a01b6197753ee10cb7faf18fcbab03c2 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 7 Jan 2019 14:28:28 +0100 Subject: [PATCH 01/26] Fix #1378: Missing unsafe modifier for static fields --- .../ICSharpCode.Decompiler.Tests.csproj | 1 + .../PrettyTestRunner.cs | 6 + .../Pretty/ConstructorInitializers.cs | 35 +++++ .../Pretty/ConstructorInitializers.il | 88 +++++++++++++ .../Pretty/ConstructorInitializers.mcs.il | 120 ++++++++++++++++++ .../Pretty/ConstructorInitializers.opt.il | 87 +++++++++++++ .../Pretty/ConstructorInitializers.opt.mcs.il | 120 ++++++++++++++++++ .../ConstructorInitializers.opt.roslyn.il | 91 +++++++++++++ .../Pretty/ConstructorInitializers.roslyn.il | 93 ++++++++++++++ .../ConvertConstructorCallIntoInitializer.cs | 15 ++- .../Transforms/IntroduceUnsafeModifier.cs | 5 + 11 files changed, 659 insertions(+), 2 deletions(-) create mode 100644 ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.cs create mode 100644 ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.il create mode 100644 ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.mcs.il create mode 100644 ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.opt.il create mode 100644 ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.opt.mcs.il create mode 100644 ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.opt.roslyn.il create mode 100644 ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.roslyn.il diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj index bec77f0d6..ddb15c1d5 100644 --- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj +++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj @@ -73,6 +73,7 @@ + diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs index 3636325ec..ed2abf072 100644 --- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs @@ -220,6 +220,12 @@ namespace ICSharpCode.Decompiler.Tests RunForLibrary(cscOptions: cscOptions); } + [Test] + public void ConstructorInitializers([ValueSource(nameof(defaultOptionsWithMcs))] CSharpCompilerOptions cscOptions) + { + RunForLibrary(cscOptions: cscOptions); + } + [Test] public void PInvoke([ValueSource(nameof(defaultOptions))] CSharpCompilerOptions cscOptions) { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.cs new file mode 100644 index 000000000..9b2a7d175 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.cs @@ -0,0 +1,35 @@ +// 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. + +namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty +{ + public class ConstructorInitializers + { + public struct SimpleStruct + { + public int Field1; + public int Field2; + } + + public class UnsafeFields + { + public unsafe static int StaticSizeOf = sizeof(SimpleStruct); + public unsafe int SizeOf = sizeof(SimpleStruct); + } + } +} diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.il new file mode 100644 index 000000000..a8d0edf46 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.il @@ -0,0 +1,88 @@ + + + + +// 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 ConstructorInitializers +{ + .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 ConstructorInitializers.dll +.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 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers + extends [mscorlib]System.Object +{ + .class sequential ansi sealed nested public beforefieldinit SimpleStruct + extends [mscorlib]System.ValueType + { + .field public int32 Field1 + .field public int32 Field2 + } // end of class SimpleStruct + + .class auto ansi nested public beforefieldinit UnsafeFields + extends [mscorlib]System.Object + { + .field public static int32 StaticSizeOf + .field public int32 SizeOf + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 20 (0x14) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: sizeof ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/SimpleStruct + IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/UnsafeFields::SizeOf + IL_000c: ldarg.0 + IL_000d: call instance void [mscorlib]System.Object::.ctor() + IL_0012: nop + IL_0013: ret + } // end of method UnsafeFields::.ctor + + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 12 (0xc) + .maxstack 8 + IL_0000: sizeof ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/SimpleStruct + IL_0006: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/UnsafeFields::StaticSizeOf + IL_000b: ret + } // end of method UnsafeFields::.cctor + + } // end of class UnsafeFields + + .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 ConstructorInitializers::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.mcs.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.mcs.il new file mode 100644 index 000000000..5fed2ec8d --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.mcs.il @@ -0,0 +1,120 @@ + + + + +// Metadata version: v2.0.50727 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 2:0:0:0 +} +.assembly ConstructorInitializers.mcs +{ + .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 + bytearray (3C 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // <.P.e.r.m.i.s.s. + 69 00 6F 00 6E 00 53 00 65 00 74 00 20 00 63 00 // i.o.n.S.e.t. .c. + 6C 00 61 00 73 00 73 00 3D 00 22 00 53 00 79 00 // l.a.s.s.=.".S.y. + 73 00 74 00 65 00 6D 00 2E 00 53 00 65 00 63 00 // s.t.e.m...S.e.c. + 75 00 72 00 69 00 74 00 79 00 2E 00 50 00 65 00 // u.r.i.t.y...P.e. + 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n. + 53 00 65 00 74 00 22 00 0D 00 0A 00 76 00 65 00 // S.e.t.".....v.e. + 72 00 73 00 69 00 6F 00 6E 00 3D 00 22 00 31 00 // r.s.i.o.n.=.".1. + 22 00 3E 00 0D 00 0A 00 3C 00 49 00 50 00 65 00 // ".>.....<.I.P.e. + 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n. + 20 00 63 00 6C 00 61 00 73 00 73 00 3D 00 22 00 // .c.l.a.s.s.=.". + 53 00 79 00 73 00 74 00 65 00 6D 00 2E 00 53 00 // S.y.s.t.e.m...S. + 65 00 63 00 75 00 72 00 69 00 74 00 79 00 2E 00 // e.c.u.r.i.t.y... + 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 69 00 // P.e.r.m.i.s.s.i. + 6F 00 6E 00 73 00 2E 00 53 00 65 00 63 00 75 00 // o.n.s...S.e.c.u. + 72 00 69 00 74 00 79 00 50 00 65 00 72 00 6D 00 // r.i.t.y.P.e.r.m. + 69 00 73 00 73 00 69 00 6F 00 6E 00 2C 00 20 00 // i.s.s.i.o.n.,. . + 6D 00 73 00 63 00 6F 00 72 00 6C 00 69 00 62 00 // m.s.c.o.r.l.i.b. + 2C 00 20 00 56 00 65 00 72 00 73 00 69 00 6F 00 // ,. .V.e.r.s.i.o. + 6E 00 3D 00 32 00 2E 00 30 00 2E 00 30 00 2E 00 // n.=.2...0...0... + 30 00 2C 00 20 00 43 00 75 00 6C 00 74 00 75 00 // 0.,. .C.u.l.t.u. + 72 00 65 00 3D 00 6E 00 65 00 75 00 74 00 72 00 // r.e.=.n.e.u.t.r. + 61 00 6C 00 2C 00 20 00 50 00 75 00 62 00 6C 00 // a.l.,. .P.u.b.l. + 69 00 63 00 4B 00 65 00 79 00 54 00 6F 00 6B 00 // i.c.K.e.y.T.o.k. + 65 00 6E 00 3D 00 62 00 37 00 37 00 61 00 35 00 // e.n.=.b.7.7.a.5. + 63 00 35 00 36 00 31 00 39 00 33 00 34 00 65 00 // c.5.6.1.9.3.4.e. + 30 00 38 00 39 00 22 00 0D 00 0A 00 76 00 65 00 // 0.8.9.".....v.e. + 72 00 73 00 69 00 6F 00 6E 00 3D 00 22 00 31 00 // r.s.i.o.n.=.".1. + 22 00 0D 00 0A 00 46 00 6C 00 61 00 67 00 73 00 // ".....F.l.a.g.s. + 3D 00 22 00 53 00 6B 00 69 00 70 00 56 00 65 00 // =.".S.k.i.p.V.e. + 72 00 69 00 66 00 69 00 63 00 61 00 74 00 69 00 // r.i.f.i.c.a.t.i. + 6F 00 6E 00 22 00 2F 00 3E 00 0D 00 0A 00 3C 00 // o.n."./.>.....<. + 2F 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // /.P.e.r.m.i.s.s. + 69 00 6F 00 6E 00 53 00 65 00 74 00 3E 00 0D 00 // i.o.n.S.e.t.>... + 0A 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module ConstructorInitializers.mcs.dll +.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) +.imagebase 0x00400000 +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 // WINDOWS_CUI +.corflags 0x00000001 // ILONLY + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers + extends [mscorlib]System.Object +{ + .class sequential ansi sealed nested public beforefieldinit SimpleStruct + extends [mscorlib]System.ValueType + { + .field public int32 Field1 + .field public int32 Field2 + } // end of class SimpleStruct + + .class auto ansi nested public beforefieldinit UnsafeFields + extends [mscorlib]System.Object + { + .field public static int32 StaticSizeOf + .field public int32 SizeOf + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 19 (0x13) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: sizeof ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/SimpleStruct + IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/UnsafeFields::SizeOf + IL_000c: ldarg.0 + IL_000d: call instance void [mscorlib]System.Object::.ctor() + IL_0012: ret + } // end of method UnsafeFields::.ctor + + .method private specialname rtspecialname static + void .cctor() cil managed + { + // Code size 12 (0xc) + .maxstack 8 + IL_0000: sizeof ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/SimpleStruct + IL_0006: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/UnsafeFields::StaticSizeOf + IL_000b: ret + } // end of method UnsafeFields::.cctor + + } // end of class UnsafeFields + + .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 ConstructorInitializers::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.opt.il new file mode 100644 index 000000000..f96a7d44e --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.opt.il @@ -0,0 +1,87 @@ + + + + +// 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 ConstructorInitializers.opt +{ + .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 ConstructorInitializers.opt.dll +.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 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers + extends [mscorlib]System.Object +{ + .class sequential ansi sealed nested public beforefieldinit SimpleStruct + extends [mscorlib]System.ValueType + { + .field public int32 Field1 + .field public int32 Field2 + } // end of class SimpleStruct + + .class auto ansi nested public beforefieldinit UnsafeFields + extends [mscorlib]System.Object + { + .field public static int32 StaticSizeOf + .field public int32 SizeOf + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 19 (0x13) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: sizeof ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/SimpleStruct + IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/UnsafeFields::SizeOf + IL_000c: ldarg.0 + IL_000d: call instance void [mscorlib]System.Object::.ctor() + IL_0012: ret + } // end of method UnsafeFields::.ctor + + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 12 (0xc) + .maxstack 8 + IL_0000: sizeof ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/SimpleStruct + IL_0006: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/UnsafeFields::StaticSizeOf + IL_000b: ret + } // end of method UnsafeFields::.cctor + + } // end of class UnsafeFields + + .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 ConstructorInitializers::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.opt.mcs.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.opt.mcs.il new file mode 100644 index 000000000..186747841 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.opt.mcs.il @@ -0,0 +1,120 @@ + + + + +// Metadata version: v2.0.50727 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 2:0:0:0 +} +.assembly ConstructorInitializers.opt.mcs +{ + .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 + bytearray (3C 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // <.P.e.r.m.i.s.s. + 69 00 6F 00 6E 00 53 00 65 00 74 00 20 00 63 00 // i.o.n.S.e.t. .c. + 6C 00 61 00 73 00 73 00 3D 00 22 00 53 00 79 00 // l.a.s.s.=.".S.y. + 73 00 74 00 65 00 6D 00 2E 00 53 00 65 00 63 00 // s.t.e.m...S.e.c. + 75 00 72 00 69 00 74 00 79 00 2E 00 50 00 65 00 // u.r.i.t.y...P.e. + 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n. + 53 00 65 00 74 00 22 00 0D 00 0A 00 76 00 65 00 // S.e.t.".....v.e. + 72 00 73 00 69 00 6F 00 6E 00 3D 00 22 00 31 00 // r.s.i.o.n.=.".1. + 22 00 3E 00 0D 00 0A 00 3C 00 49 00 50 00 65 00 // ".>.....<.I.P.e. + 72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n. + 20 00 63 00 6C 00 61 00 73 00 73 00 3D 00 22 00 // .c.l.a.s.s.=.". + 53 00 79 00 73 00 74 00 65 00 6D 00 2E 00 53 00 // S.y.s.t.e.m...S. + 65 00 63 00 75 00 72 00 69 00 74 00 79 00 2E 00 // e.c.u.r.i.t.y... + 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 69 00 // P.e.r.m.i.s.s.i. + 6F 00 6E 00 73 00 2E 00 53 00 65 00 63 00 75 00 // o.n.s...S.e.c.u. + 72 00 69 00 74 00 79 00 50 00 65 00 72 00 6D 00 // r.i.t.y.P.e.r.m. + 69 00 73 00 73 00 69 00 6F 00 6E 00 2C 00 20 00 // i.s.s.i.o.n.,. . + 6D 00 73 00 63 00 6F 00 72 00 6C 00 69 00 62 00 // m.s.c.o.r.l.i.b. + 2C 00 20 00 56 00 65 00 72 00 73 00 69 00 6F 00 // ,. .V.e.r.s.i.o. + 6E 00 3D 00 32 00 2E 00 30 00 2E 00 30 00 2E 00 // n.=.2...0...0... + 30 00 2C 00 20 00 43 00 75 00 6C 00 74 00 75 00 // 0.,. .C.u.l.t.u. + 72 00 65 00 3D 00 6E 00 65 00 75 00 74 00 72 00 // r.e.=.n.e.u.t.r. + 61 00 6C 00 2C 00 20 00 50 00 75 00 62 00 6C 00 // a.l.,. .P.u.b.l. + 69 00 63 00 4B 00 65 00 79 00 54 00 6F 00 6B 00 // i.c.K.e.y.T.o.k. + 65 00 6E 00 3D 00 62 00 37 00 37 00 61 00 35 00 // e.n.=.b.7.7.a.5. + 63 00 35 00 36 00 31 00 39 00 33 00 34 00 65 00 // c.5.6.1.9.3.4.e. + 30 00 38 00 39 00 22 00 0D 00 0A 00 76 00 65 00 // 0.8.9.".....v.e. + 72 00 73 00 69 00 6F 00 6E 00 3D 00 22 00 31 00 // r.s.i.o.n.=.".1. + 22 00 0D 00 0A 00 46 00 6C 00 61 00 67 00 73 00 // ".....F.l.a.g.s. + 3D 00 22 00 53 00 6B 00 69 00 70 00 56 00 65 00 // =.".S.k.i.p.V.e. + 72 00 69 00 66 00 69 00 63 00 61 00 74 00 69 00 // r.i.f.i.c.a.t.i. + 6F 00 6E 00 22 00 2F 00 3E 00 0D 00 0A 00 3C 00 // o.n."./.>.....<. + 2F 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // /.P.e.r.m.i.s.s. + 69 00 6F 00 6E 00 53 00 65 00 74 00 3E 00 0D 00 // i.o.n.S.e.t.>... + 0A 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module ConstructorInitializers.opt.mcs.dll +.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) +.imagebase 0x00400000 +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 // WINDOWS_CUI +.corflags 0x00000001 // ILONLY + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers + extends [mscorlib]System.Object +{ + .class sequential ansi sealed nested public beforefieldinit SimpleStruct + extends [mscorlib]System.ValueType + { + .field public int32 Field1 + .field public int32 Field2 + } // end of class SimpleStruct + + .class auto ansi nested public beforefieldinit UnsafeFields + extends [mscorlib]System.Object + { + .field public static int32 StaticSizeOf + .field public int32 SizeOf + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 19 (0x13) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: sizeof ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/SimpleStruct + IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/UnsafeFields::SizeOf + IL_000c: ldarg.0 + IL_000d: call instance void [mscorlib]System.Object::.ctor() + IL_0012: ret + } // end of method UnsafeFields::.ctor + + .method private specialname rtspecialname static + void .cctor() cil managed + { + // Code size 12 (0xc) + .maxstack 8 + IL_0000: sizeof ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/SimpleStruct + IL_0006: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/UnsafeFields::StaticSizeOf + IL_000b: ret + } // end of method UnsafeFields::.cctor + + } // end of class UnsafeFields + + .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 ConstructorInitializers::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.opt.roslyn.il new file mode 100644 index 000000000..fd488e45d --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.opt.roslyn.il @@ -0,0 +1,91 @@ + + + + +// 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 ConstructorInitializers +{ + .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 ConstructorInitializers.dll +.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 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers + extends [mscorlib]System.Object +{ + .class sequential ansi sealed nested public beforefieldinit SimpleStruct + extends [mscorlib]System.ValueType + { + .field public int32 Field1 + .field public int32 Field2 + } // end of class SimpleStruct + + .class auto ansi nested public beforefieldinit UnsafeFields + extends [mscorlib]System.Object + { + .field public static int32 StaticSizeOf + .field public int32 SizeOf + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 19 (0x13) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: sizeof ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/SimpleStruct + IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/UnsafeFields::SizeOf + IL_000c: ldarg.0 + IL_000d: call instance void [mscorlib]System.Object::.ctor() + IL_0012: ret + } // end of method UnsafeFields::.ctor + + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 12 (0xc) + .maxstack 8 + IL_0000: sizeof ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/SimpleStruct + IL_0006: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/UnsafeFields::StaticSizeOf + IL_000b: ret + } // end of method UnsafeFields::.cctor + + } // end of class UnsafeFields + + .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 ConstructorInitializers::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.roslyn.il new file mode 100644 index 000000000..e18de96fc --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.roslyn.il @@ -0,0 +1,93 @@ + + + + +// 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 ConstructorInitializers +{ + .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 ConstructorInitializers.dll +.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 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers + extends [mscorlib]System.Object +{ + .class sequential ansi sealed nested public beforefieldinit SimpleStruct + extends [mscorlib]System.ValueType + { + .field public int32 Field1 + .field public int32 Field2 + } // end of class SimpleStruct + + .class auto ansi nested public beforefieldinit UnsafeFields + extends [mscorlib]System.Object + { + .field public static int32 StaticSizeOf + .field public int32 SizeOf + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 20 (0x14) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: sizeof ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/SimpleStruct + IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/UnsafeFields::SizeOf + IL_000c: ldarg.0 + IL_000d: call instance void [mscorlib]System.Object::.ctor() + IL_0012: nop + IL_0013: ret + } // end of method UnsafeFields::.ctor + + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 12 (0xc) + .maxstack 8 + IL_0000: sizeof ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/SimpleStruct + IL_0006: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers/UnsafeFields::StaticSizeOf + IL_000b: ret + } // end of method UnsafeFields::.cctor + + } // end of class UnsafeFields + + .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 ConstructorInitializers::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ConstructorInitializers + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/ConvertConstructorCallIntoInitializer.cs b/ICSharpCode.Decompiler/CSharp/Transforms/ConvertConstructorCallIntoInitializer.cs index 4b330a949..b87bf717a 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/ConvertConstructorCallIntoInitializer.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/ConvertConstructorCallIntoInitializer.cs @@ -122,6 +122,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms var ctorMethodDef = instanceCtorsNotChainingWithThis[0].GetSymbol() as IMethod; if (ctorMethodDef != null && ctorMethodDef.DeclaringType.IsReferenceType == false) return; + + bool ctorIsUnsafe = instanceCtorsNotChainingWithThis.All(c => c.HasModifier(Modifiers.Unsafe)); // Recognize field or property initializers: // Translate first statement in all ctors (if all ctors have the same statement) into an initializer. @@ -133,7 +135,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms IMember fieldOrPropertyOrEvent = (m.Get("fieldAccess").Single().GetSymbol() as IMember)?.MemberDefinition; if (!(fieldOrPropertyOrEvent is IField) && !(fieldOrPropertyOrEvent is IProperty) && !(fieldOrPropertyOrEvent is IEvent)) break; - AstNode fieldOrPropertyOrEventDecl = members.FirstOrDefault(f => f.GetSymbol() == fieldOrPropertyOrEvent); + var fieldOrPropertyOrEventDecl = members.FirstOrDefault(f => f.GetSymbol() == fieldOrPropertyOrEvent) as EntityDeclaration; // Cannot transform if member is not found or if it is a custom event. if (fieldOrPropertyOrEventDecl == null || fieldOrPropertyOrEventDecl is CustomEventDeclaration) break; @@ -158,6 +160,9 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms if (allSame) { foreach (var ctor in instanceCtorsNotChainingWithThis) ctor.Body.First().Remove(); + if (ctorIsUnsafe && IntroduceUnsafeModifier.IsUnsafe(initializer)) { + fieldOrPropertyOrEventDecl.Modifiers |= Modifiers.Unsafe; + } if (fieldOrPropertyOrEventDecl is PropertyDeclaration pd) { pd.Initializer = initializer.Detach(); } else { @@ -175,6 +180,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms if (instanceCtors.Length == 1 && (members.Skip(1).Any() || instanceCtors[0].Parent is TypeDeclaration)) { ConstructorDeclaration emptyCtor = new ConstructorDeclaration(); emptyCtor.Modifiers = contextTypeDefinition.IsAbstract ? Modifiers.Protected : Modifiers.Public; + if (instanceCtors[0].HasModifier(Modifiers.Unsafe)) + emptyCtor.Modifiers |= Modifiers.Unsafe; emptyCtor.Body = new BlockStatement(); if (emptyCtor.IsMatch(instanceCtors[0])) instanceCtors[0].Remove(); @@ -186,6 +193,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms // Translate static constructor into field initializers if the class is BeforeFieldInit var staticCtor = members.OfType().FirstOrDefault(c => (c.Modifiers & Modifiers.Static) == Modifiers.Static); if (staticCtor != null) { + bool ctorIsUnsafe = staticCtor.HasModifier(Modifiers.Unsafe); IMethod ctorMethod = staticCtor.GetSymbol() as IMethod; if (!ctorMethod.MetadataToken.IsNil) { var metadata = context.TypeSystem.MainModule.PEFile.Metadata; @@ -202,9 +210,12 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms IMember fieldOrProperty = (assignment.Left.GetSymbol() as IMember)?.MemberDefinition; if (!(fieldOrProperty is IField || fieldOrProperty is IProperty) || !fieldOrProperty.IsStatic) break; - AstNode fieldOrPropertyDecl = members.FirstOrDefault(f => f.GetSymbol() == fieldOrProperty); + var fieldOrPropertyDecl = members.FirstOrDefault(f => f.GetSymbol() == fieldOrProperty) as EntityDeclaration; if (fieldOrPropertyDecl == null) break; + if (ctorIsUnsafe && IntroduceUnsafeModifier.IsUnsafe(assignment.Right)) { + fieldOrPropertyDecl.Modifiers |= Modifiers.Unsafe; + } if (fieldOrPropertyDecl is FieldDeclaration fd) fd.Variables.Single().Initializer = assignment.Right.Detach(); else if (fieldOrPropertyDecl is PropertyDeclaration pd) diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs index 8882a7277..03e08bba6 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs @@ -29,6 +29,11 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms { compilationUnit.AcceptVisitor(this); } + + public static bool IsUnsafe(AstNode node) + { + return node.AcceptVisitor(new IntroduceUnsafeModifier()); + } protected override bool VisitChildren(AstNode node) { From 37a8156dab5ca3e18b761de534b8bdb135a5c310 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 7 Jan 2019 14:43:04 +0100 Subject: [PATCH 02/26] Fix #1383: NRE in TransformArrayInitializers. --- .../TestCases/Pretty/InitializerTests.cs | 8 + .../TestCases/Pretty/InitializerTests.il | 49 +++++- .../TestCases/Pretty/InitializerTests.opt.il | 45 +++++- .../Pretty/InitializerTests.opt.roslyn.il | 137 +++++++++------- .../Pretty/InitializerTests.roslyn.il | 146 +++++++++++------- .../Transforms/TransformArrayInitializers.cs | 2 +- 6 files changed, 263 insertions(+), 124 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs index 9714fe225..03310c992 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs @@ -1152,6 +1152,14 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests } }); } + + private int[] Issue1383(int i, int[] array) + { + array = new int[4]; + array[i++] = 1; + array[i++] = 2; + return array; + } #endregion #region Object initializers diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il index 1adbd8fd9..b6e8df93b 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il @@ -2395,6 +2395,41 @@ IL_0020: ret } // end of method TestCases::Issue907_Test3 + .method private hidebysig instance int32[] + Issue1383(int32 i, + int32[] 'array') cil managed + { + // Code size 33 (0x21) + .maxstack 4 + .locals init (int32[] V_0) + IL_0000: nop + IL_0001: ldc.i4.4 + IL_0002: newarr [mscorlib]System.Int32 + IL_0007: starg.s 'array' + IL_0009: ldarg.2 + IL_000a: ldarg.1 + IL_000b: dup + IL_000c: ldc.i4.1 + IL_000d: add + IL_000e: starg.s i + IL_0010: ldc.i4.1 + IL_0011: stelem.i4 + IL_0012: ldarg.2 + IL_0013: ldarg.1 + IL_0014: dup + IL_0015: ldc.i4.1 + IL_0016: add + IL_0017: starg.s i + IL_0019: ldc.i4.2 + IL_001a: stelem.i4 + IL_001b: ldarg.2 + IL_001c: stloc.0 + IL_001d: br.s IL_001f + + IL_001f: ldloc.0 + IL_0020: ret + } // end of method TestCases::Issue1383 + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C Test1() cil managed { @@ -3170,7 +3205,7 @@ IL_0001: ldc.i4.4 IL_0002: newarr [mscorlib]System.Byte IL_0007: dup - IL_0008: ldtoken field int32 ''::'$$method0x6000041-1' + IL_0008: ldtoken field int32 ''::'$$method0x6000042-1' IL_000d: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0012: stloc.0 @@ -4435,7 +4470,7 @@ IL_0787: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_078c: dup - IL_078d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=36' ''::'$$method0x6000090-1' + IL_078d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=36' ''::'$$method0x6000091-1' IL_0792: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0797: stsfld int32[0...,0...] ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Issue1336_rg2 @@ -4539,8 +4574,8 @@ .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001e-4' at I_000029A8 .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x600001f-1' at I_00002A58 .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x600001f-2' at I_00002AA0 - .field static assembly int32 '$$method0x6000041-1' at I_00003318 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=36' '$$method0x6000090-1' at I_00003600 + .field static assembly int32 '$$method0x6000042-1' at I_00003348 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=36' '$$method0x6000091-1' at I_00003630 } // end of class '' @@ -4648,10 +4683,10 @@ 1D 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 // ........ ...!... 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 // "...#...$...%... 26 00 00 00 27 00 00 00) // &...'... -.data cil I_00003318 = bytearray ( +.data cil I_00003348 = bytearray ( 00 01 02 FF) -.data cil I_0000331C = int8[228] -.data cil I_00003600 = bytearray ( +.data cil I_0000334C = int8[4] +.data cil I_00003630 = bytearray ( 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il index ef48d40d0..fc6d554eb 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il @@ -2141,6 +2141,35 @@ IL_001d: ret } // end of method TestCases::Issue907_Test3 + .method private hidebysig instance int32[] + Issue1383(int32 i, + int32[] 'array') cil managed + { + // Code size 28 (0x1c) + .maxstack 8 + IL_0000: ldc.i4.4 + IL_0001: newarr [mscorlib]System.Int32 + IL_0006: starg.s 'array' + IL_0008: ldarg.2 + IL_0009: ldarg.1 + IL_000a: dup + IL_000b: ldc.i4.1 + IL_000c: add + IL_000d: starg.s i + IL_000f: ldc.i4.1 + IL_0010: stelem.i4 + IL_0011: ldarg.2 + IL_0012: ldarg.1 + IL_0013: dup + IL_0014: ldc.i4.1 + IL_0015: add + IL_0016: starg.s i + IL_0018: ldc.i4.2 + IL_0019: stelem.i4 + IL_001a: ldarg.2 + IL_001b: ret + } // end of method TestCases::Issue1383 + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C Test1() cil managed { @@ -2780,7 +2809,7 @@ IL_0000: ldc.i4.4 IL_0001: newarr [mscorlib]System.Byte IL_0006: dup - IL_0007: ldtoken field int32 ''::'$$method0x6000041-1' + IL_0007: ldtoken field int32 ''::'$$method0x6000042-1' IL_000c: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0011: ret @@ -3991,7 +4020,7 @@ IL_07df: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_07e4: dup - IL_07e5: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=36' ''::'$$method0x6000090-1' + IL_07e5: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=36' ''::'$$method0x6000091-1' IL_07ea: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_07ef: stsfld int32[0...,0...] ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Issue1336_rg2 @@ -4095,8 +4124,8 @@ .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001e-4' at I_00002938 .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x600001f-1' at I_000029E8 .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x600001f-2' at I_00002A30 - .field static assembly int32 '$$method0x6000041-1' at I_00003200 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=36' '$$method0x6000090-1' at I_000034A0 + .field static assembly int32 '$$method0x6000042-1' at I_00003220 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=36' '$$method0x6000091-1' at I_000034C0 } // end of class '' @@ -4202,11 +4231,11 @@ 1D 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 // ........ ...!... 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 // "...#...$...%... 26 00 00 00 27 00 00 00) // &...'... -.data cil I_00002A78 = int8[392] -.data cil I_00003200 = bytearray ( +.data cil I_00002A78 = int8[8] +.data cil I_00003220 = bytearray ( 00 01 02 FF) -.data cil I_00003204 = int8[28] -.data cil I_000034A0 = bytearray ( +.data cil I_00003224 = int8[28] +.data cil I_000034C0 = bytearray ( 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il index ce076988b..b9bef1887 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il @@ -1188,8 +1188,8 @@ { .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .field public static initonly class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' '<>9' - .field public static class [mscorlib]System.EventHandler '<>9__62_0' - .field public static class [mscorlib]System.Func`2 '<>9__76_0' + .field public static class [mscorlib]System.EventHandler '<>9__63_0' + .field public static class [mscorlib]System.Func`2 '<>9__77_0' .method private hidebysig specialname rtspecialname static void .cctor() cil managed { @@ -1211,17 +1211,17 @@ } // end of method '<>c'::.ctor .method assembly hidebysig instance void - 'b__62_0'(object '', + 'b__63_0'(object '', class [mscorlib]System.EventArgs '') cil managed { // Code size 6 (0x6) .maxstack 8 IL_0000: call void [mscorlib]System.Console::WriteLine() IL_0005: ret - } // end of method '<>c'::'b__62_0' + } // end of method '<>c'::'b__63_0' .method assembly hidebysig instance bool - 'b__76_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed + 'b__77_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed { // Code size 17 (0x11) .maxstack 8 @@ -1231,7 +1231,7 @@ IL_000b: call bool [mscorlib]System.String::op_Equality(string, string) IL_0010: ret - } // end of method '<>c'::'b__76_0' + } // end of method '<>c'::'b__77_0' } // end of class '<>c' @@ -2128,6 +2128,35 @@ IL_001b: ret } // end of method TestCases::Issue907_Test3 + .method private hidebysig instance int32[] + Issue1383(int32 i, + int32[] 'array') cil managed + { + // Code size 28 (0x1c) + .maxstack 8 + IL_0000: ldc.i4.4 + IL_0001: newarr [mscorlib]System.Int32 + IL_0006: starg.s 'array' + IL_0008: ldarg.2 + IL_0009: ldarg.1 + IL_000a: dup + IL_000b: ldc.i4.1 + IL_000c: add + IL_000d: starg.s i + IL_000f: ldc.i4.1 + IL_0010: stelem.i4 + IL_0011: ldarg.2 + IL_0012: ldarg.1 + IL_0013: dup + IL_0014: ldc.i4.1 + IL_0015: add + IL_0016: starg.s i + IL_0018: ldc.i4.2 + IL_0019: stelem.i4 + IL_001a: ldarg.2 + IL_001b: ret + } // end of method TestCases::Issue1383 + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C Test1() cil managed { @@ -2274,18 +2303,18 @@ IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::.ctor() IL_0005: stloc.0 IL_0006: ldloc.0 - IL_0007: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__62_0' + IL_0007: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__63_0' IL_000c: dup IL_000d: brtrue.s IL_0026 IL_000f: pop IL_0010: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9' - IL_0015: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__62_0'(object, + IL_0015: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__63_0'(object, class [mscorlib]System.EventArgs) IL_001b: newobj instance void [mscorlib]System.EventHandler::.ctor(object, native int) IL_0020: dup - IL_0021: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__62_0' + IL_0021: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__63_0' IL_0026: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::add_TestEvent(class [mscorlib]System.EventHandler) IL_002b: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y() IL_0030: ldloc.0 @@ -2622,17 +2651,17 @@ IL_0033: callvirt instance void [mscorlib]System.Globalization.CultureInfo::set_DateTimeFormat(class [mscorlib]System.Globalization.DateTimeFormatInfo) IL_0038: dup IL_0039: ldloc.0 - IL_003a: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__76_0' + IL_003a: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__77_0' IL_003f: dup IL_0040: brtrue.s IL_0059 IL_0042: pop IL_0043: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9' - IL_0048: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__76_0'(class [mscorlib]System.Globalization.NumberFormatInfo) + IL_0048: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__77_0'(class [mscorlib]System.Globalization.NumberFormatInfo) IL_004e: newobj instance void class [mscorlib]System.Func`2::.ctor(object, native int) IL_0053: dup - IL_0054: stsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__76_0' + IL_0054: stsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__77_0' IL_0059: call class [mscorlib]System.Collections.Generic.IEnumerable`1 [System.Core]System.Linq.Enumerable::Where(class [mscorlib]System.Collections.Generic.IEnumerable`1, class [mscorlib]System.Func`2) IL_005e: call !!0 [System.Core]System.Linq.Enumerable::First(class [mscorlib]System.Collections.Generic.IEnumerable`1) @@ -4046,67 +4075,67 @@ .size 256 } // end of class '__StaticArrayInitTypeSize=256' - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '1535117EC92E41D4A6B7CA00F965357B05B5DC35' at I_00006C44 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '20E3FF489634E18F3F7EB292AD504DBAE9519293' at I_00006C8C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '39E94835525CF7B71CD4595742EF462642FBF1B2' at I_00006C9C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '56D9EEC8EF899644C40B9BE9D886DF2367A5D078' at I_00006CE4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '735E5A21849E86F68D220F06163E8C5C6376B9C9' at I_00006CF4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' '7C39B7B06DD624A17F875AB8E9651554BE6E74D2' at I_00006D04 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' '8D903ECAD8D9D75B3183B23AF79F6D2E607369E3' at I_00006D44 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=80' '9B1F6E56D755443CC39C1969CE38FD41FD4EF4B7' at I_00006D6C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=256' A1EA7DC3FE43B3A54F5B729A92B92AF54181A3EB at I_00006DBC - .field static assembly initonly int64 A6296CAC471BE2954899600137940479D8073C7C at I_00006EBC - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=36' B62E59D20E3D69F06A6D9BD5E3C518FF7093EDAB at I_00006EC4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' B9583930B842DBCEF0D7B8E57D4D3F1E8055C39E at I_00006EEC - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' C4E70AB31EF6C8908F896CAD1C6BC75F7FA65E27 at I_00006F14 - .field static assembly initonly int32 C62C27924F4C967F5EDDB1850C091D54C7A2AB58 at I_00006F2C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=48' DC7043B0114737ACE19A23DD755893795FD48A23 at I_00006F34 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' DCF557B883E6FE0AEC05B7F0290F0EF47D0AC2E3 at I_00006F64 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_00006FA4 - .field static assembly initonly int64 EB0715DBB235F3F696F2C404F5839C6650640898 at I_00006FCC - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' F514FF55B79BCAA2CEC9B56C062D976E45F89AB7 at I_00006FD4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' FBCB49C1A244C1B5781AA1DB02C5A11F68908526 at I_00006FFC + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '1535117EC92E41D4A6B7CA00F965357B05B5DC35' at I_00006C8C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '20E3FF489634E18F3F7EB292AD504DBAE9519293' at I_00006CD4 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '39E94835525CF7B71CD4595742EF462642FBF1B2' at I_00006CE4 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '56D9EEC8EF899644C40B9BE9D886DF2367A5D078' at I_00006D2C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '735E5A21849E86F68D220F06163E8C5C6376B9C9' at I_00006D3C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' '7C39B7B06DD624A17F875AB8E9651554BE6E74D2' at I_00006D4C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' '8D903ECAD8D9D75B3183B23AF79F6D2E607369E3' at I_00006D8C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=80' '9B1F6E56D755443CC39C1969CE38FD41FD4EF4B7' at I_00006DB4 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=256' A1EA7DC3FE43B3A54F5B729A92B92AF54181A3EB at I_00006E04 + .field static assembly initonly int64 A6296CAC471BE2954899600137940479D8073C7C at I_00006F04 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=36' B62E59D20E3D69F06A6D9BD5E3C518FF7093EDAB at I_00006F0C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' B9583930B842DBCEF0D7B8E57D4D3F1E8055C39E at I_00006F34 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' C4E70AB31EF6C8908F896CAD1C6BC75F7FA65E27 at I_00006F5C + .field static assembly initonly int32 C62C27924F4C967F5EDDB1850C091D54C7A2AB58 at I_00006F74 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=48' DC7043B0114737ACE19A23DD755893795FD48A23 at I_00006F7C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' DCF557B883E6FE0AEC05B7F0290F0EF47D0AC2E3 at I_00006FAC + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_00006FEC + .field static assembly initonly int64 EB0715DBB235F3F696F2C404F5839C6650640898 at I_00007014 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' F514FF55B79BCAA2CEC9B56C062D976E45F89AB7 at I_0000701C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' FBCB49C1A244C1B5781AA1DB02C5A11F68908526 at I_00007044 } // end of class '' // ============================================================= -.data cil I_00006C44 = bytearray ( +.data cil I_00006C8C = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00) -.data cil I_00006C8C = bytearray ( +.data cil I_00006CD4 = bytearray ( 01 02 03 04 05 06 07 08 FE FF) -.data cil I_00006C96 = int8[2] -.data cil I_00006C9C = bytearray ( +.data cil I_00006CDE = int8[2] +.data cil I_00006CE4 = bytearray ( 15 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 // ........ ...!... 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 // "...#...$...%... 26 00 00 00 27 00 00 00) // &...'... -.data cil I_00006CE4 = bytearray ( +.data cil I_00006D2C = bytearray ( 00 80 FF FF 00 00 01 00 FF 7F) -.data cil I_00006CEE = int8[2] -.data cil I_00006CF4 = bytearray ( +.data cil I_00006D36 = int8[2] +.data cil I_00006D3C = bytearray ( 00 00 01 00 FF 7F 00 80 FE FF FF FF) -.data cil I_00006D04 = bytearray ( +.data cil I_00006D4C = bytearray ( 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_00006D44 = bytearray ( +.data cil I_00006D8C = bytearray ( 01 00 0C BB 7D 6E 9C BA FF FF FF FF FF FF FF FF // ....}n.......... 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45) // ...D..cE -.data cil I_00006D6C = bytearray ( +.data cil I_00006DB4 = bytearray ( 01 00 00 00 00 00 00 00 00 94 35 77 00 00 00 00 // ..........5w.... 00 5E D0 B2 00 00 00 00 04 00 00 00 00 00 00 00 // .^.............. 05 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45 FF FF E7 89 04 23 C7 8A) // ...D..cE.....#.. -.data cil I_00006DBC = bytearray ( +.data cil I_00006E04 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -4123,41 +4152,41 @@ 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_00006EBC = bytearray ( +.data cil I_00006F04 = bytearray ( 80 81 00 01 02 03 04 7F) -.data cil I_00006EC4 = bytearray ( +.data cil I_00006F0C = bytearray ( 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00) -.data cil I_00006EEC = bytearray ( +.data cil I_00006F34 = bytearray ( 01 00 00 00 00 94 35 77 00 5E D0 B2 04 00 00 00 // ......5w.^...... 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00006F14 = bytearray ( +.data cil I_00006F5C = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00) -.data cil I_00006F2C = bytearray ( +.data cil I_00006F74 = bytearray ( 00 01 02 FF) -.data cil I_00006F34 = bytearray ( +.data cil I_00006F7C = bytearray ( 00 00 00 00 00 00 F8 BF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F8 3F 00 00 00 00 00 00 F0 FF // .......?........ 00 00 00 00 00 00 F0 7F 00 00 00 00 00 00 F8 FF) -.data cil I_00006F64 = bytearray ( +.data cil I_00006FAC = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00) -.data cil I_00006FA4 = bytearray ( +.data cil I_00006FEC = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00006FCC = bytearray ( +.data cil I_00007014 = bytearray ( 01 00 01 00 00 00 01 01) -.data cil I_00006FD4 = bytearray ( +.data cil I_0000701C = bytearray ( 01 00 00 00 FE FF FF FF 00 94 35 77 04 00 00 00 // ..........5w.... 05 00 00 00 FA FF FF FF 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00006FFC = bytearray ( +.data cil I_00007044 = bytearray ( 00 00 C0 BF 00 00 00 00 00 00 C0 3F 00 00 80 FF // ...........?.... 00 00 80 7F 00 00 C0 FF) // *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il index c95bfde56..3722f6371 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il @@ -1257,8 +1257,8 @@ { .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .field public static initonly class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' '<>9' - .field public static class [mscorlib]System.EventHandler '<>9__62_0' - .field public static class [mscorlib]System.Func`2 '<>9__76_0' + .field public static class [mscorlib]System.EventHandler '<>9__63_0' + .field public static class [mscorlib]System.Func`2 '<>9__77_0' .method private hidebysig specialname rtspecialname static void .cctor() cil managed { @@ -1281,7 +1281,7 @@ } // end of method '<>c'::.ctor .method assembly hidebysig instance void - 'b__62_0'(object '', + 'b__63_0'(object '', class [mscorlib]System.EventArgs '') cil managed { // Code size 8 (0x8) @@ -1290,10 +1290,10 @@ IL_0001: call void [mscorlib]System.Console::WriteLine() IL_0006: nop IL_0007: ret - } // end of method '<>c'::'b__62_0' + } // end of method '<>c'::'b__63_0' .method assembly hidebysig instance bool - 'b__76_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed + 'b__77_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed { // Code size 17 (0x11) .maxstack 8 @@ -1303,7 +1303,7 @@ IL_000b: call bool [mscorlib]System.String::op_Equality(string, string) IL_0010: ret - } // end of method '<>c'::'b__76_0' + } // end of method '<>c'::'b__77_0' } // end of class '<>c' @@ -2305,6 +2305,41 @@ IL_001e: ret } // end of method TestCases::Issue907_Test3 + .method private hidebysig instance int32[] + Issue1383(int32 i, + int32[] 'array') cil managed + { + // Code size 33 (0x21) + .maxstack 4 + .locals init (int32[] V_0) + IL_0000: nop + IL_0001: ldc.i4.4 + IL_0002: newarr [mscorlib]System.Int32 + IL_0007: starg.s 'array' + IL_0009: ldarg.2 + IL_000a: ldarg.1 + IL_000b: dup + IL_000c: ldc.i4.1 + IL_000d: add + IL_000e: starg.s i + IL_0010: ldc.i4.1 + IL_0011: stelem.i4 + IL_0012: ldarg.2 + IL_0013: ldarg.1 + IL_0014: dup + IL_0015: ldc.i4.1 + IL_0016: add + IL_0017: starg.s i + IL_0019: ldc.i4.2 + IL_001a: stelem.i4 + IL_001b: ldarg.2 + IL_001c: stloc.0 + IL_001d: br.s IL_001f + + IL_001f: ldloc.0 + IL_0020: ret + } // end of method TestCases::Issue1383 + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C Test1() cil managed { @@ -2508,18 +2543,18 @@ IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::.ctor() IL_0006: stloc.0 IL_0007: ldloc.0 - IL_0008: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__62_0' + IL_0008: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__63_0' IL_000d: dup IL_000e: brtrue.s IL_0027 IL_0010: pop IL_0011: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9' - IL_0016: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__62_0'(object, + IL_0016: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__63_0'(object, class [mscorlib]System.EventArgs) IL_001c: newobj instance void [mscorlib]System.EventHandler::.ctor(object, native int) IL_0021: dup - IL_0022: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__62_0' + IL_0022: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__63_0' IL_0027: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::add_TestEvent(class [mscorlib]System.EventHandler) IL_002c: nop IL_002d: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y() @@ -2919,17 +2954,17 @@ IL_003b: nop IL_003c: dup IL_003d: ldloc.0 - IL_003e: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__76_0' + IL_003e: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__77_0' IL_0043: dup IL_0044: brtrue.s IL_005d IL_0046: pop IL_0047: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9' - IL_004c: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__76_0'(class [mscorlib]System.Globalization.NumberFormatInfo) + IL_004c: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__77_0'(class [mscorlib]System.Globalization.NumberFormatInfo) IL_0052: newobj instance void class [mscorlib]System.Func`2::.ctor(object, native int) IL_0057: dup - IL_0058: stsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__76_0' + IL_0058: stsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__77_0' IL_005d: call class [mscorlib]System.Collections.Generic.IEnumerable`1 [System.Core]System.Linq.Enumerable::Where(class [mscorlib]System.Collections.Generic.IEnumerable`1, class [mscorlib]System.Func`2) IL_0062: call !!0 [System.Core]System.Linq.Enumerable::First(class [mscorlib]System.Collections.Generic.IEnumerable`1) @@ -4486,67 +4521,68 @@ .size 256 } // end of class '__StaticArrayInitTypeSize=256' - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '1535117EC92E41D4A6B7CA00F965357B05B5DC35' at I_00007044 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '20E3FF489634E18F3F7EB292AD504DBAE9519293' at I_0000708C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '39E94835525CF7B71CD4595742EF462642FBF1B2' at I_0000709C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '56D9EEC8EF899644C40B9BE9D886DF2367A5D078' at I_000070E4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '735E5A21849E86F68D220F06163E8C5C6376B9C9' at I_000070F4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' '7C39B7B06DD624A17F875AB8E9651554BE6E74D2' at I_00007104 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' '8D903ECAD8D9D75B3183B23AF79F6D2E607369E3' at I_00007144 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=80' '9B1F6E56D755443CC39C1969CE38FD41FD4EF4B7' at I_0000716C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=256' A1EA7DC3FE43B3A54F5B729A92B92AF54181A3EB at I_000071BC - .field static assembly initonly int64 A6296CAC471BE2954899600137940479D8073C7C at I_000072BC - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=36' B62E59D20E3D69F06A6D9BD5E3C518FF7093EDAB at I_000072C4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' B9583930B842DBCEF0D7B8E57D4D3F1E8055C39E at I_000072EC - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' C4E70AB31EF6C8908F896CAD1C6BC75F7FA65E27 at I_00007314 - .field static assembly initonly int32 C62C27924F4C967F5EDDB1850C091D54C7A2AB58 at I_0000732C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=48' DC7043B0114737ACE19A23DD755893795FD48A23 at I_00007334 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' DCF557B883E6FE0AEC05B7F0290F0EF47D0AC2E3 at I_00007364 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_000073A4 - .field static assembly initonly int64 EB0715DBB235F3F696F2C404F5839C6650640898 at I_000073CC - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' F514FF55B79BCAA2CEC9B56C062D976E45F89AB7 at I_000073D4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' FBCB49C1A244C1B5781AA1DB02C5A11F68908526 at I_000073FC + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '1535117EC92E41D4A6B7CA00F965357B05B5DC35' at I_000070A0 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '20E3FF489634E18F3F7EB292AD504DBAE9519293' at I_000070E8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '39E94835525CF7B71CD4595742EF462642FBF1B2' at I_000070F8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '56D9EEC8EF899644C40B9BE9D886DF2367A5D078' at I_00007140 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '735E5A21849E86F68D220F06163E8C5C6376B9C9' at I_00007150 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' '7C39B7B06DD624A17F875AB8E9651554BE6E74D2' at I_00007160 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' '8D903ECAD8D9D75B3183B23AF79F6D2E607369E3' at I_000071A0 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=80' '9B1F6E56D755443CC39C1969CE38FD41FD4EF4B7' at I_000071C8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=256' A1EA7DC3FE43B3A54F5B729A92B92AF54181A3EB at I_00007218 + .field static assembly initonly int64 A6296CAC471BE2954899600137940479D8073C7C at I_00007318 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=36' B62E59D20E3D69F06A6D9BD5E3C518FF7093EDAB at I_00007320 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' B9583930B842DBCEF0D7B8E57D4D3F1E8055C39E at I_00007348 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' C4E70AB31EF6C8908F896CAD1C6BC75F7FA65E27 at I_00007370 + .field static assembly initonly int32 C62C27924F4C967F5EDDB1850C091D54C7A2AB58 at I_00007388 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=48' DC7043B0114737ACE19A23DD755893795FD48A23 at I_00007390 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' DCF557B883E6FE0AEC05B7F0290F0EF47D0AC2E3 at I_000073C0 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_00007400 + .field static assembly initonly int64 EB0715DBB235F3F696F2C404F5839C6650640898 at I_00007428 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' F514FF55B79BCAA2CEC9B56C062D976E45F89AB7 at I_00007430 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' FBCB49C1A244C1B5781AA1DB02C5A11F68908526 at I_00007458 } // end of class '' // ============================================================= -.data cil I_00007044 = bytearray ( +.data cil I_000070A0 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00) -.data cil I_0000708C = bytearray ( +.data cil I_000070E8 = bytearray ( 01 02 03 04 05 06 07 08 FE FF) -.data cil I_00007096 = int8[2] -.data cil I_0000709C = bytearray ( +.data cil I_000070F2 = int8[6] +.data cil I_000070F8 = bytearray ( 15 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 // ........ ...!... 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 // "...#...$...%... 26 00 00 00 27 00 00 00) // &...'... -.data cil I_000070E4 = bytearray ( +.data cil I_00007140 = bytearray ( 00 80 FF FF 00 00 01 00 FF 7F) -.data cil I_000070EE = int8[2] -.data cil I_000070F4 = bytearray ( +.data cil I_0000714A = int8[6] +.data cil I_00007150 = bytearray ( 00 00 01 00 FF 7F 00 80 FE FF FF FF) -.data cil I_00007104 = bytearray ( +.data cil I_0000715C = int8[4] +.data cil I_00007160 = bytearray ( 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_00007144 = bytearray ( +.data cil I_000071A0 = bytearray ( 01 00 0C BB 7D 6E 9C BA FF FF FF FF FF FF FF FF // ....}n.......... 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45) // ...D..cE -.data cil I_0000716C = bytearray ( +.data cil I_000071C8 = bytearray ( 01 00 00 00 00 00 00 00 00 94 35 77 00 00 00 00 // ..........5w.... 00 5E D0 B2 00 00 00 00 04 00 00 00 00 00 00 00 // .^.............. 05 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45 FF FF E7 89 04 23 C7 8A) // ...D..cE.....#.. -.data cil I_000071BC = bytearray ( +.data cil I_00007218 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -4563,41 +4599,43 @@ 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_000072BC = bytearray ( +.data cil I_00007318 = bytearray ( 80 81 00 01 02 03 04 7F) -.data cil I_000072C4 = bytearray ( +.data cil I_00007320 = bytearray ( 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00) -.data cil I_000072EC = bytearray ( +.data cil I_00007344 = int8[4] +.data cil I_00007348 = bytearray ( 01 00 00 00 00 94 35 77 00 5E D0 B2 04 00 00 00 // ......5w.^...... 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00007314 = bytearray ( +.data cil I_00007370 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00) -.data cil I_0000732C = bytearray ( +.data cil I_00007388 = bytearray ( 00 01 02 FF) -.data cil I_00007334 = bytearray ( +.data cil I_0000738C = int8[4] +.data cil I_00007390 = bytearray ( 00 00 00 00 00 00 F8 BF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F8 3F 00 00 00 00 00 00 F0 FF // .......?........ 00 00 00 00 00 00 F0 7F 00 00 00 00 00 00 F8 FF) -.data cil I_00007364 = bytearray ( +.data cil I_000073C0 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00) -.data cil I_000073A4 = bytearray ( +.data cil I_00007400 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_000073CC = bytearray ( +.data cil I_00007428 = bytearray ( 01 00 01 00 00 00 01 01) -.data cil I_000073D4 = bytearray ( +.data cil I_00007430 = bytearray ( 01 00 00 00 FE FF FF FF 00 94 35 77 04 00 00 00 // ..........5w.... 05 00 00 00 FA FF FF FF 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_000073FC = bytearray ( +.data cil I_00007458 = bytearray ( 00 00 C0 BF 00 00 00 00 00 00 C0 3F 00 00 80 FF // ...........?.... 00 00 80 7F 00 00 C0 FF) // *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs b/ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs index d8df3a2d6..759abc46e 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs @@ -317,7 +317,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms } else { for (int k = 0; k < indices.Count; k++) { if (!indices[k].MatchLdcI4(out int index)) - return nextIndices; + return null; // index must be in range [0..length[ and must be greater than or equal to nextMinimumIndex // to avoid running out of bounds or accidentally reordering instructions or overwriting previous instructions. // However, leaving array slots empty is allowed, as those are filled with default values when the From 4919b11c30899874c355ffc783cdd888a1ece2ce Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 7 Jan 2019 15:28:14 +0100 Subject: [PATCH 03/26] Fix #1384: NRE on VS2015 Tools\ILSpy command --- ILSpy.AddIn/ILSpyInstance.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ILSpy.AddIn/ILSpyInstance.cs b/ILSpy.AddIn/ILSpyInstance.cs index 3c56e448e..0cc23f773 100644 --- a/ILSpy.AddIn/ILSpyInstance.cs +++ b/ILSpy.AddIn/ILSpyInstance.cs @@ -22,13 +22,9 @@ namespace ICSharpCode.ILSpy.AddIn class ILSpyInstance { - ILSpyParameters parameters; + readonly ILSpyParameters parameters; - public ILSpyInstance() - { - } - - public ILSpyInstance(ILSpyParameters parameters) + public ILSpyInstance(ILSpyParameters parameters = null) { this.parameters = parameters; } @@ -41,7 +37,7 @@ namespace ICSharpCode.ILSpy.AddIn public void Start() { - var commandLineArguments = parameters.AssemblyFileNames?.Concat(parameters.Arguments); + var commandLineArguments = parameters?.AssemblyFileNames?.Concat(parameters.Arguments); var process = new Process() { StartInfo = new ProcessStartInfo() { From 46b56f8482c8e5b5c136f9aa1d5d348799c63d25 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 7 Jan 2019 16:33:05 +0100 Subject: [PATCH 04/26] Fix #1382: Do not reuse index instructions in TransformArrayInitializers --- .../IL/Transforms/TransformArrayInitializers.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs b/ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs index 759abc46e..e808bc333 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs @@ -324,11 +324,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms // initializer block is generated. if (index < 0 || index >= arrayLength[k] || index < nextMinimumIndex[k]) return null; + nextIndices[k] = new LdcI4(nextMinimumIndex[k]); if (index != nextMinimumIndex[k]) { exactMatch = false; - nextIndices[k] = new LdcI4(nextMinimumIndex[k]); - } else { - nextIndices[k] = indices[k]; } } } From 3d5b300602520f09d9b8a6d589dee7382b6e12db Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 7 Jan 2019 17:43:18 +0100 Subject: [PATCH 05/26] Improve TransformArrayInitializers: allow default entries at the end of a dimension > 0. --- .../TestCases/Pretty/InitializerTests.cs | 60 ++++ .../TestCases/Pretty/InitializerTests.il | 224 ++++++++++++- .../TestCases/Pretty/InitializerTests.opt.il | 213 +++++++++++- .../Pretty/InitializerTests.opt.roslyn.il | 303 ++++++++++++++--- .../Pretty/InitializerTests.roslyn.il | 315 ++++++++++++++---- .../Transforms/TransformArrayInitializers.cs | 7 +- 6 files changed, 995 insertions(+), 127 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs index 03310c992..c05b44f0d 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs @@ -1160,6 +1160,66 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests array[i++] = 2; return array; } + + private string[,] Issue1382a() + { + return new string[4, 4] { + { + null, + "test", + "hello", + "world" + }, + { + "test", + null, + "hello", + "world" + }, + { + "test", + "hello", + null, + "world" + }, + { + "test", + "hello", + "world", + null + } + }; + } + + private string[,] Issue1382b() + { + return new string[4, 4] { + { + "test", + "hello", + "world", + null + }, + { + "test", + "hello", + null, + "world" + }, + { + "test", + null, + "hello", + "world" + }, + { + null, + "test", + "hello", + "world" + } + }; + } #endregion #region Object initializers diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il index b6e8df93b..ef81efe69 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il @@ -2430,6 +2430,216 @@ IL_0020: ret } // end of method TestCases::Issue1383 + .method private hidebysig instance string[0...,0...] + Issue1382a() cil managed + { + // Code size 171 (0xab) + .maxstack 4 + .locals init (string[0...,0...] V_0, + string[0...,0...] V_1) + IL_0000: nop + IL_0001: ldc.i4.4 + IL_0002: ldc.i4.4 + IL_0003: newobj instance void string[0...,0...]::.ctor(int32, + int32) + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: ldc.i4.0 + IL_000b: ldc.i4.1 + IL_000c: ldstr "test" + IL_0011: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0016: ldloc.1 + IL_0017: ldc.i4.0 + IL_0018: ldc.i4.2 + IL_0019: ldstr "hello" + IL_001e: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0023: ldloc.1 + IL_0024: ldc.i4.0 + IL_0025: ldc.i4.3 + IL_0026: ldstr "world" + IL_002b: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0030: ldloc.1 + IL_0031: ldc.i4.1 + IL_0032: ldc.i4.0 + IL_0033: ldstr "test" + IL_0038: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_003d: ldloc.1 + IL_003e: ldc.i4.1 + IL_003f: ldc.i4.2 + IL_0040: ldstr "hello" + IL_0045: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_004a: ldloc.1 + IL_004b: ldc.i4.1 + IL_004c: ldc.i4.3 + IL_004d: ldstr "world" + IL_0052: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0057: ldloc.1 + IL_0058: ldc.i4.2 + IL_0059: ldc.i4.0 + IL_005a: ldstr "test" + IL_005f: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0064: ldloc.1 + IL_0065: ldc.i4.2 + IL_0066: ldc.i4.1 + IL_0067: ldstr "hello" + IL_006c: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0071: ldloc.1 + IL_0072: ldc.i4.2 + IL_0073: ldc.i4.3 + IL_0074: ldstr "world" + IL_0079: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_007e: ldloc.1 + IL_007f: ldc.i4.3 + IL_0080: ldc.i4.0 + IL_0081: ldstr "test" + IL_0086: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_008b: ldloc.1 + IL_008c: ldc.i4.3 + IL_008d: ldc.i4.1 + IL_008e: ldstr "hello" + IL_0093: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0098: ldloc.1 + IL_0099: ldc.i4.3 + IL_009a: ldc.i4.2 + IL_009b: ldstr "world" + IL_00a0: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_00a5: ldloc.1 + IL_00a6: stloc.0 + IL_00a7: br.s IL_00a9 + + IL_00a9: ldloc.0 + IL_00aa: ret + } // end of method TestCases::Issue1382a + + .method private hidebysig instance string[0...,0...] + Issue1382b() cil managed + { + // Code size 171 (0xab) + .maxstack 4 + .locals init (string[0...,0...] V_0, + string[0...,0...] V_1) + IL_0000: nop + IL_0001: ldc.i4.4 + IL_0002: ldc.i4.4 + IL_0003: newobj instance void string[0...,0...]::.ctor(int32, + int32) + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: ldc.i4.0 + IL_000b: ldc.i4.0 + IL_000c: ldstr "test" + IL_0011: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0016: ldloc.1 + IL_0017: ldc.i4.0 + IL_0018: ldc.i4.1 + IL_0019: ldstr "hello" + IL_001e: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0023: ldloc.1 + IL_0024: ldc.i4.0 + IL_0025: ldc.i4.2 + IL_0026: ldstr "world" + IL_002b: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0030: ldloc.1 + IL_0031: ldc.i4.1 + IL_0032: ldc.i4.0 + IL_0033: ldstr "test" + IL_0038: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_003d: ldloc.1 + IL_003e: ldc.i4.1 + IL_003f: ldc.i4.1 + IL_0040: ldstr "hello" + IL_0045: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_004a: ldloc.1 + IL_004b: ldc.i4.1 + IL_004c: ldc.i4.3 + IL_004d: ldstr "world" + IL_0052: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0057: ldloc.1 + IL_0058: ldc.i4.2 + IL_0059: ldc.i4.0 + IL_005a: ldstr "test" + IL_005f: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0064: ldloc.1 + IL_0065: ldc.i4.2 + IL_0066: ldc.i4.2 + IL_0067: ldstr "hello" + IL_006c: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0071: ldloc.1 + IL_0072: ldc.i4.2 + IL_0073: ldc.i4.3 + IL_0074: ldstr "world" + IL_0079: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_007e: ldloc.1 + IL_007f: ldc.i4.3 + IL_0080: ldc.i4.1 + IL_0081: ldstr "test" + IL_0086: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_008b: ldloc.1 + IL_008c: ldc.i4.3 + IL_008d: ldc.i4.2 + IL_008e: ldstr "hello" + IL_0093: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0098: ldloc.1 + IL_0099: ldc.i4.3 + IL_009a: ldc.i4.3 + IL_009b: ldstr "world" + IL_00a0: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_00a5: ldloc.1 + IL_00a6: stloc.0 + IL_00a7: br.s IL_00a9 + + IL_00a9: ldloc.0 + IL_00aa: ret + } // end of method TestCases::Issue1382b + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C Test1() cil managed { @@ -3205,7 +3415,7 @@ IL_0001: ldc.i4.4 IL_0002: newarr [mscorlib]System.Byte IL_0007: dup - IL_0008: ldtoken field int32 ''::'$$method0x6000042-1' + IL_0008: ldtoken field int32 ''::'$$method0x6000044-1' IL_000d: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0012: stloc.0 @@ -4470,7 +4680,7 @@ IL_0787: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_078c: dup - IL_078d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=36' ''::'$$method0x6000091-1' + IL_078d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=36' ''::'$$method0x6000093-1' IL_0792: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0797: stsfld int32[0...,0...] ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Issue1336_rg2 @@ -4574,8 +4784,8 @@ .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001e-4' at I_000029A8 .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x600001f-1' at I_00002A58 .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x600001f-2' at I_00002AA0 - .field static assembly int32 '$$method0x6000042-1' at I_00003348 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=36' '$$method0x6000091-1' at I_00003630 + .field static assembly int32 '$$method0x6000044-1' at I_000034B8 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=36' '$$method0x6000093-1' at I_000037A0 } // end of class '' @@ -4683,10 +4893,10 @@ 1D 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 // ........ ...!... 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 // "...#...$...%... 26 00 00 00 27 00 00 00) // &...'... -.data cil I_00003348 = bytearray ( +.data cil I_000034B8 = bytearray ( 00 01 02 FF) -.data cil I_0000334C = int8[4] -.data cil I_00003630 = bytearray ( +.data cil I_000034BC = int8[4] +.data cil I_000037A0 = bytearray ( 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il index fc6d554eb..c21888c47 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il @@ -2170,6 +2170,204 @@ IL_001b: ret } // end of method TestCases::Issue1383 + .method private hidebysig instance string[0...,0...] + Issue1382a() cil managed + { + // Code size 166 (0xa6) + .maxstack 4 + .locals init (string[0...,0...] V_0) + IL_0000: ldc.i4.4 + IL_0001: ldc.i4.4 + IL_0002: newobj instance void string[0...,0...]::.ctor(int32, + int32) + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldc.i4.0 + IL_000a: ldc.i4.1 + IL_000b: ldstr "test" + IL_0010: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0015: ldloc.0 + IL_0016: ldc.i4.0 + IL_0017: ldc.i4.2 + IL_0018: ldstr "hello" + IL_001d: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0022: ldloc.0 + IL_0023: ldc.i4.0 + IL_0024: ldc.i4.3 + IL_0025: ldstr "world" + IL_002a: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_002f: ldloc.0 + IL_0030: ldc.i4.1 + IL_0031: ldc.i4.0 + IL_0032: ldstr "test" + IL_0037: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_003c: ldloc.0 + IL_003d: ldc.i4.1 + IL_003e: ldc.i4.2 + IL_003f: ldstr "hello" + IL_0044: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0049: ldloc.0 + IL_004a: ldc.i4.1 + IL_004b: ldc.i4.3 + IL_004c: ldstr "world" + IL_0051: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0056: ldloc.0 + IL_0057: ldc.i4.2 + IL_0058: ldc.i4.0 + IL_0059: ldstr "test" + IL_005e: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0063: ldloc.0 + IL_0064: ldc.i4.2 + IL_0065: ldc.i4.1 + IL_0066: ldstr "hello" + IL_006b: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0070: ldloc.0 + IL_0071: ldc.i4.2 + IL_0072: ldc.i4.3 + IL_0073: ldstr "world" + IL_0078: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_007d: ldloc.0 + IL_007e: ldc.i4.3 + IL_007f: ldc.i4.0 + IL_0080: ldstr "test" + IL_0085: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_008a: ldloc.0 + IL_008b: ldc.i4.3 + IL_008c: ldc.i4.1 + IL_008d: ldstr "hello" + IL_0092: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0097: ldloc.0 + IL_0098: ldc.i4.3 + IL_0099: ldc.i4.2 + IL_009a: ldstr "world" + IL_009f: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_00a4: ldloc.0 + IL_00a5: ret + } // end of method TestCases::Issue1382a + + .method private hidebysig instance string[0...,0...] + Issue1382b() cil managed + { + // Code size 166 (0xa6) + .maxstack 4 + .locals init (string[0...,0...] V_0) + IL_0000: ldc.i4.4 + IL_0001: ldc.i4.4 + IL_0002: newobj instance void string[0...,0...]::.ctor(int32, + int32) + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldc.i4.0 + IL_000a: ldc.i4.0 + IL_000b: ldstr "test" + IL_0010: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0015: ldloc.0 + IL_0016: ldc.i4.0 + IL_0017: ldc.i4.1 + IL_0018: ldstr "hello" + IL_001d: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0022: ldloc.0 + IL_0023: ldc.i4.0 + IL_0024: ldc.i4.2 + IL_0025: ldstr "world" + IL_002a: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_002f: ldloc.0 + IL_0030: ldc.i4.1 + IL_0031: ldc.i4.0 + IL_0032: ldstr "test" + IL_0037: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_003c: ldloc.0 + IL_003d: ldc.i4.1 + IL_003e: ldc.i4.1 + IL_003f: ldstr "hello" + IL_0044: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0049: ldloc.0 + IL_004a: ldc.i4.1 + IL_004b: ldc.i4.3 + IL_004c: ldstr "world" + IL_0051: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0056: ldloc.0 + IL_0057: ldc.i4.2 + IL_0058: ldc.i4.0 + IL_0059: ldstr "test" + IL_005e: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0063: ldloc.0 + IL_0064: ldc.i4.2 + IL_0065: ldc.i4.2 + IL_0066: ldstr "hello" + IL_006b: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0070: ldloc.0 + IL_0071: ldc.i4.2 + IL_0072: ldc.i4.3 + IL_0073: ldstr "world" + IL_0078: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_007d: ldloc.0 + IL_007e: ldc.i4.3 + IL_007f: ldc.i4.1 + IL_0080: ldstr "test" + IL_0085: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_008a: ldloc.0 + IL_008b: ldc.i4.3 + IL_008c: ldc.i4.2 + IL_008d: ldstr "hello" + IL_0092: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0097: ldloc.0 + IL_0098: ldc.i4.3 + IL_0099: ldc.i4.3 + IL_009a: ldstr "world" + IL_009f: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_00a4: ldloc.0 + IL_00a5: ret + } // end of method TestCases::Issue1382b + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C Test1() cil managed { @@ -2809,7 +3007,7 @@ IL_0000: ldc.i4.4 IL_0001: newarr [mscorlib]System.Byte IL_0006: dup - IL_0007: ldtoken field int32 ''::'$$method0x6000042-1' + IL_0007: ldtoken field int32 ''::'$$method0x6000044-1' IL_000c: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0011: ret @@ -4020,7 +4218,7 @@ IL_07df: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_07e4: dup - IL_07e5: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=36' ''::'$$method0x6000091-1' + IL_07e5: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=36' ''::'$$method0x6000093-1' IL_07ea: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_07ef: stsfld int32[0...,0...] ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Issue1336_rg2 @@ -4124,8 +4322,8 @@ .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001e-4' at I_00002938 .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x600001f-1' at I_000029E8 .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x600001f-2' at I_00002A30 - .field static assembly int32 '$$method0x6000042-1' at I_00003220 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=36' '$$method0x6000091-1' at I_000034C0 + .field static assembly int32 '$$method0x6000044-1' at I_00003388 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=36' '$$method0x6000093-1' at I_00003628 } // end of class '' @@ -4231,11 +4429,10 @@ 1D 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 // ........ ...!... 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 // "...#...$...%... 26 00 00 00 27 00 00 00) // &...'... -.data cil I_00002A78 = int8[8] -.data cil I_00003220 = bytearray ( +.data cil I_00003388 = bytearray ( 00 01 02 FF) -.data cil I_00003224 = int8[28] -.data cil I_000034C0 = bytearray ( +.data cil I_0000338C = int8[4] +.data cil I_00003628 = bytearray ( 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il index b9bef1887..30cfc0695 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il @@ -1188,8 +1188,8 @@ { .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .field public static initonly class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' '<>9' - .field public static class [mscorlib]System.EventHandler '<>9__63_0' - .field public static class [mscorlib]System.Func`2 '<>9__77_0' + .field public static class [mscorlib]System.EventHandler '<>9__65_0' + .field public static class [mscorlib]System.Func`2 '<>9__79_0' .method private hidebysig specialname rtspecialname static void .cctor() cil managed { @@ -1211,17 +1211,17 @@ } // end of method '<>c'::.ctor .method assembly hidebysig instance void - 'b__63_0'(object '', + 'b__65_0'(object '', class [mscorlib]System.EventArgs '') cil managed { // Code size 6 (0x6) .maxstack 8 IL_0000: call void [mscorlib]System.Console::WriteLine() IL_0005: ret - } // end of method '<>c'::'b__63_0' + } // end of method '<>c'::'b__65_0' .method assembly hidebysig instance bool - 'b__77_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed + 'b__79_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed { // Code size 17 (0x11) .maxstack 8 @@ -1231,7 +1231,7 @@ IL_000b: call bool [mscorlib]System.String::op_Equality(string, string) IL_0010: ret - } // end of method '<>c'::'b__77_0' + } // end of method '<>c'::'b__79_0' } // end of class '<>c' @@ -2157,6 +2157,198 @@ IL_001b: ret } // end of method TestCases::Issue1383 + .method private hidebysig instance string[0...,0...] + Issue1382a() cil managed + { + // Code size 164 (0xa4) + .maxstack 5 + IL_0000: ldc.i4.4 + IL_0001: ldc.i4.4 + IL_0002: newobj instance void string[0...,0...]::.ctor(int32, + int32) + IL_0007: dup + IL_0008: ldc.i4.0 + IL_0009: ldc.i4.1 + IL_000a: ldstr "test" + IL_000f: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0014: dup + IL_0015: ldc.i4.0 + IL_0016: ldc.i4.2 + IL_0017: ldstr "hello" + IL_001c: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0021: dup + IL_0022: ldc.i4.0 + IL_0023: ldc.i4.3 + IL_0024: ldstr "world" + IL_0029: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_002e: dup + IL_002f: ldc.i4.1 + IL_0030: ldc.i4.0 + IL_0031: ldstr "test" + IL_0036: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_003b: dup + IL_003c: ldc.i4.1 + IL_003d: ldc.i4.2 + IL_003e: ldstr "hello" + IL_0043: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0048: dup + IL_0049: ldc.i4.1 + IL_004a: ldc.i4.3 + IL_004b: ldstr "world" + IL_0050: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0055: dup + IL_0056: ldc.i4.2 + IL_0057: ldc.i4.0 + IL_0058: ldstr "test" + IL_005d: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0062: dup + IL_0063: ldc.i4.2 + IL_0064: ldc.i4.1 + IL_0065: ldstr "hello" + IL_006a: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_006f: dup + IL_0070: ldc.i4.2 + IL_0071: ldc.i4.3 + IL_0072: ldstr "world" + IL_0077: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_007c: dup + IL_007d: ldc.i4.3 + IL_007e: ldc.i4.0 + IL_007f: ldstr "test" + IL_0084: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0089: dup + IL_008a: ldc.i4.3 + IL_008b: ldc.i4.1 + IL_008c: ldstr "hello" + IL_0091: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0096: dup + IL_0097: ldc.i4.3 + IL_0098: ldc.i4.2 + IL_0099: ldstr "world" + IL_009e: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_00a3: ret + } // end of method TestCases::Issue1382a + + .method private hidebysig instance string[0...,0...] + Issue1382b() cil managed + { + // Code size 164 (0xa4) + .maxstack 5 + IL_0000: ldc.i4.4 + IL_0001: ldc.i4.4 + IL_0002: newobj instance void string[0...,0...]::.ctor(int32, + int32) + IL_0007: dup + IL_0008: ldc.i4.0 + IL_0009: ldc.i4.0 + IL_000a: ldstr "test" + IL_000f: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0014: dup + IL_0015: ldc.i4.0 + IL_0016: ldc.i4.1 + IL_0017: ldstr "hello" + IL_001c: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0021: dup + IL_0022: ldc.i4.0 + IL_0023: ldc.i4.2 + IL_0024: ldstr "world" + IL_0029: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_002e: dup + IL_002f: ldc.i4.1 + IL_0030: ldc.i4.0 + IL_0031: ldstr "test" + IL_0036: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_003b: dup + IL_003c: ldc.i4.1 + IL_003d: ldc.i4.1 + IL_003e: ldstr "hello" + IL_0043: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0048: dup + IL_0049: ldc.i4.1 + IL_004a: ldc.i4.3 + IL_004b: ldstr "world" + IL_0050: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0055: dup + IL_0056: ldc.i4.2 + IL_0057: ldc.i4.0 + IL_0058: ldstr "test" + IL_005d: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0062: dup + IL_0063: ldc.i4.2 + IL_0064: ldc.i4.2 + IL_0065: ldstr "hello" + IL_006a: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_006f: dup + IL_0070: ldc.i4.2 + IL_0071: ldc.i4.3 + IL_0072: ldstr "world" + IL_0077: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_007c: dup + IL_007d: ldc.i4.3 + IL_007e: ldc.i4.1 + IL_007f: ldstr "test" + IL_0084: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0089: dup + IL_008a: ldc.i4.3 + IL_008b: ldc.i4.2 + IL_008c: ldstr "hello" + IL_0091: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0096: dup + IL_0097: ldc.i4.3 + IL_0098: ldc.i4.3 + IL_0099: ldstr "world" + IL_009e: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_00a3: ret + } // end of method TestCases::Issue1382b + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C Test1() cil managed { @@ -2303,18 +2495,18 @@ IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::.ctor() IL_0005: stloc.0 IL_0006: ldloc.0 - IL_0007: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__63_0' + IL_0007: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__65_0' IL_000c: dup IL_000d: brtrue.s IL_0026 IL_000f: pop IL_0010: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9' - IL_0015: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__63_0'(object, + IL_0015: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__65_0'(object, class [mscorlib]System.EventArgs) IL_001b: newobj instance void [mscorlib]System.EventHandler::.ctor(object, native int) IL_0020: dup - IL_0021: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__63_0' + IL_0021: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__65_0' IL_0026: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::add_TestEvent(class [mscorlib]System.EventHandler) IL_002b: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y() IL_0030: ldloc.0 @@ -2651,17 +2843,17 @@ IL_0033: callvirt instance void [mscorlib]System.Globalization.CultureInfo::set_DateTimeFormat(class [mscorlib]System.Globalization.DateTimeFormatInfo) IL_0038: dup IL_0039: ldloc.0 - IL_003a: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__77_0' + IL_003a: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__79_0' IL_003f: dup IL_0040: brtrue.s IL_0059 IL_0042: pop IL_0043: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9' - IL_0048: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__77_0'(class [mscorlib]System.Globalization.NumberFormatInfo) + IL_0048: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__79_0'(class [mscorlib]System.Globalization.NumberFormatInfo) IL_004e: newobj instance void class [mscorlib]System.Func`2::.ctor(object, native int) IL_0053: dup - IL_0054: stsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__77_0' + IL_0054: stsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__79_0' IL_0059: call class [mscorlib]System.Collections.Generic.IEnumerable`1 [System.Core]System.Linq.Enumerable::Where(class [mscorlib]System.Collections.Generic.IEnumerable`1, class [mscorlib]System.Func`2) IL_005e: call !!0 [System.Core]System.Linq.Enumerable::First(class [mscorlib]System.Collections.Generic.IEnumerable`1) @@ -4075,67 +4267,68 @@ .size 256 } // end of class '__StaticArrayInitTypeSize=256' - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '1535117EC92E41D4A6B7CA00F965357B05B5DC35' at I_00006C8C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '20E3FF489634E18F3F7EB292AD504DBAE9519293' at I_00006CD4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '39E94835525CF7B71CD4595742EF462642FBF1B2' at I_00006CE4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '56D9EEC8EF899644C40B9BE9D886DF2367A5D078' at I_00006D2C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '735E5A21849E86F68D220F06163E8C5C6376B9C9' at I_00006D3C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' '7C39B7B06DD624A17F875AB8E9651554BE6E74D2' at I_00006D4C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' '8D903ECAD8D9D75B3183B23AF79F6D2E607369E3' at I_00006D8C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=80' '9B1F6E56D755443CC39C1969CE38FD41FD4EF4B7' at I_00006DB4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=256' A1EA7DC3FE43B3A54F5B729A92B92AF54181A3EB at I_00006E04 - .field static assembly initonly int64 A6296CAC471BE2954899600137940479D8073C7C at I_00006F04 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=36' B62E59D20E3D69F06A6D9BD5E3C518FF7093EDAB at I_00006F0C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' B9583930B842DBCEF0D7B8E57D4D3F1E8055C39E at I_00006F34 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' C4E70AB31EF6C8908F896CAD1C6BC75F7FA65E27 at I_00006F5C - .field static assembly initonly int32 C62C27924F4C967F5EDDB1850C091D54C7A2AB58 at I_00006F74 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=48' DC7043B0114737ACE19A23DD755893795FD48A23 at I_00006F7C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' DCF557B883E6FE0AEC05B7F0290F0EF47D0AC2E3 at I_00006FAC - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_00006FEC - .field static assembly initonly int64 EB0715DBB235F3F696F2C404F5839C6650640898 at I_00007014 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' F514FF55B79BCAA2CEC9B56C062D976E45F89AB7 at I_0000701C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' FBCB49C1A244C1B5781AA1DB02C5A11F68908526 at I_00007044 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '1535117EC92E41D4A6B7CA00F965357B05B5DC35' at I_00006E70 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '20E3FF489634E18F3F7EB292AD504DBAE9519293' at I_00006EB8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '39E94835525CF7B71CD4595742EF462642FBF1B2' at I_00006EC8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '56D9EEC8EF899644C40B9BE9D886DF2367A5D078' at I_00006F10 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '735E5A21849E86F68D220F06163E8C5C6376B9C9' at I_00006F20 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' '7C39B7B06DD624A17F875AB8E9651554BE6E74D2' at I_00006F30 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' '8D903ECAD8D9D75B3183B23AF79F6D2E607369E3' at I_00006F70 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=80' '9B1F6E56D755443CC39C1969CE38FD41FD4EF4B7' at I_00006F98 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=256' A1EA7DC3FE43B3A54F5B729A92B92AF54181A3EB at I_00006FE8 + .field static assembly initonly int64 A6296CAC471BE2954899600137940479D8073C7C at I_000070E8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=36' B62E59D20E3D69F06A6D9BD5E3C518FF7093EDAB at I_000070F0 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' B9583930B842DBCEF0D7B8E57D4D3F1E8055C39E at I_00007118 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' C4E70AB31EF6C8908F896CAD1C6BC75F7FA65E27 at I_00007140 + .field static assembly initonly int32 C62C27924F4C967F5EDDB1850C091D54C7A2AB58 at I_00007158 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=48' DC7043B0114737ACE19A23DD755893795FD48A23 at I_00007160 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' DCF557B883E6FE0AEC05B7F0290F0EF47D0AC2E3 at I_00007190 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_000071D0 + .field static assembly initonly int64 EB0715DBB235F3F696F2C404F5839C6650640898 at I_000071F8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' F514FF55B79BCAA2CEC9B56C062D976E45F89AB7 at I_00007200 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' FBCB49C1A244C1B5781AA1DB02C5A11F68908526 at I_00007228 } // end of class '' // ============================================================= -.data cil I_00006C8C = bytearray ( +.data cil I_00006E70 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00) -.data cil I_00006CD4 = bytearray ( +.data cil I_00006EB8 = bytearray ( 01 02 03 04 05 06 07 08 FE FF) -.data cil I_00006CDE = int8[2] -.data cil I_00006CE4 = bytearray ( +.data cil I_00006EC2 = int8[6] +.data cil I_00006EC8 = bytearray ( 15 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 // ........ ...!... 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 // "...#...$...%... 26 00 00 00 27 00 00 00) // &...'... -.data cil I_00006D2C = bytearray ( +.data cil I_00006F10 = bytearray ( 00 80 FF FF 00 00 01 00 FF 7F) -.data cil I_00006D36 = int8[2] -.data cil I_00006D3C = bytearray ( +.data cil I_00006F1A = int8[6] +.data cil I_00006F20 = bytearray ( 00 00 01 00 FF 7F 00 80 FE FF FF FF) -.data cil I_00006D4C = bytearray ( +.data cil I_00006F2C = int8[4] +.data cil I_00006F30 = bytearray ( 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_00006D8C = bytearray ( +.data cil I_00006F70 = bytearray ( 01 00 0C BB 7D 6E 9C BA FF FF FF FF FF FF FF FF // ....}n.......... 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45) // ...D..cE -.data cil I_00006DB4 = bytearray ( +.data cil I_00006F98 = bytearray ( 01 00 00 00 00 00 00 00 00 94 35 77 00 00 00 00 // ..........5w.... 00 5E D0 B2 00 00 00 00 04 00 00 00 00 00 00 00 // .^.............. 05 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45 FF FF E7 89 04 23 C7 8A) // ...D..cE.....#.. -.data cil I_00006E04 = bytearray ( +.data cil I_00006FE8 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -4152,41 +4345,43 @@ 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_00006F04 = bytearray ( +.data cil I_000070E8 = bytearray ( 80 81 00 01 02 03 04 7F) -.data cil I_00006F0C = bytearray ( +.data cil I_000070F0 = bytearray ( 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00) -.data cil I_00006F34 = bytearray ( +.data cil I_00007114 = int8[4] +.data cil I_00007118 = bytearray ( 01 00 00 00 00 94 35 77 00 5E D0 B2 04 00 00 00 // ......5w.^...... 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00006F5C = bytearray ( +.data cil I_00007140 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00) -.data cil I_00006F74 = bytearray ( +.data cil I_00007158 = bytearray ( 00 01 02 FF) -.data cil I_00006F7C = bytearray ( +.data cil I_0000715C = int8[4] +.data cil I_00007160 = bytearray ( 00 00 00 00 00 00 F8 BF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F8 3F 00 00 00 00 00 00 F0 FF // .......?........ 00 00 00 00 00 00 F0 7F 00 00 00 00 00 00 F8 FF) -.data cil I_00006FAC = bytearray ( +.data cil I_00007190 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00) -.data cil I_00006FEC = bytearray ( +.data cil I_000071D0 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00007014 = bytearray ( +.data cil I_000071F8 = bytearray ( 01 00 01 00 00 00 01 01) -.data cil I_0000701C = bytearray ( +.data cil I_00007200 = bytearray ( 01 00 00 00 FE FF FF FF 00 94 35 77 04 00 00 00 // ..........5w.... 05 00 00 00 FA FF FF FF 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00007044 = bytearray ( +.data cil I_00007228 = bytearray ( 00 00 C0 BF 00 00 00 00 00 00 C0 3F 00 00 80 FF // ...........?.... 00 00 80 7F 00 00 C0 FF) // *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il index 3722f6371..13041bd81 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il @@ -1257,8 +1257,8 @@ { .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .field public static initonly class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' '<>9' - .field public static class [mscorlib]System.EventHandler '<>9__63_0' - .field public static class [mscorlib]System.Func`2 '<>9__77_0' + .field public static class [mscorlib]System.EventHandler '<>9__65_0' + .field public static class [mscorlib]System.Func`2 '<>9__79_0' .method private hidebysig specialname rtspecialname static void .cctor() cil managed { @@ -1281,7 +1281,7 @@ } // end of method '<>c'::.ctor .method assembly hidebysig instance void - 'b__63_0'(object '', + 'b__65_0'(object '', class [mscorlib]System.EventArgs '') cil managed { // Code size 8 (0x8) @@ -1290,10 +1290,10 @@ IL_0001: call void [mscorlib]System.Console::WriteLine() IL_0006: nop IL_0007: ret - } // end of method '<>c'::'b__63_0' + } // end of method '<>c'::'b__65_0' .method assembly hidebysig instance bool - 'b__77_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed + 'b__79_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed { // Code size 17 (0x11) .maxstack 8 @@ -1303,7 +1303,7 @@ IL_000b: call bool [mscorlib]System.String::op_Equality(string, string) IL_0010: ret - } // end of method '<>c'::'b__77_0' + } // end of method '<>c'::'b__79_0' } // end of class '<>c' @@ -2340,6 +2340,210 @@ IL_0020: ret } // end of method TestCases::Issue1383 + .method private hidebysig instance string[0...,0...] + Issue1382a() cil managed + { + // Code size 169 (0xa9) + .maxstack 5 + .locals init (string[0...,0...] V_0) + IL_0000: nop + IL_0001: ldc.i4.4 + IL_0002: ldc.i4.4 + IL_0003: newobj instance void string[0...,0...]::.ctor(int32, + int32) + IL_0008: dup + IL_0009: ldc.i4.0 + IL_000a: ldc.i4.1 + IL_000b: ldstr "test" + IL_0010: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0015: dup + IL_0016: ldc.i4.0 + IL_0017: ldc.i4.2 + IL_0018: ldstr "hello" + IL_001d: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0022: dup + IL_0023: ldc.i4.0 + IL_0024: ldc.i4.3 + IL_0025: ldstr "world" + IL_002a: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_002f: dup + IL_0030: ldc.i4.1 + IL_0031: ldc.i4.0 + IL_0032: ldstr "test" + IL_0037: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_003c: dup + IL_003d: ldc.i4.1 + IL_003e: ldc.i4.2 + IL_003f: ldstr "hello" + IL_0044: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0049: dup + IL_004a: ldc.i4.1 + IL_004b: ldc.i4.3 + IL_004c: ldstr "world" + IL_0051: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0056: dup + IL_0057: ldc.i4.2 + IL_0058: ldc.i4.0 + IL_0059: ldstr "test" + IL_005e: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0063: dup + IL_0064: ldc.i4.2 + IL_0065: ldc.i4.1 + IL_0066: ldstr "hello" + IL_006b: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0070: dup + IL_0071: ldc.i4.2 + IL_0072: ldc.i4.3 + IL_0073: ldstr "world" + IL_0078: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_007d: dup + IL_007e: ldc.i4.3 + IL_007f: ldc.i4.0 + IL_0080: ldstr "test" + IL_0085: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_008a: dup + IL_008b: ldc.i4.3 + IL_008c: ldc.i4.1 + IL_008d: ldstr "hello" + IL_0092: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0097: dup + IL_0098: ldc.i4.3 + IL_0099: ldc.i4.2 + IL_009a: ldstr "world" + IL_009f: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_00a4: stloc.0 + IL_00a5: br.s IL_00a7 + + IL_00a7: ldloc.0 + IL_00a8: ret + } // end of method TestCases::Issue1382a + + .method private hidebysig instance string[0...,0...] + Issue1382b() cil managed + { + // Code size 169 (0xa9) + .maxstack 5 + .locals init (string[0...,0...] V_0) + IL_0000: nop + IL_0001: ldc.i4.4 + IL_0002: ldc.i4.4 + IL_0003: newobj instance void string[0...,0...]::.ctor(int32, + int32) + IL_0008: dup + IL_0009: ldc.i4.0 + IL_000a: ldc.i4.0 + IL_000b: ldstr "test" + IL_0010: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0015: dup + IL_0016: ldc.i4.0 + IL_0017: ldc.i4.1 + IL_0018: ldstr "hello" + IL_001d: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0022: dup + IL_0023: ldc.i4.0 + IL_0024: ldc.i4.2 + IL_0025: ldstr "world" + IL_002a: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_002f: dup + IL_0030: ldc.i4.1 + IL_0031: ldc.i4.0 + IL_0032: ldstr "test" + IL_0037: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_003c: dup + IL_003d: ldc.i4.1 + IL_003e: ldc.i4.1 + IL_003f: ldstr "hello" + IL_0044: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0049: dup + IL_004a: ldc.i4.1 + IL_004b: ldc.i4.3 + IL_004c: ldstr "world" + IL_0051: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0056: dup + IL_0057: ldc.i4.2 + IL_0058: ldc.i4.0 + IL_0059: ldstr "test" + IL_005e: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0063: dup + IL_0064: ldc.i4.2 + IL_0065: ldc.i4.2 + IL_0066: ldstr "hello" + IL_006b: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0070: dup + IL_0071: ldc.i4.2 + IL_0072: ldc.i4.3 + IL_0073: ldstr "world" + IL_0078: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_007d: dup + IL_007e: ldc.i4.3 + IL_007f: ldc.i4.1 + IL_0080: ldstr "test" + IL_0085: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_008a: dup + IL_008b: ldc.i4.3 + IL_008c: ldc.i4.2 + IL_008d: ldstr "hello" + IL_0092: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_0097: dup + IL_0098: ldc.i4.3 + IL_0099: ldc.i4.3 + IL_009a: ldstr "world" + IL_009f: call instance void string[0...,0...]::Set(int32, + int32, + string) + IL_00a4: stloc.0 + IL_00a5: br.s IL_00a7 + + IL_00a7: ldloc.0 + IL_00a8: ret + } // end of method TestCases::Issue1382b + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/C Test1() cil managed { @@ -2543,18 +2747,18 @@ IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::.ctor() IL_0006: stloc.0 IL_0007: ldloc.0 - IL_0008: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__63_0' + IL_0008: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__65_0' IL_000d: dup IL_000e: brtrue.s IL_0027 IL_0010: pop IL_0011: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9' - IL_0016: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__63_0'(object, + IL_0016: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__65_0'(object, class [mscorlib]System.EventArgs) IL_001c: newobj instance void [mscorlib]System.EventHandler::.ctor(object, native int) IL_0021: dup - IL_0022: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__63_0' + IL_0022: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__65_0' IL_0027: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/Data::add_TestEvent(class [mscorlib]System.EventHandler) IL_002c: nop IL_002d: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y() @@ -2954,17 +3158,17 @@ IL_003b: nop IL_003c: dup IL_003d: ldloc.0 - IL_003e: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__77_0' + IL_003e: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__79_0' IL_0043: dup IL_0044: brtrue.s IL_005d IL_0046: pop IL_0047: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9' - IL_004c: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__77_0'(class [mscorlib]System.Globalization.NumberFormatInfo) + IL_004c: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'b__79_0'(class [mscorlib]System.Globalization.NumberFormatInfo) IL_0052: newobj instance void class [mscorlib]System.Func`2::.ctor(object, native int) IL_0057: dup - IL_0058: stsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__77_0' + IL_0058: stsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/'<>c'::'<>9__79_0' IL_005d: call class [mscorlib]System.Collections.Generic.IEnumerable`1 [System.Core]System.Linq.Enumerable::Where(class [mscorlib]System.Collections.Generic.IEnumerable`1, class [mscorlib]System.Func`2) IL_0062: call !!0 [System.Core]System.Linq.Enumerable::First(class [mscorlib]System.Collections.Generic.IEnumerable`1) @@ -4521,68 +4725,67 @@ .size 256 } // end of class '__StaticArrayInitTypeSize=256' - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '1535117EC92E41D4A6B7CA00F965357B05B5DC35' at I_000070A0 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '20E3FF489634E18F3F7EB292AD504DBAE9519293' at I_000070E8 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '39E94835525CF7B71CD4595742EF462642FBF1B2' at I_000070F8 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '56D9EEC8EF899644C40B9BE9D886DF2367A5D078' at I_00007140 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '735E5A21849E86F68D220F06163E8C5C6376B9C9' at I_00007150 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' '7C39B7B06DD624A17F875AB8E9651554BE6E74D2' at I_00007160 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' '8D903ECAD8D9D75B3183B23AF79F6D2E607369E3' at I_000071A0 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=80' '9B1F6E56D755443CC39C1969CE38FD41FD4EF4B7' at I_000071C8 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=256' A1EA7DC3FE43B3A54F5B729A92B92AF54181A3EB at I_00007218 - .field static assembly initonly int64 A6296CAC471BE2954899600137940479D8073C7C at I_00007318 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=36' B62E59D20E3D69F06A6D9BD5E3C518FF7093EDAB at I_00007320 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' B9583930B842DBCEF0D7B8E57D4D3F1E8055C39E at I_00007348 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' C4E70AB31EF6C8908F896CAD1C6BC75F7FA65E27 at I_00007370 - .field static assembly initonly int32 C62C27924F4C967F5EDDB1850C091D54C7A2AB58 at I_00007388 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=48' DC7043B0114737ACE19A23DD755893795FD48A23 at I_00007390 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' DCF557B883E6FE0AEC05B7F0290F0EF47D0AC2E3 at I_000073C0 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_00007400 - .field static assembly initonly int64 EB0715DBB235F3F696F2C404F5839C6650640898 at I_00007428 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' F514FF55B79BCAA2CEC9B56C062D976E45F89AB7 at I_00007430 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' FBCB49C1A244C1B5781AA1DB02C5A11F68908526 at I_00007458 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '1535117EC92E41D4A6B7CA00F965357B05B5DC35' at I_0000729C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '20E3FF489634E18F3F7EB292AD504DBAE9519293' at I_000072E4 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '39E94835525CF7B71CD4595742EF462642FBF1B2' at I_000072F4 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '56D9EEC8EF899644C40B9BE9D886DF2367A5D078' at I_0000733C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '735E5A21849E86F68D220F06163E8C5C6376B9C9' at I_0000734C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' '7C39B7B06DD624A17F875AB8E9651554BE6E74D2' at I_0000735C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' '8D903ECAD8D9D75B3183B23AF79F6D2E607369E3' at I_0000739C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=80' '9B1F6E56D755443CC39C1969CE38FD41FD4EF4B7' at I_000073C4 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=256' A1EA7DC3FE43B3A54F5B729A92B92AF54181A3EB at I_00007414 + .field static assembly initonly int64 A6296CAC471BE2954899600137940479D8073C7C at I_00007514 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=36' B62E59D20E3D69F06A6D9BD5E3C518FF7093EDAB at I_0000751C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' B9583930B842DBCEF0D7B8E57D4D3F1E8055C39E at I_00007544 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' C4E70AB31EF6C8908F896CAD1C6BC75F7FA65E27 at I_0000756C + .field static assembly initonly int32 C62C27924F4C967F5EDDB1850C091D54C7A2AB58 at I_00007584 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=48' DC7043B0114737ACE19A23DD755893795FD48A23 at I_0000758C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' DCF557B883E6FE0AEC05B7F0290F0EF47D0AC2E3 at I_000075BC + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_000075FC + .field static assembly initonly int64 EB0715DBB235F3F696F2C404F5839C6650640898 at I_00007624 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' F514FF55B79BCAA2CEC9B56C062D976E45F89AB7 at I_0000762C + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' FBCB49C1A244C1B5781AA1DB02C5A11F68908526 at I_00007654 } // end of class '' // ============================================================= -.data cil I_000070A0 = bytearray ( +.data cil I_0000729C = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00) -.data cil I_000070E8 = bytearray ( +.data cil I_000072E4 = bytearray ( 01 02 03 04 05 06 07 08 FE FF) -.data cil I_000070F2 = int8[6] -.data cil I_000070F8 = bytearray ( +.data cil I_000072EE = int8[2] +.data cil I_000072F4 = bytearray ( 15 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 // ........ ...!... 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 // "...#...$...%... 26 00 00 00 27 00 00 00) // &...'... -.data cil I_00007140 = bytearray ( +.data cil I_0000733C = bytearray ( 00 80 FF FF 00 00 01 00 FF 7F) -.data cil I_0000714A = int8[6] -.data cil I_00007150 = bytearray ( +.data cil I_00007346 = int8[2] +.data cil I_0000734C = bytearray ( 00 00 01 00 FF 7F 00 80 FE FF FF FF) -.data cil I_0000715C = int8[4] -.data cil I_00007160 = bytearray ( +.data cil I_0000735C = bytearray ( 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_000071A0 = bytearray ( +.data cil I_0000739C = bytearray ( 01 00 0C BB 7D 6E 9C BA FF FF FF FF FF FF FF FF // ....}n.......... 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45) // ...D..cE -.data cil I_000071C8 = bytearray ( +.data cil I_000073C4 = bytearray ( 01 00 00 00 00 00 00 00 00 94 35 77 00 00 00 00 // ..........5w.... 00 5E D0 B2 00 00 00 00 04 00 00 00 00 00 00 00 // .^.............. 05 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45 FF FF E7 89 04 23 C7 8A) // ...D..cE.....#.. -.data cil I_00007218 = bytearray ( +.data cil I_00007414 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -4599,43 +4802,41 @@ 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_00007318 = bytearray ( +.data cil I_00007514 = bytearray ( 80 81 00 01 02 03 04 7F) -.data cil I_00007320 = bytearray ( +.data cil I_0000751C = bytearray ( 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00) -.data cil I_00007344 = int8[4] -.data cil I_00007348 = bytearray ( +.data cil I_00007544 = bytearray ( 01 00 00 00 00 94 35 77 00 5E D0 B2 04 00 00 00 // ......5w.^...... 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00007370 = bytearray ( +.data cil I_0000756C = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00) -.data cil I_00007388 = bytearray ( +.data cil I_00007584 = bytearray ( 00 01 02 FF) -.data cil I_0000738C = int8[4] -.data cil I_00007390 = bytearray ( +.data cil I_0000758C = bytearray ( 00 00 00 00 00 00 F8 BF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F8 3F 00 00 00 00 00 00 F0 FF // .......?........ 00 00 00 00 00 00 F0 7F 00 00 00 00 00 00 F8 FF) -.data cil I_000073C0 = bytearray ( +.data cil I_000075BC = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00) -.data cil I_00007400 = bytearray ( +.data cil I_000075FC = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00007428 = bytearray ( +.data cil I_00007624 = bytearray ( 01 00 01 00 00 00 01 01) -.data cil I_00007430 = bytearray ( +.data cil I_0000762C = bytearray ( 01 00 00 00 FE FF FF FF 00 94 35 77 04 00 00 00 // ..........5w.... 05 00 00 00 FA FF FF FF 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00007458 = bytearray ( +.data cil I_00007654 = bytearray ( 00 00 C0 BF 00 00 00 00 00 00 C0 3F 00 00 80 FF // ...........?.... 00 00 80 7F 00 00 C0 FF) // *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs b/ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs index e808bc333..9f9e3caf6 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs @@ -315,6 +315,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms nextIndices[k] = new LdcI4(nextMinimumIndex[k]); } } else { + bool previousComponentWasGreater = false; for (int k = 0; k < indices.Count; k++) { if (!indices[k].MatchLdcI4(out int index)) return null; @@ -322,11 +323,15 @@ namespace ICSharpCode.Decompiler.IL.Transforms // to avoid running out of bounds or accidentally reordering instructions or overwriting previous instructions. // However, leaving array slots empty is allowed, as those are filled with default values when the // initializer block is generated. - if (index < 0 || index >= arrayLength[k] || index < nextMinimumIndex[k]) + if (index < 0 || index >= arrayLength[k] || (!previousComponentWasGreater && index < nextMinimumIndex[k])) return null; nextIndices[k] = new LdcI4(nextMinimumIndex[k]); if (index != nextMinimumIndex[k]) { exactMatch = false; + // this flag allows us to check whether the whole set of indices is smaller: + // [3, 3] should be smaller than [4, 0] even though 3 > 0. + if (index > nextMinimumIndex[k]) + previousComponentWasGreater = true; } } } From 17d19cd04a9f6c8419772dcd88dce8d01f17e2d6 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 7 Jan 2019 18:00:22 +0100 Subject: [PATCH 06/26] Fix #1379: Missing ILRange from yield return FSM. --- ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs b/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs index 241126458..1136574b2 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs @@ -649,7 +649,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow private BlockContainer ConvertBody(BlockContainer oldBody, StateRangeAnalysis rangeAnalysis) { var blockStateMap = rangeAnalysis.GetBlockStateSetMapping(oldBody); - BlockContainer newBody = new BlockContainer(); + BlockContainer newBody = new BlockContainer() { ILRange = oldBody.ILRange }; // create all new blocks so that they can be referenced by gotos for (int blockIndex = 0; blockIndex < oldBody.Blocks.Count; blockIndex++) { newBody.Blocks.Add(new Block { ILRange = oldBody.Blocks[blockIndex].ILRange }); From 98261c775f4e10fe1f241e43e585c6fdb7ae6441 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 8 Jan 2019 12:49:23 +0100 Subject: [PATCH 07/26] Fix #1387: Allow to search for names that contain spaces: simply wrap the whole name in double-quotes. Supports escaping of " and \. --- ILSpy/NativeMethods.cs | 97 +++++++++++++++++++++++++++++++++++++- ILSpy/Search/SearchPane.cs | 2 +- 2 files changed, 97 insertions(+), 2 deletions(-) diff --git a/ILSpy/NativeMethods.cs b/ILSpy/NativeMethods.cs index 1513d66ae..9487743d6 100644 --- a/ILSpy/NativeMethods.cs +++ b/ILSpy/NativeMethods.cs @@ -19,6 +19,7 @@ using System; using System.Text; using System.Runtime.InteropServices; +using System.ComponentModel; namespace ICSharpCode.ILSpy { @@ -50,8 +51,102 @@ namespace ICSharpCode.ILSpy [DllImport("user32.dll", CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool SetForegroundWindow(IntPtr hWnd); + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")] + [DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + static extern unsafe char** CommandLineToArgvW([MarshalAs(UnmanagedType.LPWStr)] string lpCmdLine, out int pNumArgs); + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")] + [DllImport("kernel32.dll")] + static extern IntPtr LocalFree(IntPtr hMem); + + #region CommandLine <-> Argument Array + /// + /// Decodes a command line into an array of arguments according to the CommandLineToArgvW rules. + /// + /// + /// Command line parsing rules: + /// - 2n backslashes followed by a quotation mark produce n backslashes, and the quotation mark is considered to be the end of the argument. + /// - (2n) + 1 backslashes followed by a quotation mark again produce n backslashes followed by a quotation mark. + /// - n backslashes not followed by a quotation mark simply produce n backslashes. + /// + public static unsafe string[] CommandLineToArgumentArray(string commandLine) + { + if (string.IsNullOrEmpty(commandLine)) + return new string[0]; + int numberOfArgs; + char** arr = CommandLineToArgvW(commandLine, out numberOfArgs); + if (arr == null) + throw new Win32Exception(); + try { + string[] result = new string[numberOfArgs]; + for (int i = 0; i < numberOfArgs; i++) { + result[i] = new string(arr[i]); + } + return result; + } finally { + // Free memory obtained by CommandLineToArgW. + LocalFree(new IntPtr(arr)); + } + } + + static readonly char[] charsNeedingQuoting = { ' ', '\t', '\n', '\v', '"' }; + + /// + /// Escapes a set of arguments according to the CommandLineToArgvW rules. + /// + /// + /// Command line parsing rules: + /// - 2n backslashes followed by a quotation mark produce n backslashes, and the quotation mark is considered to be the end of the argument. + /// - (2n) + 1 backslashes followed by a quotation mark again produce n backslashes followed by a quotation mark. + /// - n backslashes not followed by a quotation mark simply produce n backslashes. + /// + public static string ArgumentArrayToCommandLine(params string[] arguments) + { + if (arguments == null) + return null; + StringBuilder b = new StringBuilder(); + for (int i = 0; i < arguments.Length; i++) { + if (i > 0) + b.Append(' '); + AppendArgument(b, arguments[i]); + } + return b.ToString(); + } + + static void AppendArgument(StringBuilder b, string arg) + { + if (arg == null) { + return; + } + + if (arg.Length > 0 && arg.IndexOfAny(charsNeedingQuoting) < 0) { + b.Append(arg); + } else { + b.Append('"'); + for (int j = 0; ; j++) { + int backslashCount = 0; + while (j < arg.Length && arg[j] == '\\') { + backslashCount++; + j++; + } + if (j == arg.Length) { + b.Append('\\', backslashCount * 2); + break; + } else if (arg[j] == '"') { + b.Append('\\', backslashCount * 2 + 1); + b.Append('"'); + } else { + b.Append('\\', backslashCount); + b.Append(arg[j]); + } + } + b.Append('"'); + } + } + #endregion } - + [return: MarshalAs(UnmanagedType.Bool)] delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam); diff --git a/ILSpy/Search/SearchPane.cs b/ILSpy/Search/SearchPane.cs index c71e0193e..9d9dea18f 100644 --- a/ILSpy/Search/SearchPane.cs +++ b/ILSpy/Search/SearchPane.cs @@ -200,7 +200,7 @@ namespace ICSharpCode.ILSpy { this.dispatcher = Dispatcher.CurrentDispatcher; this.assemblies = assemblies; - this.searchTerm = searchTerm.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); + this.searchTerm = NativeMethods.CommandLineToArgumentArray(searchTerm); this.language = language; this.searchMode = searchMode; From e9cf52d1d517a9d6370734a121e183f106100733 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 10 Jan 2019 21:25:00 +0100 Subject: [PATCH 08/26] Fix #1390: Extension methods used in collection initializers were not converted correctly. --- .../TestCases/Pretty/InitializerTests.cs | 40 +++- .../TestCases/Pretty/InitializerTests.il | 148 ++++++------- .../TestCases/Pretty/InitializerTests.opt.il | 200 +++++++++--------- .../Pretty/InitializerTests.opt.roslyn.il | 176 +++++++++------ .../Pretty/InitializerTests.roslyn.il | 183 ++++++++++------ ICSharpCode.Decompiler/CSharp/CallBuilder.cs | 42 ++-- 6 files changed, 466 insertions(+), 323 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs index c05b44f0d..c8e12415f 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs @@ -27,7 +27,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests { public static class Extensions { - public static void Add(this TestCases.CustomList inst, int a, int b) + public static void Add(this TestCases.CustomList inst, string a, string b) + { + } + + public static void Add(this IList> collection, string key, T value, Func convert = null) { } } @@ -1544,13 +1548,13 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests #if CS60 X(Y(), new CustomList { { - 1, - 2 + "1", + "2" } }); #else CustomList customList = new CustomList(); - customList.Add(1, 2); + customList.Add("1", "2"); X(Y(), customList); #endif } @@ -1703,7 +1707,33 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests [(object)value] = new S(value) }); } + + public static void Issue1390(IEnumerable tokens, bool alwaysAllowAdministrators, char wireDelimiter) + { +#if OPT + List> obj = new List> { +#else + List> list = new List> { +#endif + { + "tokens", + string.Join(wireDelimiter.ToString(), tokens), + (Func)null + }, + { + "alwaysAllowAdministrators", + alwaysAllowAdministrators.ToString(), + (Func)null + }, + { + "delimiter", + wireDelimiter.ToString(), + (Func)null + } + }; + } + #endif #endregion - } + } } \ No newline at end of file diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il index ef81efe69..ce011b502 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il @@ -15,10 +15,10 @@ } .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. .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) .permissionset reqmin = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} .hash algorithm 0x00008004 @@ -40,8 +40,8 @@ { .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) .method public hidebysig static void Add(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1 inst, - int32 a, - int32 b) cil managed + string a, + string b) cil managed { .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) // Code size 2 (0x2) @@ -50,6 +50,19 @@ IL_0001: ret } // end of method Extensions::Add + .method public hidebysig static void Add(class [mscorlib]System.Collections.Generic.IList`1> collection, + string key, + !!T 'value', + [opt] class [mscorlib]System.Func`2 convert) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .param [4] = nullref + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method Extensions::Add + } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions .class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases @@ -1413,7 +1426,7 @@ IL_0006: ldc.i4.s 10 IL_0008: newarr [mscorlib]System.Int32 IL_000d: dup - IL_000e: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x600000a-1' + IL_000e: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x600000b-1' IL_0013: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0018: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1471,7 +1484,7 @@ IL_000f: ldc.i4.s 10 IL_0011: newarr [mscorlib]System.Int32 IL_0016: dup - IL_0017: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x600000c-1' + IL_0017: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x600000d-1' IL_001c: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0021: stelem.ref @@ -1499,7 +1512,7 @@ IL_003b: ldc.i4.6 IL_003c: newarr [mscorlib]System.Int32 IL_0041: dup - IL_0042: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=24' ''::'$$method0x600000c-2' + IL_0042: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=24' ''::'$$method0x600000d-2' IL_0047: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_004c: stelem.ref @@ -1762,7 +1775,7 @@ IL_0006: ldc.i4.8 IL_0007: newarr [mscorlib]System.Boolean IL_000c: dup - IL_000d: ldtoken field int64 ''::'$$method0x600000f-1' + IL_000d: ldtoken field int64 ''::'$$method0x6000010-1' IL_0012: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1780,7 +1793,7 @@ IL_0006: ldc.i4.s 10 IL_0008: newarr [mscorlib]System.Byte IL_000d: dup - IL_000e: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=10' ''::'$$method0x6000010-1' + IL_000e: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=10' ''::'$$method0x6000011-1' IL_0013: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0018: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1798,7 +1811,7 @@ IL_0006: ldc.i4.8 IL_0007: newarr [mscorlib]System.SByte IL_000c: dup - IL_000d: ldtoken field int64 ''::'$$method0x6000011-1' + IL_000d: ldtoken field int64 ''::'$$method0x6000012-1' IL_0012: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1816,7 +1829,7 @@ IL_0006: ldc.i4.5 IL_0007: newarr [mscorlib]System.Int16 IL_000c: dup - IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=10' ''::'$$method0x6000012-1' + IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=10' ''::'$$method0x6000013-1' IL_0012: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1834,7 +1847,7 @@ IL_0006: ldc.i4.6 IL_0007: newarr [mscorlib]System.UInt16 IL_000c: dup - IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=12' ''::'$$method0x6000013-1' + IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=12' ''::'$$method0x6000014-1' IL_0012: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1852,7 +1865,7 @@ IL_0006: ldc.i4.s 10 IL_0008: newarr [mscorlib]System.Int32 IL_000d: dup - IL_000e: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x6000014-1' + IL_000e: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x6000015-1' IL_0013: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0018: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1870,7 +1883,7 @@ IL_0006: ldc.i4.s 10 IL_0008: newarr [mscorlib]System.UInt32 IL_000d: dup - IL_000e: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x6000015-1' + IL_000e: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x6000016-1' IL_0013: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0018: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1888,7 +1901,7 @@ IL_0006: ldc.i4.5 IL_0007: newarr [mscorlib]System.Int64 IL_000c: dup - IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x6000016-1' + IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x6000017-1' IL_0012: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1906,7 +1919,7 @@ IL_0006: ldc.i4.s 10 IL_0008: newarr [mscorlib]System.UInt64 IL_000d: dup - IL_000e: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=80' ''::'$$method0x6000017-1' + IL_000e: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=80' ''::'$$method0x6000018-1' IL_0013: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0018: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1924,7 +1937,7 @@ IL_0006: ldc.i4.6 IL_0007: newarr [mscorlib]System.Single IL_000c: dup - IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=24' ''::'$$method0x6000018-1' + IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=24' ''::'$$method0x6000019-1' IL_0012: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1942,7 +1955,7 @@ IL_0006: ldc.i4.6 IL_0007: newarr [mscorlib]System.Double IL_000c: dup - IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=48' ''::'$$method0x6000019-1' + IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=48' ''::'$$method0x600001a-1' IL_0012: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -2088,7 +2101,7 @@ IL_0004: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_0009: dup - IL_000a: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=256' ''::'$$method0x600001d-1' + IL_000a: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=256' ''::'$$method0x600001e-1' IL_000f: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0014: stloc.0 @@ -2116,7 +2129,7 @@ IL_000c: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_0011: dup - IL_0012: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001e-1' + IL_0012: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001f-1' IL_0017: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_001c: stelem.ref @@ -2127,7 +2140,7 @@ IL_0021: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_0026: dup - IL_0027: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001e-2' + IL_0027: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001f-2' IL_002c: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0031: stelem.ref @@ -2138,7 +2151,7 @@ IL_0036: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_003b: dup - IL_003c: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001e-3' + IL_003c: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001f-3' IL_0041: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0046: stelem.ref @@ -2149,7 +2162,7 @@ IL_004b: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_0050: dup - IL_0051: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001e-4' + IL_0051: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001f-4' IL_0056: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_005b: stelem.ref @@ -2181,7 +2194,7 @@ int32, int32) IL_0012: dup - IL_0013: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=72' ''::'$$method0x600001f-1' + IL_0013: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=72' ''::'$$method0x6000020-1' IL_0018: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_001d: stelem.ref @@ -2194,7 +2207,7 @@ int32, int32) IL_0028: dup - IL_0029: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=72' ''::'$$method0x600001f-2' + IL_0029: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=72' ''::'$$method0x6000020-2' IL_002e: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0033: stelem.ref @@ -3415,7 +3428,7 @@ IL_0001: ldc.i4.4 IL_0002: newarr [mscorlib]System.Byte IL_0007: dup - IL_0008: ldtoken field int32 ''::'$$method0x6000044-1' + IL_0008: ldtoken field int32 ''::'$$method0x6000045-1' IL_000d: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0012: stloc.0 @@ -3540,34 +3553,25 @@ .method public hidebysig static void ExtensionMethodInCollectionInitializer() cil managed { - // Code size 43 (0x2b) - .maxstack 4 - .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1 V_0, - int32[] V_1) + // Code size 37 (0x25) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1 V_0) IL_0000: nop IL_0001: newobj instance void class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1::.ctor() IL_0006: stloc.0 IL_0007: ldloc.0 - IL_0008: ldc.i4.2 - IL_0009: newarr [mscorlib]System.Int32 - IL_000e: stloc.1 - IL_000f: ldloc.1 - IL_0010: ldc.i4.0 - IL_0011: ldc.i4.1 - IL_0012: stelem.i4 - IL_0013: ldloc.1 - IL_0014: ldc.i4.1 - IL_0015: ldc.i4.2 - IL_0016: stelem.i4 - IL_0017: ldloc.1 - IL_0018: callvirt instance void class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1::Add(int32[]) - IL_001d: nop - IL_001e: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y() - IL_0023: ldloc.0 - IL_0024: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, + IL_0008: ldstr "1" + IL_000d: ldstr "2" + IL_0012: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions::Add(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1, + string, + string) + IL_0017: nop + IL_0018: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y() + IL_001d: ldloc.0 + IL_001e: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, object) - IL_0029: nop - IL_002a: ret + IL_0023: nop + IL_0024: ret } // end of method TestCases::ExtensionMethodInCollectionInitializer .method public hidebysig static void NoCollectionInitializerBecauseOfTypeArguments() cil managed @@ -4680,7 +4684,7 @@ IL_0787: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_078c: dup - IL_078d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=36' ''::'$$method0x6000093-1' + IL_078d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=36' ''::'$$method0x6000094-1' IL_0792: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0797: stsfld int32[0...,0...] ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Issue1336_rg2 @@ -4763,29 +4767,29 @@ .size 36 } // end of class '__StaticArrayInitTypeSize=36' - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x600000a-1' at I_000020C0 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x600000c-1' at I_00002138 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=24' '$$method0x600000c-2' at I_00002160 - .field static assembly int64 '$$method0x600000f-1' at I_00002418 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=10' '$$method0x6000010-1' at I_00002440 - .field static assembly int64 '$$method0x6000011-1' at I_00002470 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=10' '$$method0x6000012-1' at I_00002498 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=12' '$$method0x6000013-1' at I_000024C8 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x6000014-1' at I_000024F8 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x6000015-1' at I_00002540 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x6000016-1' at I_00002588 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=80' '$$method0x6000017-1' at I_000025D0 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=24' '$$method0x6000018-1' at I_00002640 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=48' '$$method0x6000019-1' at I_00002678 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=256' '$$method0x600001d-1' at I_000027C0 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001e-1' at I_000028E8 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001e-2' at I_00002928 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001e-3' at I_00002968 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001e-4' at I_000029A8 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x600001f-1' at I_00002A58 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x600001f-2' at I_00002AA0 - .field static assembly int32 '$$method0x6000044-1' at I_000034B8 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=36' '$$method0x6000093-1' at I_000037A0 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x600000b-1' at I_000020C0 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x600000d-1' at I_00002138 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=24' '$$method0x600000d-2' at I_00002160 + .field static assembly int64 '$$method0x6000010-1' at I_00002418 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=10' '$$method0x6000011-1' at I_00002440 + .field static assembly int64 '$$method0x6000012-1' at I_00002470 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=10' '$$method0x6000013-1' at I_00002498 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=12' '$$method0x6000014-1' at I_000024C8 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x6000015-1' at I_000024F8 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x6000016-1' at I_00002540 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x6000017-1' at I_00002588 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=80' '$$method0x6000018-1' at I_000025D0 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=24' '$$method0x6000019-1' at I_00002640 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=48' '$$method0x600001a-1' at I_00002678 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=256' '$$method0x600001e-1' at I_000027C0 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001f-1' at I_000028E8 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001f-2' at I_00002928 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001f-3' at I_00002968 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001f-4' at I_000029A8 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x6000020-1' at I_00002A58 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x6000020-2' at I_00002AA0 + .field static assembly int32 '$$method0x6000045-1' at I_000034B8 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=36' '$$method0x6000094-1' at I_000037A0 } // end of class '' diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il index c21888c47..d430a21db 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il @@ -15,10 +15,10 @@ } .assembly InitializerTests.opt { - .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. .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) .permissionset reqmin = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} .hash algorithm 0x00008004 @@ -40,8 +40,8 @@ { .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) .method public hidebysig static void Add(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1 inst, - int32 a, - int32 b) cil managed + string a, + string b) cil managed { .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) // Code size 1 (0x1) @@ -49,6 +49,18 @@ IL_0000: ret } // end of method Extensions::Add + .method public hidebysig static void Add(class [mscorlib]System.Collections.Generic.IList`1> collection, + string key, + !!T 'value', + [opt] class [mscorlib]System.Func`2 convert) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .param [4] = nullref + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method Extensions::Add + } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions .class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases @@ -1226,7 +1238,7 @@ IL_0005: ldc.i4.s 10 IL_0007: newarr [mscorlib]System.Int32 IL_000c: dup - IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x600000a-1' + IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x600000b-1' IL_0012: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1280,7 +1292,7 @@ IL_000e: ldc.i4.s 10 IL_0010: newarr [mscorlib]System.Int32 IL_0015: dup - IL_0016: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x600000c-1' + IL_0016: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x600000d-1' IL_001b: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0020: stelem.ref @@ -1308,7 +1320,7 @@ IL_003a: ldc.i4.6 IL_003b: newarr [mscorlib]System.Int32 IL_0040: dup - IL_0041: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=24' ''::'$$method0x600000c-2' + IL_0041: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=24' ''::'$$method0x600000d-2' IL_0046: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_004b: stelem.ref @@ -1571,7 +1583,7 @@ IL_0005: ldc.i4.8 IL_0006: newarr [mscorlib]System.Boolean IL_000b: dup - IL_000c: ldtoken field int64 ''::'$$method0x600000f-1' + IL_000c: ldtoken field int64 ''::'$$method0x6000010-1' IL_0011: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0016: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1587,7 +1599,7 @@ IL_0005: ldc.i4.s 10 IL_0007: newarr [mscorlib]System.Byte IL_000c: dup - IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=10' ''::'$$method0x6000010-1' + IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=10' ''::'$$method0x6000011-1' IL_0012: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1603,7 +1615,7 @@ IL_0005: ldc.i4.8 IL_0006: newarr [mscorlib]System.SByte IL_000b: dup - IL_000c: ldtoken field int64 ''::'$$method0x6000011-1' + IL_000c: ldtoken field int64 ''::'$$method0x6000012-1' IL_0011: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0016: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1619,7 +1631,7 @@ IL_0005: ldc.i4.5 IL_0006: newarr [mscorlib]System.Int16 IL_000b: dup - IL_000c: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=10' ''::'$$method0x6000012-1' + IL_000c: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=10' ''::'$$method0x6000013-1' IL_0011: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0016: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1635,7 +1647,7 @@ IL_0005: ldc.i4.6 IL_0006: newarr [mscorlib]System.UInt16 IL_000b: dup - IL_000c: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=12' ''::'$$method0x6000013-1' + IL_000c: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=12' ''::'$$method0x6000014-1' IL_0011: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0016: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1651,7 +1663,7 @@ IL_0005: ldc.i4.s 10 IL_0007: newarr [mscorlib]System.Int32 IL_000c: dup - IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x6000014-1' + IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x6000015-1' IL_0012: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1667,7 +1679,7 @@ IL_0005: ldc.i4.s 10 IL_0007: newarr [mscorlib]System.UInt32 IL_000c: dup - IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x6000015-1' + IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x6000016-1' IL_0012: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1683,7 +1695,7 @@ IL_0005: ldc.i4.5 IL_0006: newarr [mscorlib]System.Int64 IL_000b: dup - IL_000c: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x6000016-1' + IL_000c: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=40' ''::'$$method0x6000017-1' IL_0011: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0016: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1699,7 +1711,7 @@ IL_0005: ldc.i4.s 10 IL_0007: newarr [mscorlib]System.UInt64 IL_000c: dup - IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=80' ''::'$$method0x6000017-1' + IL_000d: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=80' ''::'$$method0x6000018-1' IL_0012: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1715,7 +1727,7 @@ IL_0005: ldc.i4.6 IL_0006: newarr [mscorlib]System.Single IL_000b: dup - IL_000c: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=24' ''::'$$method0x6000018-1' + IL_000c: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=24' ''::'$$method0x6000019-1' IL_0011: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0016: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1731,7 +1743,7 @@ IL_0005: ldc.i4.6 IL_0006: newarr [mscorlib]System.Double IL_000b: dup - IL_000c: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=48' ''::'$$method0x6000019-1' + IL_000c: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=48' ''::'$$method0x600001a-1' IL_0011: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0016: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, @@ -1868,7 +1880,7 @@ IL_0003: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_0008: dup - IL_0009: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=256' ''::'$$method0x600001d-1' + IL_0009: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=256' ''::'$$method0x600001e-1' IL_000e: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0013: ret @@ -1890,7 +1902,7 @@ IL_000b: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_0010: dup - IL_0011: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001e-1' + IL_0011: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001f-1' IL_0016: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_001b: stelem.ref @@ -1901,7 +1913,7 @@ IL_0020: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_0025: dup - IL_0026: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001e-2' + IL_0026: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001f-2' IL_002b: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0030: stelem.ref @@ -1912,7 +1924,7 @@ IL_0035: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_003a: dup - IL_003b: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001e-3' + IL_003b: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001f-3' IL_0040: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0045: stelem.ref @@ -1923,7 +1935,7 @@ IL_004a: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_004f: dup - IL_0050: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001e-4' + IL_0050: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=64' ''::'$$method0x600001f-4' IL_0055: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_005a: stelem.ref @@ -1949,7 +1961,7 @@ int32, int32) IL_0011: dup - IL_0012: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=72' ''::'$$method0x600001f-1' + IL_0012: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=72' ''::'$$method0x6000020-1' IL_0017: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_001c: stelem.ref @@ -1962,7 +1974,7 @@ int32, int32) IL_0027: dup - IL_0028: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=72' ''::'$$method0x600001f-2' + IL_0028: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=72' ''::'$$method0x6000020-2' IL_002d: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0032: stelem.ref @@ -3007,7 +3019,7 @@ IL_0000: ldc.i4.4 IL_0001: newarr [mscorlib]System.Byte IL_0006: dup - IL_0007: ldtoken field int32 ''::'$$method0x6000044-1' + IL_0007: ldtoken field int32 ''::'$$method0x6000045-1' IL_000c: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_0011: ret @@ -3106,31 +3118,22 @@ .method public hidebysig static void ExtensionMethodInCollectionInitializer() cil managed { - // Code size 40 (0x28) - .maxstack 4 - .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1 V_0, - int32[] V_1) + // Code size 34 (0x22) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1 V_0) IL_0000: newobj instance void class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1::.ctor() IL_0005: stloc.0 IL_0006: ldloc.0 - IL_0007: ldc.i4.2 - IL_0008: newarr [mscorlib]System.Int32 - IL_000d: stloc.1 - IL_000e: ldloc.1 - IL_000f: ldc.i4.0 - IL_0010: ldc.i4.1 - IL_0011: stelem.i4 - IL_0012: ldloc.1 - IL_0013: ldc.i4.1 - IL_0014: ldc.i4.2 - IL_0015: stelem.i4 - IL_0016: ldloc.1 - IL_0017: callvirt instance void class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1::Add(int32[]) - IL_001c: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y() - IL_0021: ldloc.0 - IL_0022: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, + IL_0007: ldstr "1" + IL_000c: ldstr "2" + IL_0011: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions::Add(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1, + string, + string) + IL_0016: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y() + IL_001b: ldloc.0 + IL_001c: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, object) - IL_0027: ret + IL_0021: ret } // end of method TestCases::ExtensionMethodInCollectionInitializer .method public hidebysig static void NoCollectionInitializerBecauseOfTypeArguments() cil managed @@ -4218,7 +4221,7 @@ IL_07df: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_07e4: dup - IL_07e5: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=36' ''::'$$method0x6000093-1' + IL_07e5: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=36' ''::'$$method0x6000094-1' IL_07ea: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) IL_07ef: stsfld int32[0...,0...] ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Issue1336_rg2 @@ -4301,86 +4304,86 @@ .size 36 } // end of class '__StaticArrayInitTypeSize=36' - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x600000a-1' at I_00002070 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x600000c-1' at I_000020E8 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=24' '$$method0x600000c-2' at I_00002110 - .field static assembly int64 '$$method0x600000f-1' at I_000023D0 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=10' '$$method0x6000010-1' at I_000023F8 - .field static assembly int64 '$$method0x6000011-1' at I_00002420 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=10' '$$method0x6000012-1' at I_00002448 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=12' '$$method0x6000013-1' at I_00002470 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x6000014-1' at I_000024A0 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x6000015-1' at I_000024E8 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x6000016-1' at I_00002530 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=80' '$$method0x6000017-1' at I_00002578 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=24' '$$method0x6000018-1' at I_000025E8 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=48' '$$method0x6000019-1' at I_00002620 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=256' '$$method0x600001d-1' at I_00002760 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001e-1' at I_00002878 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001e-2' at I_000028B8 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001e-3' at I_000028F8 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001e-4' at I_00002938 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x600001f-1' at I_000029E8 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x600001f-2' at I_00002A30 - .field static assembly int32 '$$method0x6000044-1' at I_00003388 - .field static assembly valuetype ''/'__StaticArrayInitTypeSize=36' '$$method0x6000093-1' at I_00003628 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x600000b-1' at I_00002078 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x600000d-1' at I_000020F0 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=24' '$$method0x600000d-2' at I_00002118 + .field static assembly int64 '$$method0x6000010-1' at I_000023D8 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=10' '$$method0x6000011-1' at I_00002400 + .field static assembly int64 '$$method0x6000012-1' at I_00002428 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=10' '$$method0x6000013-1' at I_00002450 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=12' '$$method0x6000014-1' at I_00002478 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x6000015-1' at I_000024A8 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x6000016-1' at I_000024F0 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=40' '$$method0x6000017-1' at I_00002538 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=80' '$$method0x6000018-1' at I_00002580 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=24' '$$method0x6000019-1' at I_000025F0 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=48' '$$method0x600001a-1' at I_00002628 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=256' '$$method0x600001e-1' at I_00002768 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001f-1' at I_00002880 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001f-2' at I_000028C0 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001f-3' at I_00002900 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=64' '$$method0x600001f-4' at I_00002940 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x6000020-1' at I_000029F0 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=72' '$$method0x6000020-2' at I_00002A38 + .field static assembly int32 '$$method0x6000045-1' at I_00003390 + .field static assembly valuetype ''/'__StaticArrayInitTypeSize=36' '$$method0x6000094-1' at I_00003628 } // end of class '' // ============================================================= -.data cil I_00002070 = bytearray ( +.data cil I_00002078 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_000020E8 = bytearray ( +.data cil I_000020F0 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00002110 = bytearray ( +.data cil I_00002118 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00) -.data cil I_00002128 = int8[8] -.data cil I_000023D0 = bytearray ( +.data cil I_000023D8 = bytearray ( 01 00 01 00 00 00 01 01) -.data cil I_000023F8 = bytearray ( +.data cil I_000023E0 = int8[32] +.data cil I_00002400 = bytearray ( 01 02 03 04 05 06 07 08 FE FF) -.data cil I_00002402 = int8[30] -.data cil I_00002420 = bytearray ( +.data cil I_0000240A = int8[6] +.data cil I_00002428 = bytearray ( 80 81 00 01 02 03 04 7F) -.data cil I_00002448 = bytearray ( +.data cil I_00002450 = bytearray ( 00 80 FF FF 00 00 01 00 FF 7F) -.data cil I_00002452 = int8[14] -.data cil I_00002470 = bytearray ( +.data cil I_0000245A = int8[6] +.data cil I_00002478 = bytearray ( 00 00 01 00 FF 7F 00 80 FE FF FF FF) -.data cil I_0000247C = int8[4] -.data cil I_000024A0 = bytearray ( +.data cil I_00002484 = int8[4] +.data cil I_000024A8 = bytearray ( 01 00 00 00 FE FF FF FF 00 94 35 77 04 00 00 00 // ..........5w.... 05 00 00 00 FA FF FF FF 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_000024E8 = bytearray ( +.data cil I_000024F0 = bytearray ( 01 00 00 00 00 94 35 77 00 5E D0 B2 04 00 00 00 // ......5w.^...... 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00002530 = bytearray ( +.data cil I_00002538 = bytearray ( 01 00 0C BB 7D 6E 9C BA FF FF FF FF FF FF FF FF // ....}n.......... 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45) // ...D..cE -.data cil I_00002578 = bytearray ( +.data cil I_00002560 = int8[32] +.data cil I_00002580 = bytearray ( 01 00 00 00 00 00 00 00 00 94 35 77 00 00 00 00 // ..........5w.... 00 5E D0 B2 00 00 00 00 04 00 00 00 00 00 00 00 // .^.............. 05 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45 FF FF E7 89 04 23 C7 8A) // ...D..cE.....#.. -.data cil I_000025E8 = bytearray ( +.data cil I_000025F0 = bytearray ( 00 00 C0 BF 00 00 00 00 00 00 C0 3F 00 00 80 FF // ...........?.... 00 00 80 7F 00 00 C0 FF) -.data cil I_00002620 = bytearray ( +.data cil I_00002628 = bytearray ( 00 00 00 00 00 00 F8 BF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F8 3F 00 00 00 00 00 00 F0 FF // .......?........ 00 00 00 00 00 00 F0 7F 00 00 00 00 00 00 F8 FF) -.data cil I_00002650 = int8[16] -.data cil I_00002760 = bytearray ( +.data cil I_00002768 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -4397,41 +4400,42 @@ 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_00002878 = bytearray ( +.data cil I_00002868 = int8[24] +.data cil I_00002880 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00) -.data cil I_000028B8 = bytearray ( +.data cil I_000028C0 = bytearray ( 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_000028F8 = bytearray ( +.data cil I_00002900 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00) -.data cil I_00002938 = bytearray ( +.data cil I_00002940 = bytearray ( 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_000029E8 = bytearray ( +.data cil I_000029F0 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00) -.data cil I_00002A30 = bytearray ( +.data cil I_00002A38 = bytearray ( 15 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 // ........ ...!... 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 // "...#...$...%... 26 00 00 00 27 00 00 00) // &...'... -.data cil I_00003388 = bytearray ( +.data cil I_00003390 = bytearray ( 00 01 02 FF) -.data cil I_0000338C = int8[4] +.data cil I_00003394 = int8[4] .data cil I_00003628 = bytearray ( 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il index 30cfc0695..286d091ff 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il @@ -44,8 +44,8 @@ { .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) .method public hidebysig static void Add(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1 inst, - int32 a, - int32 b) cil managed + string a, + string b) cil managed { .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) // Code size 1 (0x1) @@ -53,6 +53,18 @@ IL_0000: ret } // end of method Extensions::Add + .method public hidebysig static void Add(class [mscorlib]System.Collections.Generic.IList`1> collection, + string key, + !!T 'value', + [opt] class [mscorlib]System.Func`2 convert) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .param [4] = nullref + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method Extensions::Add + } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions .class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases @@ -3039,28 +3051,19 @@ .method public hidebysig static void ExtensionMethodInCollectionInitializer() cil managed { - // Code size 38 (0x26) - .maxstack 6 - .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1 V_0) + // Code size 32 (0x20) + .maxstack 8 IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y() IL_0005: newobj instance void class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1::.ctor() - IL_000a: stloc.0 - IL_000b: ldloc.0 - IL_000c: ldc.i4.2 - IL_000d: newarr [mscorlib]System.Int32 - IL_0012: dup - IL_0013: ldc.i4.0 - IL_0014: ldc.i4.1 - IL_0015: stelem.i4 - IL_0016: dup - IL_0017: ldc.i4.1 - IL_0018: ldc.i4.2 - IL_0019: stelem.i4 - IL_001a: callvirt instance void class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1::Add(int32[]) - IL_001f: ldloc.0 - IL_0020: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, + IL_000a: dup + IL_000b: ldstr "1" + IL_0010: ldstr "2" + IL_0015: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions::Add(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1, + string, + string) + IL_001a: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, object) - IL_0025: ret + IL_001f: ret } // end of method TestCases::ExtensionMethodInCollectionInitializer .method public hidebysig static void NoCollectionInitializerBecauseOfTypeArguments() cil managed @@ -3369,6 +3372,47 @@ IL_0023: ret } // end of method TestCases::Issue1250_Test4 + .method public hidebysig static void Issue1390(class [mscorlib]System.Collections.Generic.IEnumerable`1 tokens, + bool alwaysAllowAdministrators, + char wireDelimiter) cil managed + { + // Code size 70 (0x46) + .maxstack 5 + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0005: dup + IL_0006: ldstr "tokens" + IL_000b: ldarga.s wireDelimiter + IL_000d: call instance string [mscorlib]System.Char::ToString() + IL_0012: ldarg.0 + IL_0013: call string [mscorlib]System.String::Join(string, + class [mscorlib]System.Collections.Generic.IEnumerable`1) + IL_0018: ldnull + IL_0019: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions::Add(class [mscorlib]System.Collections.Generic.IList`1>, + string, + !!0, + class [mscorlib]System.Func`2) + IL_001e: dup + IL_001f: ldstr "alwaysAllowAdministrators" + IL_0024: ldarga.s alwaysAllowAdministrators + IL_0026: call instance string [mscorlib]System.Boolean::ToString() + IL_002b: ldnull + IL_002c: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions::Add(class [mscorlib]System.Collections.Generic.IList`1>, + string, + !!0, + class [mscorlib]System.Func`2) + IL_0031: dup + IL_0032: ldstr "delimiter" + IL_0037: ldarga.s wireDelimiter + IL_0039: call instance string [mscorlib]System.Char::ToString() + IL_003e: ldnull + IL_003f: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions::Add(class [mscorlib]System.Collections.Generic.IList`1>, + string, + !!0, + class [mscorlib]System.Func`2) + IL_0044: pop + IL_0045: ret + } // end of method TestCases::Issue1390 + .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { @@ -4267,68 +4311,68 @@ .size 256 } // end of class '__StaticArrayInitTypeSize=256' - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '1535117EC92E41D4A6B7CA00F965357B05B5DC35' at I_00006E70 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '20E3FF489634E18F3F7EB292AD504DBAE9519293' at I_00006EB8 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '39E94835525CF7B71CD4595742EF462642FBF1B2' at I_00006EC8 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '56D9EEC8EF899644C40B9BE9D886DF2367A5D078' at I_00006F10 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '735E5A21849E86F68D220F06163E8C5C6376B9C9' at I_00006F20 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' '7C39B7B06DD624A17F875AB8E9651554BE6E74D2' at I_00006F30 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' '8D903ECAD8D9D75B3183B23AF79F6D2E607369E3' at I_00006F70 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=80' '9B1F6E56D755443CC39C1969CE38FD41FD4EF4B7' at I_00006F98 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=256' A1EA7DC3FE43B3A54F5B729A92B92AF54181A3EB at I_00006FE8 - .field static assembly initonly int64 A6296CAC471BE2954899600137940479D8073C7C at I_000070E8 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=36' B62E59D20E3D69F06A6D9BD5E3C518FF7093EDAB at I_000070F0 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' B9583930B842DBCEF0D7B8E57D4D3F1E8055C39E at I_00007118 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' C4E70AB31EF6C8908F896CAD1C6BC75F7FA65E27 at I_00007140 - .field static assembly initonly int32 C62C27924F4C967F5EDDB1850C091D54C7A2AB58 at I_00007158 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=48' DC7043B0114737ACE19A23DD755893795FD48A23 at I_00007160 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' DCF557B883E6FE0AEC05B7F0290F0EF47D0AC2E3 at I_00007190 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_000071D0 - .field static assembly initonly int64 EB0715DBB235F3F696F2C404F5839C6650640898 at I_000071F8 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' F514FF55B79BCAA2CEC9B56C062D976E45F89AB7 at I_00007200 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' FBCB49C1A244C1B5781AA1DB02C5A11F68908526 at I_00007228 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '1535117EC92E41D4A6B7CA00F965357B05B5DC35' at I_00007040 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '20E3FF489634E18F3F7EB292AD504DBAE9519293' at I_00007088 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '39E94835525CF7B71CD4595742EF462642FBF1B2' at I_00007098 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '56D9EEC8EF899644C40B9BE9D886DF2367A5D078' at I_000070E0 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '735E5A21849E86F68D220F06163E8C5C6376B9C9' at I_000070F0 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' '7C39B7B06DD624A17F875AB8E9651554BE6E74D2' at I_00007100 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' '8D903ECAD8D9D75B3183B23AF79F6D2E607369E3' at I_00007140 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=80' '9B1F6E56D755443CC39C1969CE38FD41FD4EF4B7' at I_00007168 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=256' A1EA7DC3FE43B3A54F5B729A92B92AF54181A3EB at I_000071B8 + .field static assembly initonly int64 A6296CAC471BE2954899600137940479D8073C7C at I_000072B8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=36' B62E59D20E3D69F06A6D9BD5E3C518FF7093EDAB at I_000072C0 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' B9583930B842DBCEF0D7B8E57D4D3F1E8055C39E at I_000072E8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' C4E70AB31EF6C8908F896CAD1C6BC75F7FA65E27 at I_00007310 + .field static assembly initonly int32 C62C27924F4C967F5EDDB1850C091D54C7A2AB58 at I_00007328 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=48' DC7043B0114737ACE19A23DD755893795FD48A23 at I_00007330 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' DCF557B883E6FE0AEC05B7F0290F0EF47D0AC2E3 at I_00007360 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_000073A0 + .field static assembly initonly int64 EB0715DBB235F3F696F2C404F5839C6650640898 at I_000073C8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' F514FF55B79BCAA2CEC9B56C062D976E45F89AB7 at I_000073D0 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' FBCB49C1A244C1B5781AA1DB02C5A11F68908526 at I_000073F8 } // end of class '' // ============================================================= -.data cil I_00006E70 = bytearray ( +.data cil I_00007040 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00) -.data cil I_00006EB8 = bytearray ( +.data cil I_00007088 = bytearray ( 01 02 03 04 05 06 07 08 FE FF) -.data cil I_00006EC2 = int8[6] -.data cil I_00006EC8 = bytearray ( +.data cil I_00007092 = int8[6] +.data cil I_00007098 = bytearray ( 15 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 // ........ ...!... 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 // "...#...$...%... 26 00 00 00 27 00 00 00) // &...'... -.data cil I_00006F10 = bytearray ( +.data cil I_000070E0 = bytearray ( 00 80 FF FF 00 00 01 00 FF 7F) -.data cil I_00006F1A = int8[6] -.data cil I_00006F20 = bytearray ( +.data cil I_000070EA = int8[6] +.data cil I_000070F0 = bytearray ( 00 00 01 00 FF 7F 00 80 FE FF FF FF) -.data cil I_00006F2C = int8[4] -.data cil I_00006F30 = bytearray ( +.data cil I_000070FC = int8[4] +.data cil I_00007100 = bytearray ( 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_00006F70 = bytearray ( +.data cil I_00007140 = bytearray ( 01 00 0C BB 7D 6E 9C BA FF FF FF FF FF FF FF FF // ....}n.......... 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45) // ...D..cE -.data cil I_00006F98 = bytearray ( +.data cil I_00007168 = bytearray ( 01 00 00 00 00 00 00 00 00 94 35 77 00 00 00 00 // ..........5w.... 00 5E D0 B2 00 00 00 00 04 00 00 00 00 00 00 00 // .^.............. 05 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45 FF FF E7 89 04 23 C7 8A) // ...D..cE.....#.. -.data cil I_00006FE8 = bytearray ( +.data cil I_000071B8 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -4345,43 +4389,43 @@ 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_000070E8 = bytearray ( +.data cil I_000072B8 = bytearray ( 80 81 00 01 02 03 04 7F) -.data cil I_000070F0 = bytearray ( +.data cil I_000072C0 = bytearray ( 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00) -.data cil I_00007114 = int8[4] -.data cil I_00007118 = bytearray ( +.data cil I_000072E4 = int8[4] +.data cil I_000072E8 = bytearray ( 01 00 00 00 00 94 35 77 00 5E D0 B2 04 00 00 00 // ......5w.^...... 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00007140 = bytearray ( +.data cil I_00007310 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00) -.data cil I_00007158 = bytearray ( +.data cil I_00007328 = bytearray ( 00 01 02 FF) -.data cil I_0000715C = int8[4] -.data cil I_00007160 = bytearray ( +.data cil I_0000732C = int8[4] +.data cil I_00007330 = bytearray ( 00 00 00 00 00 00 F8 BF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F8 3F 00 00 00 00 00 00 F0 FF // .......?........ 00 00 00 00 00 00 F0 7F 00 00 00 00 00 00 F8 FF) -.data cil I_00007190 = bytearray ( +.data cil I_00007360 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00) -.data cil I_000071D0 = bytearray ( +.data cil I_000073A0 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_000071F8 = bytearray ( +.data cil I_000073C8 = bytearray ( 01 00 01 00 00 00 01 01) -.data cil I_00007200 = bytearray ( +.data cil I_000073D0 = bytearray ( 01 00 00 00 FE FF FF FF 00 94 35 77 04 00 00 00 // ..........5w.... 05 00 00 00 FA FF FF FF 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00007228 = bytearray ( +.data cil I_000073F8 = bytearray ( 00 00 C0 BF 00 00 00 00 00 00 C0 3F 00 00 80 FF // ...........?.... 00 00 80 7F 00 00 C0 FF) // *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il index 13041bd81..48e0576a1 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il @@ -44,8 +44,8 @@ { .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) .method public hidebysig static void Add(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1 inst, - int32 a, - int32 b) cil managed + string a, + string b) cil managed { .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) // Code size 2 (0x2) @@ -54,6 +54,19 @@ IL_0001: ret } // end of method Extensions::Add + .method public hidebysig static void Add(class [mscorlib]System.Collections.Generic.IList`1> collection, + string key, + !!T 'value', + [opt] class [mscorlib]System.Func`2 convert) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .param [4] = nullref + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method Extensions::Add + } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions .class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases @@ -3429,31 +3442,22 @@ .method public hidebysig static void ExtensionMethodInCollectionInitializer() cil managed { - // Code size 41 (0x29) - .maxstack 6 - .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1 V_0) + // Code size 35 (0x23) + .maxstack 8 IL_0000: nop IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::Y() IL_0006: newobj instance void class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1::.ctor() - IL_000b: stloc.0 - IL_000c: ldloc.0 - IL_000d: ldc.i4.2 - IL_000e: newarr [mscorlib]System.Int32 - IL_0013: dup - IL_0014: ldc.i4.0 - IL_0015: ldc.i4.1 - IL_0016: stelem.i4 - IL_0017: dup - IL_0018: ldc.i4.1 - IL_0019: ldc.i4.2 - IL_001a: stelem.i4 - IL_001b: callvirt instance void class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1::Add(int32[]) - IL_0020: nop - IL_0021: ldloc.0 - IL_0022: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, + IL_000b: dup + IL_000c: ldstr "1" + IL_0011: ldstr "2" + IL_0016: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions::Add(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases/CustomList`1, + string, + string) + IL_001b: nop + IL_001c: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.TestCases::X(object, object) - IL_0027: nop - IL_0028: ret + IL_0021: nop + IL_0022: ret } // end of method TestCases::ExtensionMethodInCollectionInitializer .method public hidebysig static void NoCollectionInitializerBecauseOfTypeArguments() cil managed @@ -3826,6 +3830,52 @@ IL_0026: ret } // end of method TestCases::Issue1250_Test4 + .method public hidebysig static void Issue1390(class [mscorlib]System.Collections.Generic.IEnumerable`1 tokens, + bool alwaysAllowAdministrators, + char wireDelimiter) cil managed + { + // Code size 74 (0x4a) + .maxstack 5 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0006: dup + IL_0007: ldstr "tokens" + IL_000c: ldarga.s wireDelimiter + IL_000e: call instance string [mscorlib]System.Char::ToString() + IL_0013: ldarg.0 + IL_0014: call string [mscorlib]System.String::Join(string, + class [mscorlib]System.Collections.Generic.IEnumerable`1) + IL_0019: ldnull + IL_001a: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions::Add(class [mscorlib]System.Collections.Generic.IList`1>, + string, + !!0, + class [mscorlib]System.Func`2) + IL_001f: nop + IL_0020: dup + IL_0021: ldstr "alwaysAllowAdministrators" + IL_0026: ldarga.s alwaysAllowAdministrators + IL_0028: call instance string [mscorlib]System.Boolean::ToString() + IL_002d: ldnull + IL_002e: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions::Add(class [mscorlib]System.Collections.Generic.IList`1>, + string, + !!0, + class [mscorlib]System.Func`2) + IL_0033: nop + IL_0034: dup + IL_0035: ldstr "delimiter" + IL_003a: ldarga.s wireDelimiter + IL_003c: call instance string [mscorlib]System.Char::ToString() + IL_0041: ldnull + IL_0042: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests.Extensions::Add(class [mscorlib]System.Collections.Generic.IList`1>, + string, + !!0, + class [mscorlib]System.Func`2) + IL_0047: nop + IL_0048: stloc.0 + IL_0049: ret + } // end of method TestCases::Issue1390 + .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { @@ -4725,67 +4775,68 @@ .size 256 } // end of class '__StaticArrayInitTypeSize=256' - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '1535117EC92E41D4A6B7CA00F965357B05B5DC35' at I_0000729C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '20E3FF489634E18F3F7EB292AD504DBAE9519293' at I_000072E4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '39E94835525CF7B71CD4595742EF462642FBF1B2' at I_000072F4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '56D9EEC8EF899644C40B9BE9D886DF2367A5D078' at I_0000733C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '735E5A21849E86F68D220F06163E8C5C6376B9C9' at I_0000734C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' '7C39B7B06DD624A17F875AB8E9651554BE6E74D2' at I_0000735C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' '8D903ECAD8D9D75B3183B23AF79F6D2E607369E3' at I_0000739C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=80' '9B1F6E56D755443CC39C1969CE38FD41FD4EF4B7' at I_000073C4 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=256' A1EA7DC3FE43B3A54F5B729A92B92AF54181A3EB at I_00007414 - .field static assembly initonly int64 A6296CAC471BE2954899600137940479D8073C7C at I_00007514 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=36' B62E59D20E3D69F06A6D9BD5E3C518FF7093EDAB at I_0000751C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' B9583930B842DBCEF0D7B8E57D4D3F1E8055C39E at I_00007544 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' C4E70AB31EF6C8908F896CAD1C6BC75F7FA65E27 at I_0000756C - .field static assembly initonly int32 C62C27924F4C967F5EDDB1850C091D54C7A2AB58 at I_00007584 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=48' DC7043B0114737ACE19A23DD755893795FD48A23 at I_0000758C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' DCF557B883E6FE0AEC05B7F0290F0EF47D0AC2E3 at I_000075BC - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_000075FC - .field static assembly initonly int64 EB0715DBB235F3F696F2C404F5839C6650640898 at I_00007624 - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' F514FF55B79BCAA2CEC9B56C062D976E45F89AB7 at I_0000762C - .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' FBCB49C1A244C1B5781AA1DB02C5A11F68908526 at I_00007654 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '1535117EC92E41D4A6B7CA00F965357B05B5DC35' at I_00007480 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '20E3FF489634E18F3F7EB292AD504DBAE9519293' at I_000074C8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=72' '39E94835525CF7B71CD4595742EF462642FBF1B2' at I_000074D8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=10' '56D9EEC8EF899644C40B9BE9D886DF2367A5D078' at I_00007520 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '735E5A21849E86F68D220F06163E8C5C6376B9C9' at I_00007530 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' '7C39B7B06DD624A17F875AB8E9651554BE6E74D2' at I_00007540 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' '8D903ECAD8D9D75B3183B23AF79F6D2E607369E3' at I_00007580 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=80' '9B1F6E56D755443CC39C1969CE38FD41FD4EF4B7' at I_000075A8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=256' A1EA7DC3FE43B3A54F5B729A92B92AF54181A3EB at I_000075F8 + .field static assembly initonly int64 A6296CAC471BE2954899600137940479D8073C7C at I_000076F8 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=36' B62E59D20E3D69F06A6D9BD5E3C518FF7093EDAB at I_00007700 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' B9583930B842DBCEF0D7B8E57D4D3F1E8055C39E at I_00007728 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' C4E70AB31EF6C8908F896CAD1C6BC75F7FA65E27 at I_00007750 + .field static assembly initonly int32 C62C27924F4C967F5EDDB1850C091D54C7A2AB58 at I_00007768 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=48' DC7043B0114737ACE19A23DD755893795FD48A23 at I_00007770 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=64' DCF557B883E6FE0AEC05B7F0290F0EF47D0AC2E3 at I_000077A0 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' E0D2592373A0C161E56E266306CD8405CD719D19 at I_000077E0 + .field static assembly initonly int64 EB0715DBB235F3F696F2C404F5839C6650640898 at I_00007808 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=40' F514FF55B79BCAA2CEC9B56C062D976E45F89AB7 at I_00007810 + .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=24' FBCB49C1A244C1B5781AA1DB02C5A11F68908526 at I_00007838 } // end of class '' // ============================================================= -.data cil I_0000729C = bytearray ( +.data cil I_00007480 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00) -.data cil I_000072E4 = bytearray ( +.data cil I_000074C8 = bytearray ( 01 02 03 04 05 06 07 08 FE FF) -.data cil I_000072EE = int8[2] -.data cil I_000072F4 = bytearray ( +.data cil I_000074D2 = int8[6] +.data cil I_000074D8 = bytearray ( 15 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 // ........ ...!... 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 // "...#...$...%... 26 00 00 00 27 00 00 00) // &...'... -.data cil I_0000733C = bytearray ( +.data cil I_00007520 = bytearray ( 00 80 FF FF 00 00 01 00 FF 7F) -.data cil I_00007346 = int8[2] -.data cil I_0000734C = bytearray ( +.data cil I_0000752A = int8[6] +.data cil I_00007530 = bytearray ( 00 00 01 00 FF 7F 00 80 FE FF FF FF) -.data cil I_0000735C = bytearray ( +.data cil I_0000753C = int8[4] +.data cil I_00007540 = bytearray ( 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_0000739C = bytearray ( +.data cil I_00007580 = bytearray ( 01 00 0C BB 7D 6E 9C BA FF FF FF FF FF FF FF FF // ....}n.......... 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45) // ...D..cE -.data cil I_000073C4 = bytearray ( +.data cil I_000075A8 = bytearray ( 01 00 00 00 00 00 00 00 00 94 35 77 00 00 00 00 // ..........5w.... 00 5E D0 B2 00 00 00 00 04 00 00 00 00 00 00 00 // .^.............. 05 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 FF FF F3 44 82 91 63 45 FF FF E7 89 04 23 C7 8A) // ...D..cE.....#.. -.data cil I_00007414 = bytearray ( +.data cil I_000075F8 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -4802,41 +4853,43 @@ 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00) -.data cil I_00007514 = bytearray ( +.data cil I_000076F8 = bytearray ( 80 81 00 01 02 03 04 7F) -.data cil I_0000751C = bytearray ( +.data cil I_00007700 = bytearray ( 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00) -.data cil I_00007544 = bytearray ( +.data cil I_00007724 = int8[4] +.data cil I_00007728 = bytearray ( 01 00 00 00 00 94 35 77 00 5E D0 B2 04 00 00 00 // ......5w.^...... 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_0000756C = bytearray ( +.data cil I_00007750 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00) -.data cil I_00007584 = bytearray ( +.data cil I_00007768 = bytearray ( 00 01 02 FF) -.data cil I_0000758C = bytearray ( +.data cil I_0000776C = int8[4] +.data cil I_00007770 = bytearray ( 00 00 00 00 00 00 F8 BF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F8 3F 00 00 00 00 00 00 F0 FF // .......?........ 00 00 00 00 00 00 F0 7F 00 00 00 00 00 00 F8 FF) -.data cil I_000075BC = bytearray ( +.data cil I_000077A0 = bytearray ( 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00) -.data cil I_000075FC = bytearray ( +.data cil I_000077E0 = bytearray ( 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00007624 = bytearray ( +.data cil I_00007808 = bytearray ( 01 00 01 00 00 00 01 01) -.data cil I_0000762C = bytearray ( +.data cil I_00007810 = bytearray ( 01 00 00 00 FE FF FF FF 00 94 35 77 04 00 00 00 // ..........5w.... 05 00 00 00 FA FF FF FF 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00) -.data cil I_00007654 = bytearray ( +.data cil I_00007838 = bytearray ( 00 00 C0 BF 00 00 00 00 00 00 C0 3F 00 00 80 FF // ...........?.... 00 00 80 7F 00 00 C0 FF) // *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler/CSharp/CallBuilder.cs b/ICSharpCode.Decompiler/CSharp/CallBuilder.cs index 515ec9eae..3b4e98ee5 100644 --- a/ICSharpCode.Decompiler/CSharp/CallBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/CallBuilder.cs @@ -54,18 +54,19 @@ namespace ICSharpCode.Decompiler.CSharp public bool IsExpandedForm; public int Length => Arguments.Length; - public IEnumerable GetArgumentResolveResults() + public IEnumerable GetArgumentResolveResults(int skipCount = 0) { return FirstOptionalArgumentIndex < 0 - ? Arguments.Select(a => a.ResolveResult) - : Arguments.Take(FirstOptionalArgumentIndex).Select(a => a.ResolveResult); + ? Arguments.Skip(skipCount).Select(a => a.ResolveResult) + : Arguments.Skip(skipCount).Take(FirstOptionalArgumentIndex).Select(a => a.ResolveResult); } - public IEnumerable GetArgumentExpressions() + public IEnumerable GetArgumentExpressions(int skipCount = 0) { if (AddNamesToPrimitiveValues && IsPrimitiveValue.Any() && !IsExpandedForm && !ParameterNames.Any(p => string.IsNullOrEmpty(p))) { + Debug.Assert(skipCount == 0); if (ArgumentNames == null) { ArgumentNames = new string[Arguments.Length]; } @@ -78,9 +79,10 @@ namespace ICSharpCode.Decompiler.CSharp } if (ArgumentNames == null) { if (FirstOptionalArgumentIndex < 0) - return Arguments.Select(arg => arg.Expression); - return Arguments.Take(FirstOptionalArgumentIndex).Select(arg => arg.Expression); + return Arguments.Skip(skipCount).Select(arg => arg.Expression); + return Arguments.Skip(skipCount).Take(FirstOptionalArgumentIndex).Select(arg => arg.Expression); } else { + Debug.Assert(skipCount == 0); if (FirstOptionalArgumentIndex < 0) { return Arguments.Zip(ArgumentNames, (arg, name) => { @@ -373,17 +375,15 @@ namespace ICSharpCode.Decompiler.CSharp // sure that the correct method is called by resolving any ambiguities by inserting casts, if necessary. ExpectedTargetDetails expectedTargetDetails = new ExpectedTargetDetails { CallOpCode = callOpCode }; - - // Special case: only in this case, collection initializers, are extension methods already transformed on - // ILAst level, therefore we have to exclude the first argument. - int firstParamIndex = method.IsExtensionMethod ? 1 : 0; + var unused = new IdentifierExpression("initializedObject").WithRR(target).WithoutILInstruction(); + var args = callArguments.ToList(); + if (method.IsExtensionMethod) + args.Insert(0, new Nop()); var argumentList = BuildArgumentList(expectedTargetDetails, target, method, - firstParamIndex, callArguments, null); + firstParamIndex: 0, args, null); argumentList.ArgumentNames = null; argumentList.AddNamesToPrimitiveValues = false; - - var unused = new IdentifierExpression("initializedObject").WithRR(target).WithoutILInstruction(); var transform = GetRequiredTransformationsForCall(expectedTargetDetails, method, ref unused, ref argumentList, CallTransformation.None, out IParameterizedMember foundMethod); Debug.Assert(transform == CallTransformation.None || transform == CallTransformation.NoOptionalArgumentAllowed); @@ -391,14 +391,22 @@ namespace ICSharpCode.Decompiler.CSharp // Calls with only one argument do not need an array initializer expression to wrap them. // Any special cases are handled by the caller (i.e., ExpressionBuilder.TranslateObjectAndCollectionInitializer) // Note: we intentionally ignore the firstOptionalArgumentIndex in this case. - if (argumentList.Arguments.Length == 1) - return argumentList.Arguments[0]; + int skipCount; + if (method.IsExtensionMethod) { + if (argumentList.Arguments.Length == 2) + return argumentList.Arguments[1]; + skipCount = 1; + } else { + if (argumentList.Arguments.Length == 1) + return argumentList.Arguments[0]; + skipCount = 0; + } if ((transform & CallTransformation.NoOptionalArgumentAllowed) != 0) argumentList.FirstOptionalArgumentIndex = -1; - return new ArrayInitializerExpression(argumentList.GetArgumentExpressions()) - .WithRR(new CSharpInvocationResolveResult(target, method, argumentList.GetArgumentResolveResults().ToArray(), + return new ArrayInitializerExpression(argumentList.GetArgumentExpressions(skipCount)) + .WithRR(new CSharpInvocationResolveResult(target, method, argumentList.GetArgumentResolveResults(skipCount).ToArray(), isExtensionMethodInvocation: method.IsExtensionMethod, isExpandedForm: argumentList.IsExpandedForm)); } From d280f55666fbc94978029a8057dec79e1fd590dd Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 13 Jan 2019 11:08:25 +0100 Subject: [PATCH 09/26] Set VersionName = "rc2" --- ILSpy/Properties/AssemblyInfo.template.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILSpy/Properties/AssemblyInfo.template.cs b/ILSpy/Properties/AssemblyInfo.template.cs index d88029a74..2b2caee49 100644 --- a/ILSpy/Properties/AssemblyInfo.template.cs +++ b/ILSpy/Properties/AssemblyInfo.template.cs @@ -42,7 +42,7 @@ internal static class RevisionClass public const string Minor = "0"; public const string Build = "0"; public const string Revision = "$INSERTREVISION$"; - public const string VersionName = "rc1"; + public const string VersionName = "rc2"; public const string FullVersion = Major + "." + Minor + "." + Build + ".$INSERTREVISION$$INSERTBRANCHPOSTFIX$$INSERTVERSIONNAMEPOSTFIX$"; } From b1c89a634c7d69282cca507d52c6060340b0a577 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 16 Jan 2019 13:40:13 +0100 Subject: [PATCH 10/26] Set VersionName = null --- ILSpy/Properties/AssemblyInfo.template.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILSpy/Properties/AssemblyInfo.template.cs b/ILSpy/Properties/AssemblyInfo.template.cs index 2b2caee49..3819a4c1c 100644 --- a/ILSpy/Properties/AssemblyInfo.template.cs +++ b/ILSpy/Properties/AssemblyInfo.template.cs @@ -42,7 +42,7 @@ internal static class RevisionClass public const string Minor = "0"; public const string Build = "0"; public const string Revision = "$INSERTREVISION$"; - public const string VersionName = "rc2"; + public const string VersionName = null; public const string FullVersion = Major + "." + Minor + "." + Build + ".$INSERTREVISION$$INSERTBRANCHPOSTFIX$$INSERTVERSIONNAMEPOSTFIX$"; } From ea930e025c047094fa68954ba52decf39264fc25 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 16 Jan 2019 10:43:26 -0600 Subject: [PATCH 11/26] Switch to MSBuild.Sdk.Extras for WPF support --- .../ILSpy.BamlDecompiler.Tests.csproj | 14 ++++--------- ILSpy/ILSpy.csproj | 21 ++++--------------- SharpTreeView/ICSharpCode.TreeView.csproj | 10 ++++----- TestPlugin/TestPlugin.csproj | 10 ++++----- global.json | 5 +++++ 5 files changed, 21 insertions(+), 39 deletions(-) create mode 100644 global.json diff --git a/ILSpy.BamlDecompiler.Tests/ILSpy.BamlDecompiler.Tests.csproj b/ILSpy.BamlDecompiler.Tests/ILSpy.BamlDecompiler.Tests.csproj index 18c13fc75..f5923fd80 100644 --- a/ILSpy.BamlDecompiler.Tests/ILSpy.BamlDecompiler.Tests.csproj +++ b/ILSpy.BamlDecompiler.Tests/ILSpy.BamlDecompiler.Tests.csproj @@ -1,5 +1,5 @@  - + net46 @@ -7,11 +7,9 @@ False false - - - - - $(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets + true + false + false @@ -99,8 +97,4 @@ - - - - \ No newline at end of file diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index beb5823a6..a90bcbddb 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -1,5 +1,5 @@  - + net46 @@ -8,6 +8,9 @@ False false + true + false + false ICSharpCode.ILSpy @@ -34,11 +37,6 @@ ..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.ruleset - - - $(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets - - @@ -258,7 +256,6 @@ - @@ -392,16 +389,6 @@ - - - - false - - - - $(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets - - diff --git a/TestPlugin/TestPlugin.csproj b/TestPlugin/TestPlugin.csproj index 4ded52538..36058d340 100644 --- a/TestPlugin/TestPlugin.csproj +++ b/TestPlugin/TestPlugin.csproj @@ -1,5 +1,5 @@  - + net461 @@ -8,6 +8,9 @@ False False + true + false + false @@ -21,11 +24,6 @@ true - - - $(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets - - diff --git a/global.json b/global.json new file mode 100644 index 000000000..8067f2c2a --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "msbuild-sdks": { + "MSBuild.Sdk.Extras": "1.6.65" + } +} From 6a2eab2a527272bb45dcbb4e99bcfba17b21350f Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 16 Jan 2019 11:13:20 -0600 Subject: [PATCH 12/26] Switch to AsyncPackage with background load --- ILSpy.AddIn/Commands/OpenCodeItemCommand.cs | 3 ++ ILSpy.AddIn/Commands/OpenILSpyCommand.cs | 5 +++ .../Commands/OpenProjectOutputCommand.cs | 3 ++ ILSpy.AddIn/Commands/OpenReferenceCommand.cs | 3 ++ ILSpy.AddIn/ILSpyAddInPackage.cs | 36 +++++++++++++------ 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/ILSpy.AddIn/Commands/OpenCodeItemCommand.cs b/ILSpy.AddIn/Commands/OpenCodeItemCommand.cs index 958b0e00a..0f26fa2d6 100644 --- a/ILSpy.AddIn/Commands/OpenCodeItemCommand.cs +++ b/ILSpy.AddIn/Commands/OpenCodeItemCommand.cs @@ -18,6 +18,7 @@ namespace ICSharpCode.ILSpy.AddIn.Commands public OpenCodeItemCommand(ILSpyAddInPackage owner) : base(owner, PkgCmdIDList.cmdidOpenCodeItemInILSpy) { + ThreadHelper.ThrowIfNotOnUIThread(); } protected override void OnBeforeQueryStatus(object sender, EventArgs e) @@ -185,6 +186,8 @@ namespace ICSharpCode.ILSpy.AddIn.Commands internal static void Register(ILSpyAddInPackage owner) { + ThreadHelper.ThrowIfNotOnUIThread(); + instance = new OpenCodeItemCommand(owner); } } diff --git a/ILSpy.AddIn/Commands/OpenILSpyCommand.cs b/ILSpy.AddIn/Commands/OpenILSpyCommand.cs index 6f1261d3c..317004f50 100644 --- a/ILSpy.AddIn/Commands/OpenILSpyCommand.cs +++ b/ILSpy.AddIn/Commands/OpenILSpyCommand.cs @@ -32,6 +32,8 @@ namespace ICSharpCode.ILSpy.AddIn.Commands protected ILSpyCommand(ILSpyAddInPackage owner, uint id) { + ThreadHelper.ThrowIfNotOnUIThread(); + this.owner = owner; CommandID menuCommandID = new CommandID(GuidList.guidILSpyAddInCmdSet, (int)id); OleMenuCommand menuItem = new OleMenuCommand(OnExecute, menuCommandID); @@ -120,6 +122,7 @@ namespace ICSharpCode.ILSpy.AddIn.Commands public OpenILSpyCommand(ILSpyAddInPackage owner) : base(owner, PkgCmdIDList.cmdidOpenILSpy) { + ThreadHelper.ThrowIfNotOnUIThread(); } protected override void OnExecute(object sender, EventArgs e) @@ -129,6 +132,8 @@ namespace ICSharpCode.ILSpy.AddIn.Commands internal static void Register(ILSpyAddInPackage owner) { + ThreadHelper.ThrowIfNotOnUIThread(); + instance = new OpenILSpyCommand(owner); } } diff --git a/ILSpy.AddIn/Commands/OpenProjectOutputCommand.cs b/ILSpy.AddIn/Commands/OpenProjectOutputCommand.cs index 924f8deaa..8fd06a50c 100644 --- a/ILSpy.AddIn/Commands/OpenProjectOutputCommand.cs +++ b/ILSpy.AddIn/Commands/OpenProjectOutputCommand.cs @@ -12,6 +12,7 @@ namespace ICSharpCode.ILSpy.AddIn.Commands public OpenProjectOutputCommand(ILSpyAddInPackage owner) : base(owner, PkgCmdIDList.cmdidOpenProjectOutputInILSpy) { + ThreadHelper.ThrowIfNotOnUIThread(); } protected override void OnBeforeQueryStatus(object sender, EventArgs e) @@ -36,6 +37,8 @@ namespace ICSharpCode.ILSpy.AddIn.Commands internal static void Register(ILSpyAddInPackage owner) { + ThreadHelper.ThrowIfNotOnUIThread(); + instance = new OpenProjectOutputCommand(owner); } } diff --git a/ILSpy.AddIn/Commands/OpenReferenceCommand.cs b/ILSpy.AddIn/Commands/OpenReferenceCommand.cs index 682f5659d..5c2b61fa8 100644 --- a/ILSpy.AddIn/Commands/OpenReferenceCommand.cs +++ b/ILSpy.AddIn/Commands/OpenReferenceCommand.cs @@ -17,6 +17,7 @@ namespace ICSharpCode.ILSpy.AddIn.Commands public OpenReferenceCommand(ILSpyAddInPackage owner) : base(owner, PkgCmdIDList.cmdidOpenReferenceInILSpy) { + ThreadHelper.ThrowIfNotOnUIThread(); } protected override void OnBeforeQueryStatus(object sender, EventArgs e) @@ -87,6 +88,8 @@ namespace ICSharpCode.ILSpy.AddIn.Commands internal static void Register(ILSpyAddInPackage owner) { + ThreadHelper.ThrowIfNotOnUIThread(); + instance = new OpenReferenceCommand(owner); } } diff --git a/ILSpy.AddIn/ILSpyAddInPackage.cs b/ILSpy.AddIn/ILSpyAddInPackage.cs index fe1d19bdc..aedbda510 100644 --- a/ILSpy.AddIn/ILSpyAddInPackage.cs +++ b/ILSpy.AddIn/ILSpyAddInPackage.cs @@ -3,6 +3,8 @@ using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; using System.ComponentModel.Design; +using System.Threading; +using Microsoft; using Microsoft.VisualStudio; using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Shell; @@ -11,6 +13,7 @@ using Microsoft.VisualStudio.ComponentModelHost; using Microsoft.VisualStudio.LanguageServices; using EnvDTE; using System.Collections.Generic; +using Task = System.Threading.Tasks.Task; namespace ICSharpCode.ILSpy.AddIn { @@ -26,15 +29,15 @@ namespace ICSharpCode.ILSpy.AddIn /// // This attribute tells the PkgDef creation utility (CreatePkgDef.exe) that this class is // a package. - [PackageRegistration(UseManagedResourcesOnly = true)] + [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] // This attribute is used to register the information needed to show this package // in the Help/About dialog of Visual Studio. [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] // This attribute is needed to let the shell know that this package exposes some menus. [ProvideMenuResource("Menus.ctmenu", 1)] [Guid(GuidList.guidILSpyAddInPkgString)] - [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_string)] - public sealed class ILSpyAddInPackage : Package + [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_string, PackageAutoLoadFlags.BackgroundLoad)] + public sealed class ILSpyAddInPackage : AsyncPackage { /// /// Default constructor of the package. @@ -65,19 +68,24 @@ namespace ICSharpCode.ILSpy.AddIn /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// - protected override void Initialize() + protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress progress) { - Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); - base.Initialize(); + Debug.WriteLine($"Entering {nameof(InitializeAsync)}() of: {this}"); + + await base.InitializeAsync(cancellationToken, progress); + + await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); + cancellationToken.ThrowIfCancellationRequested(); + + var componentModel = (IComponentModel)await GetServiceAsync(typeof(SComponentModel)); + Assumes.Present(componentModel); // Add our command handlers for menu (commands must exist in the .vsct file) - this.menuService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; + this.menuService = (OleMenuCommandService)await GetServiceAsync(typeof(IMenuCommandService)); + Assumes.Present(menuService); - var componentModel = (IComponentModel)this.GetService(typeof(SComponentModel)); this.workspace = componentModel.GetService(); - - if (menuService == null || workspace == null) - return; + Assumes.Present(workspace); OpenILSpyCommand.Register(this); OpenProjectOutputCommand.Register(this); @@ -88,16 +96,22 @@ namespace ICSharpCode.ILSpy.AddIn public void ShowMessage(string format, params object[] items) { + ThreadHelper.ThrowIfNotOnUIThread(); + ShowMessage(OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_INFO, format, items); } public void ShowMessage(OLEMSGICON icon, string format, params object[] items) { + ThreadHelper.ThrowIfNotOnUIThread(); + ShowMessage(OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, icon, format, items); } public int ShowMessage(OLEMSGBUTTON buttons, OLEMSGDEFBUTTON defaultButton, OLEMSGICON icon, string format, params object[] items) { + ThreadHelper.ThrowIfNotOnUIThread(); + IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; int result; From 6af75ce358c4568018e4832a43ea4869c550665e Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 16 Jan 2019 11:14:14 -0600 Subject: [PATCH 13/26] Update references --- ILSpy.AddIn/Commands/OpenILSpyCommand.cs | 4 ++-- ILSpy.AddIn/ILSpy.AddIn.csproj | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ILSpy.AddIn/Commands/OpenILSpyCommand.cs b/ILSpy.AddIn/Commands/OpenILSpyCommand.cs index 317004f50..898393005 100644 --- a/ILSpy.AddIn/Commands/OpenILSpyCommand.cs +++ b/ILSpy.AddIn/Commands/OpenILSpyCommand.cs @@ -6,9 +6,9 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; -using EnvDTE80; using Microsoft.VisualStudio.Shell; using Mono.Cecil; +using DTEConstants = EnvDTE.Constants; namespace ICSharpCode.ILSpy.AddIn.Commands { @@ -98,7 +98,7 @@ namespace ICSharpCode.ILSpy.AddIn.Commands protected EnvDTE.Project FindProject(IEnumerable projects, string projectFile) { foreach (var project in projects) { - if (project.Kind == ProjectKinds.vsProjectKindSolutionFolder) { + if (project.Kind == DTEConstants.vsProjectKindSolutionItems) { // This is a solution folder -> search in sub-projects var subProject = FindProject( project.ProjectItems.OfType().Select(pi => pi.SubProject).OfType(), diff --git a/ILSpy.AddIn/ILSpy.AddIn.csproj b/ILSpy.AddIn/ILSpy.AddIn.csproj index f3b2dd135..c8bb0b57b 100644 --- a/ILSpy.AddIn/ILSpy.AddIn.csproj +++ b/ILSpy.AddIn/ILSpy.AddIn.csproj @@ -51,9 +51,11 @@ - + + + From e8abb788b4b4b6a842ea2f0f867717282657d077 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 16 Jan 2019 11:14:31 -0600 Subject: [PATCH 14/26] Remove duplicate VSIX installation targets --- ILSpy.AddIn/source.extension.vsixmanifest.template | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ILSpy.AddIn/source.extension.vsixmanifest.template b/ILSpy.AddIn/source.extension.vsixmanifest.template index f2c56a440..b87e1d1dc 100644 --- a/ILSpy.AddIn/source.extension.vsixmanifest.template +++ b/ILSpy.AddIn/source.extension.vsixmanifest.template @@ -9,10 +9,6 @@ ILSpy-Large.ico - - - - From 875b498c4ac854a3d307382f5a4121c63eee7fdb Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Wed, 16 Jan 2019 18:52:05 +0100 Subject: [PATCH 15/26] Update dotnet tool ilspycmd to 4.0 rtm, PS and Xamarin workbook --- DecompilerNuGetDemos.workbook | 2 +- .../ICSharpCode.Decompiler.Console.csproj | 8 ++++---- .../ICSharpCode.Decompiler.PowerShell.csproj | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/DecompilerNuGetDemos.workbook b/DecompilerNuGetDemos.workbook index 6b2154b09..88215c397 100644 --- a/DecompilerNuGetDemos.workbook +++ b/DecompilerNuGetDemos.workbook @@ -6,7 +6,7 @@ platforms: - DotNetCore packages: - id: ICSharpCode.Decompiler - version: 4.0.0.4509-rc1 + version: 4.0.0.4521 --- Setup: load the references required to work with the decompiler diff --git a/ICSharpCode.Decompiler.Console/ICSharpCode.Decompiler.Console.csproj b/ICSharpCode.Decompiler.Console/ICSharpCode.Decompiler.Console.csproj index dba035584..81f528251 100644 --- a/ICSharpCode.Decompiler.Console/ICSharpCode.Decompiler.Console.csproj +++ b/ICSharpCode.Decompiler.Console/ICSharpCode.Decompiler.Console.csproj @@ -7,7 +7,7 @@ true ilspycmd ilspycmd - 3.8.0 + 4.0 Command-line decompiler using the ILSpy decompilation engine Copyright 2011-2019 AlphaSierraPapa https://github.com/icsharpcode/ILSpy/ @@ -15,8 +15,8 @@ https://ilspy.net/images/icon32.png https://github.com/icsharpcode/ILSpy/ - 3.8.0.0 - 3.8.0.0 + 4.0.0.0 + 4.0.0.0 true @@ -27,7 +27,7 @@ - + diff --git a/ICSharpCode.Decompiler.PowerShell/ICSharpCode.Decompiler.PowerShell.csproj b/ICSharpCode.Decompiler.PowerShell/ICSharpCode.Decompiler.PowerShell.csproj index 3a8e90d7a..514c347a6 100644 --- a/ICSharpCode.Decompiler.PowerShell/ICSharpCode.Decompiler.PowerShell.csproj +++ b/ICSharpCode.Decompiler.PowerShell/ICSharpCode.Decompiler.PowerShell.csproj @@ -8,7 +8,7 @@ - + From 96f7a4cab092b8653eb87708be9cd12e5ce306e4 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 21 Jan 2019 01:20:39 +0100 Subject: [PATCH 16/26] Fix #1399: Use same default value as in previous versions for "show internal types and members" setting. Fixes #1398 as well. --- ILSpy/FilterSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILSpy/FilterSettings.cs b/ILSpy/FilterSettings.cs index 9a76a6a26..e784f1c3c 100644 --- a/ILSpy/FilterSettings.cs +++ b/ILSpy/FilterSettings.cs @@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpy { public FilterSettings(XElement element) { - this.ShowApiLevel = (ApiVisibility?)(int?)element.Element("ShowAPILevel") ?? ApiVisibility.PublicOnly; + this.ShowApiLevel = (ApiVisibility?)(int?)element.Element("ShowAPILevel") ?? ApiVisibility.PublicAndInternal; this.Language = Languages.GetLanguage((string)element.Element("Language")); this.LanguageVersion = Language.LanguageVersions.FirstOrDefault(v => v.Version == (string)element.Element("LanguageVersion")); if (this.LanguageVersion == default(LanguageVersion)) From e6e8fbe764f010e7974e3b681a63a71707766c2b Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 21 Jan 2019 02:18:17 +0100 Subject: [PATCH 17/26] Move VSIX build workaround from ILSpy.csproj to ILSpy.AddIn.csproj. Fix #1400 by adding ILSpy.BamlDecompiler.Plugin.dll to the workaround file list. --- ILSpy.AddIn/ILSpy.AddIn.csproj | 39 ++++++++++++++++++++++++++++------ ILSpy.sln | 5 ++++- ILSpy/ILSpy.csproj | 26 ----------------------- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/ILSpy.AddIn/ILSpy.AddIn.csproj b/ILSpy.AddIn/ILSpy.AddIn.csproj index c8bb0b57b..8b1df1687 100644 --- a/ILSpy.AddIn/ILSpy.AddIn.csproj +++ b/ILSpy.AddIn/ILSpy.AddIn.csproj @@ -103,13 +103,42 @@ + + + ..\ILSpy\bin\$(Configuration)\$(TargetFramework)\ + + + + + + + + + + + + + + + + + + + + + - + true \ - + - + + @@ -162,8 +191,4 @@ - - - - \ No newline at end of file diff --git a/ILSpy.sln b/ILSpy.sln index 2e0b1b0ac..21c5ca663 100644 --- a/ILSpy.sln +++ b/ILSpy.sln @@ -25,10 +25,13 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILSpy.BamlDecompiler.Tests", "ILSpy.BamlDecompiler.Tests\ILSpy.BamlDecompiler.Tests.csproj", "{1169E6D1-1899-43D4-A500-07CE4235B388}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILSpy.AddIn", "ILSpy.AddIn\ILSpy.AddIn.csproj", "{9D7BE6C0-B7B3-4A50-A54E-18A2D84A3384}" + ProjectSection(ProjectDependencies) = postProject + {A6BAD2BA-76BA-461C-8B6D-418607591247} = {A6BAD2BA-76BA-461C-8B6D-418607591247} + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.Decompiler.PdbProvider.Cecil", "ICSharpCode.Decompiler.PdbProvider.Cecil\ICSharpCode.Decompiler.PdbProvider.Cecil.csproj", "{B85A155A-9DD6-43BC-A624-2D8EC773D71F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.Tests", "ILSpy.Tests\ILSpy.Tests.csproj", "{B51C6636-B8D1-4200-9869-08F2689DE6C2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILSpy.Tests", "ILSpy.Tests\ILSpy.Tests.csproj", "{B51C6636-B8D1-4200-9869-08F2689DE6C2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index a90bcbddb..d8a6632c9 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -389,32 +389,6 @@ - - - - - - - - - - - - - - - - - - - - - - $(MSBuildToolsPath)\..\..\..\VC\ $(VCBasePath)Auxiliary\Build\Microsoft.VCToolsVersion.default.props From 25fb4f4ffe0f2cc72fcbf02835bb6f583f74cfa4 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 24 Jan 2019 22:11:13 +0100 Subject: [PATCH 18/26] Prepare 4.0.1 hotfix release. --- ILSpy/Properties/AssemblyInfo.template.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILSpy/Properties/AssemblyInfo.template.cs b/ILSpy/Properties/AssemblyInfo.template.cs index 3819a4c1c..a6228d001 100644 --- a/ILSpy/Properties/AssemblyInfo.template.cs +++ b/ILSpy/Properties/AssemblyInfo.template.cs @@ -40,7 +40,7 @@ internal static class RevisionClass { public const string Major = "4"; public const string Minor = "0"; - public const string Build = "0"; + public const string Build = "1"; public const string Revision = "$INSERTREVISION$"; public const string VersionName = null; From 5df098f7375c27aa456d7b5fafbb6c459098f75a Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 26 Jan 2019 09:23:26 +0100 Subject: [PATCH 19/26] Set version = 4.1.0 alpha1 --- ILSpy/Properties/AssemblyInfo.template.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ILSpy/Properties/AssemblyInfo.template.cs b/ILSpy/Properties/AssemblyInfo.template.cs index a6228d001..ac3c7cc8b 100644 --- a/ILSpy/Properties/AssemblyInfo.template.cs +++ b/ILSpy/Properties/AssemblyInfo.template.cs @@ -39,10 +39,10 @@ using System.Diagnostics.CodeAnalysis; internal static class RevisionClass { public const string Major = "4"; - public const string Minor = "0"; - public const string Build = "1"; + public const string Minor = "1"; + public const string Build = "0"; public const string Revision = "$INSERTREVISION$"; - public const string VersionName = null; + public const string VersionName = "alpha1"; public const string FullVersion = Major + "." + Minor + "." + Build + ".$INSERTREVISION$$INSERTBRANCHPOSTFIX$$INSERTVERSIONNAMEPOSTFIX$"; } From 99fc57c6beb43c592d2020f954635fb90476d89b Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 26 Jan 2019 09:24:55 +0100 Subject: [PATCH 20/26] CachedDelegateInitialization: Do not lose IL range by creating a new store instruction, reuse existing instruction instead. --- .../IL/Transforms/CachedDelegateInitialization.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/IL/Transforms/CachedDelegateInitialization.cs b/ICSharpCode.Decompiler/IL/Transforms/CachedDelegateInitialization.cs index 0a0d39c09..a0e365f92 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/CachedDelegateInitialization.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/CachedDelegateInitialization.cs @@ -116,7 +116,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms return false; context.Step("CachedDelegateInitializationWithLocal", inst); ((Block)otherStore.Parent).Instructions.Remove(otherStore); - inst.ReplaceWith(new StLoc(v, value)); + inst.ReplaceWith(storeInst); return true; } From 98692e2fedcfc03a00f93e00aa75499b854c8aa0 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 26 Jan 2019 09:26:32 +0100 Subject: [PATCH 21/26] Fix title bar content in debug builds. --- ILSpy/MainWindow.xaml.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs index d5cbbddbd..68e57b8d7 100644 --- a/ILSpy/MainWindow.xaml.cs +++ b/ILSpy/MainWindow.xaml.cs @@ -381,9 +381,6 @@ namespace ICSharpCode.ILSpy } Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => OpenAssemblies(spySettings))); -#if DEBUG - this.Title = $"ILSpy {RevisionClass.FullVersion}"; -#endif } void OpenAssemblies(ILSpySettings spySettings) @@ -508,11 +505,19 @@ namespace ICSharpCode.ILSpy treeView.Root = assemblyListTreeNode; if (assemblyList.ListName == AssemblyListManager.DefaultListName) +#if DEBUG + this.Title = $"ILSpy {RevisionClass.FullVersion}"; +#else this.Title = "ILSpy"; +#endif else +#if DEBUG + this.Title = $"ILSpy {RevisionClass.FullVersion} - " + assemblyList.ListName; +#else this.Title = "ILSpy - " + assemblyList.ListName; +#endif } - + void assemblyList_Assemblies_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Reset) { From ecde53969c4159bae3645e8281e9dd82a9944672 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 26 Jan 2019 09:27:23 +0100 Subject: [PATCH 22/26] Add IsInConstructorInitializer case to ILInlining.OptionsForBlock. --- ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs | 11 +++++++++-- .../IL/Transforms/NamedArgumentTransform.cs | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs b/ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs index b4409d250..099c41d38 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs @@ -52,14 +52,21 @@ namespace ICSharpCode.Decompiler.IL.Transforms public void Run(Block block, int pos, StatementTransformContext context) { - InlineOneIfPossible(block, pos, OptionsForBlock(block), context: context); + InlineOneIfPossible(block, pos, OptionsForBlock(block, pos), context: context); } - internal static InliningOptions OptionsForBlock(Block block) + internal static InliningOptions OptionsForBlock(Block block, int pos) { InliningOptions options = InliningOptions.None; if (IsCatchWhenBlock(block)) options |= InliningOptions.Aggressive; + else { + var function = block.Ancestors.OfType().FirstOrDefault(); + var inst = block.Instructions[pos]; + int? ctorCallStart = null; + if (IsInConstructorInitializer(function, inst, ref ctorCallStart)) + options |= InliningOptions.Aggressive; + } return options; } diff --git a/ICSharpCode.Decompiler/IL/Transforms/NamedArgumentTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/NamedArgumentTransform.cs index a9627c68b..cb22e437e 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/NamedArgumentTransform.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/NamedArgumentTransform.cs @@ -103,7 +103,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms { if (!context.Settings.NamedArguments) return; - var options = ILInlining.OptionsForBlock(block); + var options = ILInlining.OptionsForBlock(block, pos); options |= InliningOptions.IntroduceNamedArguments; ILInlining.InlineOneIfPossible(block, pos, options, context: context); } From 04910a8eb4192f3fc681246f2caa7df02ae54064 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 26 Jan 2019 09:32:45 +0100 Subject: [PATCH 23/26] TypeSystemAstBuilder: Do not create references to System.MathF, if PI or E are not defined. --- .../CSharp/Syntax/TypeSystemAstBuilder.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs index 49d2db93a..17dac186b 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs @@ -970,9 +970,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax IType mathType; if (isDouble) mathType = compilation.FindType(typeof(Math)); - else - mathType = compilation.FindType(new TopLevelTypeName("System", "MathF")).GetDefinition() - ?? compilation.FindType(typeof(Math)); + else { + mathType = compilation.FindType(new TopLevelTypeName("System", "MathF")).GetDefinition(); + if (mathType == null || !mathType.GetFields(f => f.Name == "PI" && f.IsConst).Any() || !mathType.GetFields(f => f.Name == "E" && f.IsConst).Any()) + mathType = compilation.FindType(typeof(Math)); + } expr = TryExtractExpression(mathType, type, constantValue, "PI", isDouble) ?? TryExtractExpression(mathType, type, constantValue, "E", isDouble); From af4dd6e9e39b59fb71ad71ec11ad423e83ab8448 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 26 Jan 2019 09:36:34 +0100 Subject: [PATCH 24/26] Fix DecompilerTypeSystem: struct is never null. --- ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs b/ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs index 71bc5a4e7..251050bda 100644 --- a/ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs +++ b/ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs @@ -205,10 +205,10 @@ namespace ICSharpCode.Decompiler.TypeSystem bool HasType(KnownTypeCode code) { TopLevelTypeName name = KnownTypeReference.Get(code).TypeName; - if (mainModule.GetTypeDefinition(name) != null) + if (!mainModule.GetTypeDefinition(name).IsNil) return true; foreach (var file in referencedAssemblies) { - if (file.GetTypeDefinition(name) != null) + if (!file.GetTypeDefinition(name).IsNil) return true; } return false; From deeb603fd78fe0b5eb22cec60762853054a3695b Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 26 Jan 2019 15:12:37 +0100 Subject: [PATCH 25/26] Fix #1395: do-while loop missing entry-point label. --- .../TestCases/Pretty/Loops.cs | 49 +++++++ .../TestCases/Pretty/Loops.il | 121 +++++++++++++++++ .../TestCases/Pretty/Loops.mcs.il | 92 +++++++++++++ .../TestCases/Pretty/Loops.opt.il | 88 +++++++++++++ .../TestCases/Pretty/Loops.opt.mcs.il | 92 +++++++++++++ .../TestCases/Pretty/Loops.opt.roslyn.il | 85 ++++++++++++ .../TestCases/Pretty/Loops.roslyn.il | 122 ++++++++++++++++++ .../CSharp/StatementBuilder.cs | 10 +- .../IL/Transforms/HighLevelLoopTransform.cs | 8 +- 9 files changed, 661 insertions(+), 6 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs index 1631e8bba..0a76c7b48 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs @@ -715,6 +715,55 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty Console.WriteLine("End of method"); } + public void Issue1395(int count) + { + Environment.GetCommandLineArgs(); + for (int i = 0; i < count; i++) { + Environment.GetCommandLineArgs(); + do { +#if OPT || MCS + IL_0013: +#else + IL_0016: +#endif + Environment.GetCommandLineArgs(); + if (Condition("part1")) { + Environment.GetEnvironmentVariables(); + if (Condition("restart")) { +#if OPT || MCS + goto IL_0013; +#else + goto IL_0016; +#endif + } + } else { + Environment.GetLogicalDrives(); + } + Environment.GetCommandLineArgs(); + while (count > 0) { + switch (count) { + case 0: + case 1: + case 2: + Environment.GetCommandLineArgs(); + break; + case 3: + case 5: + case 6: + Environment.GetEnvironmentVariables(); + break; + default: + Environment.GetLogicalDrives(); + break; + } + } + count++; + } while (Condition("do-while")); + Environment.GetCommandLineArgs(); + } + Environment.GetCommandLineArgs(); + } + public void ForLoop() { Console.WriteLine("Initial"); diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.il index 74e00afb6..cef7a70f6 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.il @@ -2681,6 +2681,127 @@ IL_0098: ret } // end of method Loops::DoWhileLoop + .method public hidebysig instance void + Issue1395(int32 count) cil managed + { + // Code size 218 (0xda) + .maxstack 2 + .locals init (int32 V_0, + bool V_1, + int32 V_2) + IL_0000: nop + IL_0001: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0006: pop + IL_0007: ldc.i4.0 + IL_0008: stloc.0 + IL_0009: br IL_00c8 + + IL_000e: nop + IL_000f: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0014: pop + IL_0015: nop + IL_0016: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_001b: pop + IL_001c: ldarg.0 + IL_001d: ldstr "part1" + IL_0022: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_0027: ldc.i4.0 + IL_0028: ceq + IL_002a: stloc.1 + IL_002b: ldloc.1 + IL_002c: brtrue.s IL_004d + + IL_002e: nop + IL_002f: call class [mscorlib]System.Collections.IDictionary [mscorlib]System.Environment::GetEnvironmentVariables() + IL_0034: pop + IL_0035: ldarg.0 + IL_0036: ldstr "restart" + IL_003b: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_0040: ldc.i4.0 + IL_0041: ceq + IL_0043: stloc.1 + IL_0044: ldloc.1 + IL_0045: brtrue.s IL_004a + + IL_0047: nop + IL_0048: br.s IL_0016 + + IL_004a: nop + IL_004b: br.s IL_0055 + + IL_004d: nop + IL_004e: call string[] [mscorlib]System.Environment::GetLogicalDrives() + IL_0053: pop + IL_0054: nop + IL_0055: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_005a: pop + IL_005b: br.s IL_009d + + IL_005d: nop + IL_005e: ldarg.1 + IL_005f: stloc.2 + IL_0060: ldloc.2 + IL_0061: switch ( + IL_0084, + IL_0084, + IL_0084, + IL_008c, + IL_0094, + IL_008c, + IL_008c) + IL_0082: br.s IL_0094 + + IL_0084: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0089: pop + IL_008a: br.s IL_009c + + IL_008c: call class [mscorlib]System.Collections.IDictionary [mscorlib]System.Environment::GetEnvironmentVariables() + IL_0091: pop + IL_0092: br.s IL_009c + + IL_0094: call string[] [mscorlib]System.Environment::GetLogicalDrives() + IL_0099: pop + IL_009a: br.s IL_009c + + IL_009c: nop + IL_009d: ldarg.1 + IL_009e: ldc.i4.0 + IL_009f: cgt + IL_00a1: stloc.1 + IL_00a2: ldloc.1 + IL_00a3: brtrue.s IL_005d + + IL_00a5: ldarg.1 + IL_00a6: ldc.i4.1 + IL_00a7: add + IL_00a8: starg.s count + IL_00aa: nop + IL_00ab: ldarg.0 + IL_00ac: ldstr "do-while" + IL_00b1: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_00b6: stloc.1 + IL_00b7: ldloc.1 + IL_00b8: brtrue IL_0015 + + IL_00bd: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_00c2: pop + IL_00c3: nop + IL_00c4: ldloc.0 + IL_00c5: ldc.i4.1 + IL_00c6: add + IL_00c7: stloc.0 + IL_00c8: ldloc.0 + IL_00c9: ldarg.1 + IL_00ca: clt + IL_00cc: stloc.1 + IL_00cd: ldloc.1 + IL_00ce: brtrue IL_000e + + IL_00d3: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_00d8: pop + IL_00d9: ret + } // end of method Loops::Issue1395 + .method public hidebysig instance void ForLoop() cil managed { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.mcs.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.mcs.il index 65457fe39..997475058 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.mcs.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.mcs.il @@ -1904,6 +1904,98 @@ IL_008c: ret } // end of method Loops::DoWhileLoop + .method public hidebysig instance void + Issue1395(int32 count) cil managed + { + // Code size 216 (0xd8) + .maxstack 19 + .locals init (int32 V_0, + int32 V_1) + IL_0000: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0005: pop + IL_0006: ldc.i4.0 + IL_0007: stloc.0 + IL_0008: br IL_00ca + + IL_000d: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0012: pop + IL_0013: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0018: pop + IL_0019: ldarg.0 + IL_001a: ldstr "part1" + IL_001f: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_0024: brfalse IL_0049 + + IL_0029: call class [mscorlib]System.Collections.IDictionary [mscorlib]System.Environment::GetEnvironmentVariables() + IL_002e: pop + IL_002f: ldarg.0 + IL_0030: ldstr "restart" + IL_0035: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_003a: brfalse IL_0044 + + IL_003f: br IL_0013 + + IL_0044: br IL_004f + + IL_0049: call string[] [mscorlib]System.Environment::GetLogicalDrives() + IL_004e: pop + IL_004f: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0054: pop + IL_0055: br IL_00a4 + + IL_005a: ldarg.1 + IL_005b: stloc.1 + IL_005c: ldloc.1 + IL_005d: switch ( + IL_0083, + IL_0083, + IL_0083, + IL_008e, + IL_0099, + IL_008e, + IL_008e) + IL_007e: br IL_0099 + + IL_0083: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0088: pop + IL_0089: br IL_00a4 + + IL_008e: call class [mscorlib]System.Collections.IDictionary [mscorlib]System.Environment::GetEnvironmentVariables() + IL_0093: pop + IL_0094: br IL_00a4 + + IL_0099: call string[] [mscorlib]System.Environment::GetLogicalDrives() + IL_009e: pop + IL_009f: br IL_00a4 + + IL_00a4: ldarg.1 + IL_00a5: ldc.i4.0 + IL_00a6: bgt IL_005a + + IL_00ab: ldarg.1 + IL_00ac: ldc.i4.1 + IL_00ad: add + IL_00ae: starg.s count + IL_00b0: ldarg.0 + IL_00b1: ldstr "do-while" + IL_00b6: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_00bb: brtrue IL_0013 + + IL_00c0: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_00c5: pop + IL_00c6: ldloc.0 + IL_00c7: ldc.i4.1 + IL_00c8: add + IL_00c9: stloc.0 + IL_00ca: ldloc.0 + IL_00cb: ldarg.1 + IL_00cc: blt IL_000d + + IL_00d1: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_00d6: pop + IL_00d7: ret + } // end of method Loops::Issue1395 + .method public hidebysig instance void ForLoop() cil managed { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.il index 204ad1436..57adc4f97 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.il @@ -2067,6 +2067,94 @@ IL_0073: ret } // end of method Loops::DoWhileLoop + .method public hidebysig instance void + Issue1395(int32 count) cil managed + { + // Code size 182 (0xb6) + .maxstack 2 + .locals init (int32 V_0, + int32 V_1) + IL_0000: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0005: pop + IL_0006: ldc.i4.0 + IL_0007: stloc.0 + IL_0008: br IL_00a8 + + IL_000d: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0012: pop + IL_0013: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0018: pop + IL_0019: ldarg.0 + IL_001a: ldstr "part1" + IL_001f: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_0024: brfalse.s IL_003b + + IL_0026: call class [mscorlib]System.Collections.IDictionary [mscorlib]System.Environment::GetEnvironmentVariables() + IL_002b: pop + IL_002c: ldarg.0 + IL_002d: ldstr "restart" + IL_0032: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_0037: brfalse.s IL_0041 + + IL_0039: br.s IL_0013 + + IL_003b: call string[] [mscorlib]System.Environment::GetLogicalDrives() + IL_0040: pop + IL_0041: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0046: pop + IL_0047: br.s IL_0085 + + IL_0049: ldarg.1 + IL_004a: stloc.1 + IL_004b: ldloc.1 + IL_004c: switch ( + IL_006f, + IL_006f, + IL_006f, + IL_0077, + IL_007f, + IL_0077, + IL_0077) + IL_006d: br.s IL_007f + + IL_006f: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0074: pop + IL_0075: br.s IL_0085 + + IL_0077: call class [mscorlib]System.Collections.IDictionary [mscorlib]System.Environment::GetEnvironmentVariables() + IL_007c: pop + IL_007d: br.s IL_0085 + + IL_007f: call string[] [mscorlib]System.Environment::GetLogicalDrives() + IL_0084: pop + IL_0085: ldarg.1 + IL_0086: ldc.i4.0 + IL_0087: bgt.s IL_0049 + + IL_0089: ldarg.1 + IL_008a: ldc.i4.1 + IL_008b: add + IL_008c: starg.s count + IL_008e: ldarg.0 + IL_008f: ldstr "do-while" + IL_0094: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_0099: brtrue IL_0013 + + IL_009e: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_00a3: pop + IL_00a4: ldloc.0 + IL_00a5: ldc.i4.1 + IL_00a6: add + IL_00a7: stloc.0 + IL_00a8: ldloc.0 + IL_00a9: ldarg.1 + IL_00aa: blt IL_000d + + IL_00af: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_00b4: pop + IL_00b5: ret + } // end of method Loops::Issue1395 + .method public hidebysig instance void ForLoop() cil managed { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.mcs.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.mcs.il index 32a7b66a2..3b1f28262 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.mcs.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.mcs.il @@ -1904,6 +1904,98 @@ IL_008c: ret } // end of method Loops::DoWhileLoop + .method public hidebysig instance void + Issue1395(int32 count) cil managed + { + // Code size 216 (0xd8) + .maxstack 19 + .locals init (int32 V_0, + int32 V_1) + IL_0000: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0005: pop + IL_0006: ldc.i4.0 + IL_0007: stloc.0 + IL_0008: br IL_00ca + + IL_000d: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0012: pop + IL_0013: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0018: pop + IL_0019: ldarg.0 + IL_001a: ldstr "part1" + IL_001f: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_0024: brfalse IL_0049 + + IL_0029: call class [mscorlib]System.Collections.IDictionary [mscorlib]System.Environment::GetEnvironmentVariables() + IL_002e: pop + IL_002f: ldarg.0 + IL_0030: ldstr "restart" + IL_0035: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_003a: brfalse IL_0044 + + IL_003f: br IL_0013 + + IL_0044: br IL_004f + + IL_0049: call string[] [mscorlib]System.Environment::GetLogicalDrives() + IL_004e: pop + IL_004f: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0054: pop + IL_0055: br IL_00a4 + + IL_005a: ldarg.1 + IL_005b: stloc.1 + IL_005c: ldloc.1 + IL_005d: switch ( + IL_0083, + IL_0083, + IL_0083, + IL_008e, + IL_0099, + IL_008e, + IL_008e) + IL_007e: br IL_0099 + + IL_0083: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0088: pop + IL_0089: br IL_00a4 + + IL_008e: call class [mscorlib]System.Collections.IDictionary [mscorlib]System.Environment::GetEnvironmentVariables() + IL_0093: pop + IL_0094: br IL_00a4 + + IL_0099: call string[] [mscorlib]System.Environment::GetLogicalDrives() + IL_009e: pop + IL_009f: br IL_00a4 + + IL_00a4: ldarg.1 + IL_00a5: ldc.i4.0 + IL_00a6: bgt IL_005a + + IL_00ab: ldarg.1 + IL_00ac: ldc.i4.1 + IL_00ad: add + IL_00ae: starg.s count + IL_00b0: ldarg.0 + IL_00b1: ldstr "do-while" + IL_00b6: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_00bb: brtrue IL_0013 + + IL_00c0: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_00c5: pop + IL_00c6: ldloc.0 + IL_00c7: ldc.i4.1 + IL_00c8: add + IL_00c9: stloc.0 + IL_00ca: ldloc.0 + IL_00cb: ldarg.1 + IL_00cc: blt IL_000d + + IL_00d1: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_00d6: pop + IL_00d7: ret + } // end of method Loops::Issue1395 + .method public hidebysig instance void ForLoop() cil managed { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.roslyn.il index 02ccb1df7..4ab077d02 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.roslyn.il @@ -2011,6 +2011,91 @@ IL_0073: ret } // end of method Loops::DoWhileLoop + .method public hidebysig instance void + Issue1395(int32 count) cil managed + { + // Code size 180 (0xb4) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0005: pop + IL_0006: ldc.i4.0 + IL_0007: stloc.0 + IL_0008: br IL_00a6 + + IL_000d: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0012: pop + IL_0013: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0018: pop + IL_0019: ldarg.0 + IL_001a: ldstr "part1" + IL_001f: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_0024: brfalse.s IL_003b + + IL_0026: call class [mscorlib]System.Collections.IDictionary [mscorlib]System.Environment::GetEnvironmentVariables() + IL_002b: pop + IL_002c: ldarg.0 + IL_002d: ldstr "restart" + IL_0032: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_0037: brfalse.s IL_0041 + + IL_0039: br.s IL_0013 + + IL_003b: call string[] [mscorlib]System.Environment::GetLogicalDrives() + IL_0040: pop + IL_0041: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0046: pop + IL_0047: br.s IL_0083 + + IL_0049: ldarg.1 + IL_004a: switch ( + IL_006d, + IL_006d, + IL_006d, + IL_0075, + IL_007d, + IL_0075, + IL_0075) + IL_006b: br.s IL_007d + + IL_006d: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0072: pop + IL_0073: br.s IL_0083 + + IL_0075: call class [mscorlib]System.Collections.IDictionary [mscorlib]System.Environment::GetEnvironmentVariables() + IL_007a: pop + IL_007b: br.s IL_0083 + + IL_007d: call string[] [mscorlib]System.Environment::GetLogicalDrives() + IL_0082: pop + IL_0083: ldarg.1 + IL_0084: ldc.i4.0 + IL_0085: bgt.s IL_0049 + + IL_0087: ldarg.1 + IL_0088: ldc.i4.1 + IL_0089: add + IL_008a: starg.s count + IL_008c: ldarg.0 + IL_008d: ldstr "do-while" + IL_0092: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_0097: brtrue IL_0013 + + IL_009c: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_00a1: pop + IL_00a2: ldloc.0 + IL_00a3: ldc.i4.1 + IL_00a4: add + IL_00a5: stloc.0 + IL_00a6: ldloc.0 + IL_00a7: ldarg.1 + IL_00a8: blt IL_000d + + IL_00ad: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_00b2: pop + IL_00b3: ret + } // end of method Loops::Issue1395 + .method public hidebysig instance void ForLoop() cil managed { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.roslyn.il index 5bb292564..90028e792 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.roslyn.il @@ -2508,6 +2508,128 @@ IL_0094: ret } // end of method Loops::DoWhileLoop + .method public hidebysig instance void + Issue1395(int32 count) cil managed + { + // Code size 219 (0xdb) + .maxstack 2 + .locals init (int32 V_0, + bool V_1, + bool V_2, + int32 V_3, + bool V_4, + bool V_5, + bool V_6) + IL_0000: nop + IL_0001: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0006: pop + IL_0007: ldc.i4.0 + IL_0008: stloc.0 + IL_0009: br IL_00c7 + + IL_000e: nop + IL_000f: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0014: pop + IL_0015: nop + IL_0016: nop + IL_0017: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_001c: pop + IL_001d: ldarg.0 + IL_001e: ldstr "part1" + IL_0023: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_0028: stloc.1 + IL_0029: ldloc.1 + IL_002a: brfalse.s IL_0048 + + IL_002c: nop + IL_002d: call class [mscorlib]System.Collections.IDictionary [mscorlib]System.Environment::GetEnvironmentVariables() + IL_0032: pop + IL_0033: ldarg.0 + IL_0034: ldstr "restart" + IL_0039: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_003e: stloc.2 + IL_003f: ldloc.2 + IL_0040: brfalse.s IL_0045 + + IL_0042: nop + IL_0043: br.s IL_0016 + + IL_0045: nop + IL_0046: br.s IL_0050 + + IL_0048: nop + IL_0049: call string[] [mscorlib]System.Environment::GetLogicalDrives() + IL_004e: pop + IL_004f: nop + IL_0050: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0055: pop + IL_0056: br.s IL_0098 + + IL_0058: nop + IL_0059: ldarg.1 + IL_005a: stloc.3 + IL_005b: ldloc.3 + IL_005c: switch ( + IL_007f, + IL_007f, + IL_007f, + IL_0087, + IL_008f, + IL_0087, + IL_0087) + IL_007d: br.s IL_008f + + IL_007f: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_0084: pop + IL_0085: br.s IL_0097 + + IL_0087: call class [mscorlib]System.Collections.IDictionary [mscorlib]System.Environment::GetEnvironmentVariables() + IL_008c: pop + IL_008d: br.s IL_0097 + + IL_008f: call string[] [mscorlib]System.Environment::GetLogicalDrives() + IL_0094: pop + IL_0095: br.s IL_0097 + + IL_0097: nop + IL_0098: ldarg.1 + IL_0099: ldc.i4.0 + IL_009a: cgt + IL_009c: stloc.s V_4 + IL_009e: ldloc.s V_4 + IL_00a0: brtrue.s IL_0058 + + IL_00a2: ldarg.1 + IL_00a3: ldc.i4.1 + IL_00a4: add + IL_00a5: starg.s count + IL_00a7: nop + IL_00a8: ldarg.0 + IL_00a9: ldstr "do-while" + IL_00ae: call instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Condition(string) + IL_00b3: stloc.s V_5 + IL_00b5: ldloc.s V_5 + IL_00b7: brtrue IL_0015 + + IL_00bc: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_00c1: pop + IL_00c2: nop + IL_00c3: ldloc.0 + IL_00c4: ldc.i4.1 + IL_00c5: add + IL_00c6: stloc.0 + IL_00c7: ldloc.0 + IL_00c8: ldarg.1 + IL_00c9: clt + IL_00cb: stloc.s V_6 + IL_00cd: ldloc.s V_6 + IL_00cf: brtrue IL_000e + + IL_00d4: call string[] [mscorlib]System.Environment::GetCommandLineArgs() + IL_00d9: pop + IL_00da: ret + } // end of method Loops::Issue1395 + .method public hidebysig instance void ForLoop() cil managed { diff --git a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs index 42eb1dd12..2a8b12a24 100644 --- a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs @@ -858,12 +858,18 @@ namespace ICSharpCode.Decompiler.CSharp if (!container.MatchConditionBlock(continueTarget, out condition, out _)) throw new NotSupportedException("Invalid condition block in do-while loop."); blockStatement = ConvertBlockContainer(new BlockStatement(), container, container.Blocks.SkipLast(1), true); - if (continueTarget.IncomingEdgeCount == continueCount) { - // Remove the entrypoint label if all jumps to the label were replaced with 'continue;' statements + if (container.EntryPoint.IncomingEdgeCount == 2) { + // Remove the entry-point label, if there are only two jumps to the entry-point: + // from outside the loop and from the condition-block. blockStatement.Statements.First().Remove(); } if (blockStatement.LastOrDefault() is ContinueStatement continueStmt3) continueStmt3.Remove(); + if (continueTarget.IncomingEdgeCount > continueCount) { + // if there are branches to the condition block, that were not converted + // to continue statements, we have to introduce an extra label. + blockStatement.Add(new LabelStatement { Label = continueTarget.Label }); + } if (blockStatement.Statements.Count == 0) { return new WhileStatement { Condition = exprBuilder.TranslateCondition(condition), diff --git a/ICSharpCode.Decompiler/IL/Transforms/HighLevelLoopTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/HighLevelLoopTransform.cs index ba119c84d..d9afadd56 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/HighLevelLoopTransform.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/HighLevelLoopTransform.cs @@ -82,7 +82,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms ConditionDetection.InvertIf(loopBody, ifInstruction, context); } - context.Step("Transform to while (condition) loop", loop); + context.Step("Transform to while (condition) loop: " + loop.EntryPoint.Label, loop); loop.Kind = ContainerKind.While; //invert comparison ifInstruction.Condition = Comp.LogicNot(ifInstruction.Condition); @@ -150,7 +150,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms // not a do-while loop, exit. if (conditions == null || conditions.Count == 0) return false; - context.Step("Transform to do-while loop", loop); + context.Step("Transform to do-while loop: " + loop.EntryPoint.Label, loop); Block conditionBlock; // first we remove all extracted instructions from the original block. var originalBlock = (Block)exit.Parent; @@ -358,7 +358,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms // - increment block if (incrementBlock.Instructions.Count <= 1 || loop.Blocks.Count < 3) return false; - context.Step("Transform to for loop", loop); + context.Step("Transform to for loop: " + loop.EntryPoint.Label, loop); // move the block to the end of the loop: loop.Blocks.MoveElementToEnd(incrementBlock); loop.Kind = ContainerKind.For; @@ -398,7 +398,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms } if (numberOfConditions == 0) return false; - context.Step("Transform to for loop", loop); + context.Step("Transform to for loop: " + loop.EntryPoint.Label, loop); // split condition block: whileCondition.ReplaceWith(forCondition); ExpressionTransforms.RunOnSingleStatement(forCondition, context); From 9d19b33ec0e8f9ad83738f42afabe54d419114a8 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 26 Jan 2019 15:31:47 +0100 Subject: [PATCH 26/26] Fix #1394: Fields marked 'specialname' are excluded from the type system --- .../TypeSystem/TypeSystemLoaderTests.cs | 10 +++++++++- ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs | 4 +++- .../Implementation/MetadataTypeDefinition.cs | 2 +- ILSpy/TreeNodes/TypeTreeNode.cs | 12 +++++++++--- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs b/ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs index 2b23df55a..dc7d6bad1 100644 --- a/ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs +++ b/ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs @@ -488,9 +488,17 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem public void EnumFieldsTest() { var e = GetTypeDefinition(typeof(MyEnum)); - IField[] fields = e.Fields.ToArray(); + IField valueField = e.Fields.First(); + IField[] fields = e.Fields.Skip(1).ToArray(); Assert.AreEqual(5, fields.Length); + Assert.AreEqual("value__", valueField.Name); + Assert.AreEqual(GetTypeDefinition(typeof(short)), valueField.Type); + Assert.AreEqual(Accessibility.Public, valueField.Accessibility); + Assert.AreEqual(null, valueField.GetConstantValue()); + Assert.IsFalse(valueField.IsConst); + Assert.IsFalse(valueField.IsStatic); + foreach (IField f in fields) { Assert.IsTrue(f.IsStatic); Assert.IsTrue(f.IsConst); diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs index 60c9f518b..d61c36f75 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs @@ -951,6 +951,8 @@ namespace ICSharpCode.Decompiler.CSharp } foreach (var field in typeDef.Fields) { if (!field.MetadataToken.IsNil && !MemberIsHidden(module.PEFile, field.MetadataToken, settings)) { + if (typeDef.Kind == TypeKind.Enum && !field.IsConst) + continue; var memberDecl = DoDecompile(field, decompileRun, decompilationContext.WithCurrentMember(field)); typeDecl.Members.Add(memberDecl); } @@ -1262,7 +1264,7 @@ namespace ICSharpCode.Decompiler.CSharp Debug.Assert(decompilationContext.CurrentMember == field); try { var typeSystemAstBuilder = CreateAstBuilder(decompilationContext); - if (decompilationContext.CurrentTypeDefinition.Kind == TypeKind.Enum) { + if (decompilationContext.CurrentTypeDefinition.Kind == TypeKind.Enum && field.IsConst) { var enumDec = new EnumMemberDeclaration { Name = field.Name }; object constantValue = field.GetConstantValue(); if (constantValue != null) { diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataTypeDefinition.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataTypeDefinition.cs index d053a6bdb..f4bd17efb 100644 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataTypeDefinition.cs +++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataTypeDefinition.cs @@ -162,7 +162,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation foreach (FieldDefinitionHandle h in fieldCollection) { var field = metadata.GetFieldDefinition(h); var attr = field.Attributes; - if (module.IsVisible(attr) && (attr & FieldAttributes.SpecialName) == 0) { + if (module.IsVisible(attr)) { fieldList.Add(module.GetDefinition(h)); } } diff --git a/ILSpy/TreeNodes/TypeTreeNode.cs b/ILSpy/TreeNodes/TypeTreeNode.cs index 6f1c394ec..3ef91c411 100644 --- a/ILSpy/TreeNodes/TypeTreeNode.cs +++ b/ILSpy/TreeNodes/TypeTreeNode.cs @@ -79,10 +79,16 @@ namespace ICSharpCode.ILSpy.TreeNodes foreach (var nestedType in TypeDefinition.NestedTypes.OrderBy(t => t.Name, NaturalStringComparer.Instance)) { this.Children.Add(new TypeTreeNode(nestedType, ParentAssemblyNode)); } - foreach (var field in TypeDefinition.Fields.OrderBy(f => f.Name, NaturalStringComparer.Instance)) { - this.Children.Add(new FieldTreeNode(field)); + if (TypeDefinition.Kind == TypeKind.Enum) { + // if the type is an enum, it's better to not sort by field name. + foreach (var field in TypeDefinition.Fields) { + this.Children.Add(new FieldTreeNode(field)); + } + } else { + foreach (var field in TypeDefinition.Fields.OrderBy(f => f.Name, NaturalStringComparer.Instance)) { + this.Children.Add(new FieldTreeNode(field)); + } } - foreach (var property in TypeDefinition.Properties.OrderBy(p => p.Name, NaturalStringComparer.Instance)) { this.Children.Add(new PropertyTreeNode(property)); }