From 23c7a8a46e5aa1a0cd302e4cd3eb578265e2bec7 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 31 Oct 2017 13:18:23 +0100 Subject: [PATCH 1/3] Fix #953: Missing nullable specifier for array initializer --- .../TestCases/Correctness/InitializerTests.cs | 58 +++++++++++++++++++ .../TestCases/Pretty/InitializerTests.cs | 12 ++++ .../TestCases/Pretty/InitializerTests.il | 50 ++++++++++++---- .../TestCases/Pretty/InitializerTests.opt.il | 38 ++++++++++-- .../Pretty/InitializerTests.opt.roslyn.il | 40 ++++++++++--- .../Pretty/InitializerTests.roslyn.il | 52 ++++++++++++----- .../CSharp/ExpressionBuilder.cs | 6 +- 7 files changed, 215 insertions(+), 41 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/InitializerTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/InitializerTests.cs index c975fa00a..f76e44372 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/InitializerTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/InitializerTests.cs @@ -194,6 +194,64 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness }); } + public static void NestedNullableArray(int a, int b, int c) + { + InitializerTests.X(InitializerTests.Y(), new int?[][] + { + new int?[] + { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + null + }, + new int?[] + { + a, + b, + c, + null + }, + new int?[] + { + 1, + 2, + 3, + 4, + 5, + 6, + null + } + }); + } + public unsafe static void NestedPointerArray(int a, int b, int c) + { + InitializerTests.X(InitializerTests.Y(), new void*[][] + { + new void*[] + { + null + }, + new void*[] + { + (void*)200, + null + }, + new void*[] + { + (void*)100, + null + } + }); + } + public static void ArrayBoolean() { InitializerTests.X(InitializerTests.Y(), new bool[] diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs index e272fcd9c..6f095f0fb 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs @@ -344,6 +344,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty return "Test"; } + private static void NoOp(Guid?[] array) + { + + } + #if !LEGACY_CSC public static void SimpleDictInitializer() { @@ -480,5 +485,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty } }); } + + public static void Bug953_MissingNullableSpecifierForArrayInitializer() + { + InitializerTests.NoOp(new Guid?[1] { + Guid.Empty + }); + } } } \ 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 04af92cf4..576d1b39b 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il @@ -1,6 +1,6 @@ // Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 -// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. +// Copyright (c) Microsoft Corporation. All rights reserved. @@ -15,7 +15,7 @@ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 4:0:0:0 } -.assembly n0iwoj0v +.assembly '31sn40gd' { .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 @@ -25,15 +25,15 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 } -.module n0iwoj0v.dll -// MVID: {04AC1961-FA71-4E8B-A77B-45FF217A617C} +.module '31sn40gd.dll' +// MVID: {EE7CB403-8040-4C94-B17A-F697CE60CA23} .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .imagebase 0x10000000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY -// Image base: 0x009A0000 +// Image base: 0x02FB0000 // =============== CLASS MEMBERS DECLARATION =================== @@ -1172,6 +1172,14 @@ IL_000a: ret } // end of method InitializerTests::GetString + .method private hidebysig static void NoOp(valuetype [mscorlib]System.Nullable`1[] 'array') cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method InitializerTests::NoOp + .method public hidebysig static void ObjectInitializerWithInitializationOfDeeplyNestedObjects() cil managed { // Code size 84 (0x54) @@ -1474,6 +1482,27 @@ IL_007f: ret } // end of method InitializerTests::Bug270_NestedInitialisers + .method public hidebysig static void Bug953_MissingNullableSpecifierForArrayInitializer() cil managed + { + // Code size 38 (0x26) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1[] V_0) + IL_0000: nop + IL_0001: ldc.i4.1 + IL_0002: newarr valuetype [mscorlib]System.Nullable`1 + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldc.i4.0 + IL_000a: ldelema valuetype [mscorlib]System.Nullable`1 + IL_000f: ldsfld valuetype [mscorlib]System.Guid [mscorlib]System.Guid::Empty + IL_0014: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0019: stobj valuetype [mscorlib]System.Nullable`1 + IL_001e: ldloc.0 + IL_001f: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::NoOp(valuetype [mscorlib]System.Nullable`1[]) + IL_0024: nop + IL_0025: ret + } // end of method InitializerTests::Bug953_MissingNullableSpecifierForArrayInitializer + .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { @@ -1488,11 +1517,12 @@ class [mscorlib]System.EventArgs e) cil managed { .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - // Code size 7 (0x7) + // Code size 8 (0x8) .maxstack 8 - IL_0000: call void [mscorlib]System.Console::WriteLine() - IL_0005: nop - IL_0006: ret + IL_0000: nop + IL_0001: call void [mscorlib]System.Console::WriteLine() + IL_0006: nop + IL_0007: ret } // end of method InitializerTests::'b__7' .method private hidebysig static bool 'b__1b'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed @@ -1519,4 +1549,4 @@ // ============================================================= // *********** DISASSEMBLY COMPLETE *********************** -// Warnung: Win32-Ressourcendatei "../../../TestCases/Pretty\InitializerTests.res" wurde erstellt. +// WARNING: Created Win32 resource file ../../../TestCases/Pretty\InitializerTests.res diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il index bf86fbc0c..05f0d4bdd 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il @@ -1,6 +1,6 @@ // Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 -// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. +// Copyright (c) Microsoft Corporation. All rights reserved. @@ -15,7 +15,7 @@ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 4:0:0:0 } -.assembly mo2wq1js +.assembly awwuldf0 { .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 @@ -25,15 +25,15 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 } -.module mo2wq1js.dll -// MVID: {99F5978B-D68E-4578-9D8F-7D47C1F63A30} +.module awwuldf0.dll +// MVID: {59891EFA-EBA3-4F9A-9034-4F24037CEC15} .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .imagebase 0x10000000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY -// Image base: 0x027A0000 +// Image base: 0x03070000 // =============== CLASS MEMBERS DECLARATION =================== @@ -981,6 +981,13 @@ IL_0005: ret } // end of method InitializerTests::GetString + .method private hidebysig static void NoOp(valuetype [mscorlib]System.Nullable`1[] 'array') cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method InitializerTests::NoOp + .method public hidebysig static void ObjectInitializerWithInitializationOfDeeplyNestedObjects() cil managed { // Code size 79 (0x4f) @@ -1239,6 +1246,25 @@ IL_0076: ret } // end of method InitializerTests::Bug270_NestedInitialisers + .method public hidebysig static void Bug953_MissingNullableSpecifierForArrayInitializer() cil managed + { + // Code size 36 (0x24) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1[] V_0) + IL_0000: ldc.i4.1 + IL_0001: newarr valuetype [mscorlib]System.Nullable`1 + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldc.i4.0 + IL_0009: ldelema valuetype [mscorlib]System.Nullable`1 + IL_000e: ldsfld valuetype [mscorlib]System.Guid [mscorlib]System.Guid::Empty + IL_0013: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0018: stobj valuetype [mscorlib]System.Nullable`1 + IL_001d: ldloc.0 + IL_001e: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::NoOp(valuetype [mscorlib]System.Nullable`1[]) + IL_0023: ret + } // end of method InitializerTests::Bug953_MissingNullableSpecifierForArrayInitializer + .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { @@ -1278,4 +1304,4 @@ // ============================================================= // *********** DISASSEMBLY COMPLETE *********************** -// Warnung: Win32-Ressourcendatei "../../../TestCases/Pretty\InitializerTests.opt.res" wurde erstellt. +// WARNING: Created Win32 resource file ../../../TestCases/Pretty\InitializerTests.opt.res diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il index 22e3c0319..72b5a9640 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il @@ -1,6 +1,6 @@ // Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 -// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. +// Copyright (c) Microsoft Corporation. All rights reserved. @@ -30,14 +30,14 @@ .ver 0:0:0:0 } .module InitializerTests.dll -// MVID: {1A200C9E-AB38-4402-A1D6-E7C3307A45E2} +// MVID: {8AE31202-72A4-4C73-86BF-EE49F9DE8C56} .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .imagebase 0x10000000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY -// Image base: 0x02C80000 +// Image base: 0x02EC0000 // =============== CLASS MEMBERS DECLARATION =================== @@ -504,7 +504,7 @@ .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .field public static initonly class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c' '<>9' .field public static class [mscorlib]System.EventHandler '<>9__23_0' - .field public static class [mscorlib]System.Func`2 '<>9__41_0' + .field public static class [mscorlib]System.Func`2 '<>9__42_0' .method private hidebysig specialname rtspecialname static void .cctor() cil managed { @@ -536,7 +536,7 @@ } // end of method '<>c'::'b__23_0' .method assembly hidebysig instance bool - 'b__41_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed + 'b__42_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed { // Code size 17 (0x11) .maxstack 8 @@ -546,7 +546,7 @@ IL_000b: call bool [mscorlib]System.String::op_Equality(string, string) IL_0010: ret - } // end of method '<>c'::'b__41_0' + } // end of method '<>c'::'b__42_0' } // end of class '<>c' @@ -981,6 +981,13 @@ IL_0005: ret } // end of method InitializerTests::GetString + .method private hidebysig static void NoOp(valuetype [mscorlib]System.Nullable`1[] 'array') cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method InitializerTests::NoOp + .method public hidebysig static void SimpleDictInitializer() cil managed { // Code size 41 (0x29) @@ -1275,17 +1282,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/'<>c'::'<>9__41_0' + IL_003a: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9__42_0' IL_003f: dup IL_0040: brtrue.s IL_0059 IL_0042: pop IL_0043: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9' - IL_0048: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'b__41_0'(class [mscorlib]System.Globalization.NumberFormatInfo) + IL_0048: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'b__42_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/'<>c'::'<>9__41_0' + IL_0054: stsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9__42_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) @@ -1296,6 +1303,21 @@ IL_0072: ret } // end of method InitializerTests::Bug270_NestedInitialisers + .method public hidebysig static void Bug953_MissingNullableSpecifierForArrayInitializer() cil managed + { + // Code size 29 (0x1d) + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: newarr valuetype [mscorlib]System.Nullable`1 + IL_0006: dup + IL_0007: ldc.i4.0 + IL_0008: ldsfld valuetype [mscorlib]System.Guid [mscorlib]System.Guid::Empty + IL_000d: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0012: stelem valuetype [mscorlib]System.Nullable`1 + IL_0017: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::NoOp(valuetype [mscorlib]System.Nullable`1[]) + IL_001c: ret + } // end of method InitializerTests::Bug953_MissingNullableSpecifierForArrayInitializer + .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il index 69b897be6..ced96cb2f 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il @@ -1,6 +1,6 @@ // Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 -// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. +// Copyright (c) Microsoft Corporation. All rights reserved. @@ -30,14 +30,14 @@ .ver 0:0:0:0 } .module InitializerTests.dll -// MVID: {764AEFFE-E491-413B-876B-B40EBE774D84} +// MVID: {4E6BCF8B-3662-4EB0-88AA-8085A69A4D25} .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .imagebase 0x10000000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY -// Image base: 0x00FC0000 +// Image base: 0x02C10000 // =============== CLASS MEMBERS DECLARATION =================== @@ -531,7 +531,7 @@ .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .field public static initonly class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c' '<>9' .field public static class [mscorlib]System.EventHandler '<>9__23_0' - .field public static class [mscorlib]System.Func`2 '<>9__41_0' + .field public static class [mscorlib]System.Func`2 '<>9__42_0' .method private hidebysig specialname rtspecialname static void .cctor() cil managed { @@ -557,15 +557,16 @@ 'b__23_0'(object sender, class [mscorlib]System.EventArgs e) cil managed { - // Code size 7 (0x7) + // Code size 8 (0x8) .maxstack 8 - IL_0000: call void [mscorlib]System.Console::WriteLine() - IL_0005: nop - IL_0006: ret + IL_0000: nop + IL_0001: call void [mscorlib]System.Console::WriteLine() + IL_0006: nop + IL_0007: ret } // end of method '<>c'::'b__23_0' .method assembly hidebysig instance bool - 'b__41_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed + 'b__42_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed { // Code size 17 (0x11) .maxstack 8 @@ -575,7 +576,7 @@ IL_000b: call bool [mscorlib]System.String::op_Equality(string, string) IL_0010: ret - } // end of method '<>c'::'b__41_0' + } // end of method '<>c'::'b__42_0' } // end of class '<>c' @@ -1149,6 +1150,14 @@ IL_000a: ret } // end of method InitializerTests::GetString + .method private hidebysig static void NoOp(valuetype [mscorlib]System.Nullable`1[] 'array') cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method InitializerTests::NoOp + .method public hidebysig static void SimpleDictInitializer() cil managed { // Code size 45 (0x2d) @@ -1490,17 +1499,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/'<>c'::'<>9__41_0' + IL_003e: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9__42_0' IL_0043: dup IL_0044: brtrue.s IL_005d IL_0046: pop IL_0047: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9' - IL_004c: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'b__41_0'(class [mscorlib]System.Globalization.NumberFormatInfo) + IL_004c: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'b__42_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/'<>c'::'<>9__41_0' + IL_0058: stsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9__42_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) @@ -1514,6 +1523,23 @@ IL_0079: ret } // end of method InitializerTests::Bug270_NestedInitialisers + .method public hidebysig static void Bug953_MissingNullableSpecifierForArrayInitializer() cil managed + { + // Code size 31 (0x1f) + .maxstack 8 + IL_0000: nop + IL_0001: ldc.i4.1 + IL_0002: newarr valuetype [mscorlib]System.Nullable`1 + IL_0007: dup + IL_0008: ldc.i4.0 + IL_0009: ldsfld valuetype [mscorlib]System.Guid [mscorlib]System.Guid::Empty + IL_000e: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0013: stelem valuetype [mscorlib]System.Nullable`1 + IL_0018: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::NoOp(valuetype [mscorlib]System.Nullable`1[]) + IL_001d: nop + IL_001e: ret + } // end of method InitializerTests::Bug953_MissingNullableSpecifierForArrayInitializer + .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs index db3d299dd..4443c0f27 100644 --- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs @@ -1852,9 +1852,9 @@ namespace ICSharpCode.Decompiler.CSharp additionalSpecifiers = new[] { new ArraySpecifier() }; } else { typeExpression = ConvertType(type); - if (typeExpression is ComposedType) { - additionalSpecifiers = ((ComposedType)typeExpression).ArraySpecifiers.SelectArray(a => (ArraySpecifier)a.Clone()); - typeExpression = ((ComposedType)typeExpression).BaseType.Clone(); + if (typeExpression is ComposedType compType && compType.ArraySpecifiers.Count > 0) { + additionalSpecifiers = compType.ArraySpecifiers.SelectArray(a => (ArraySpecifier)a.Clone()); + compType.ArraySpecifiers.Clear(); } else { additionalSpecifiers = NoSpecifiers; } From b3bf6258fccc170b6a1a19c64586d0dfa1cba2d9 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 31 Oct 2017 13:28:28 +0100 Subject: [PATCH 2/3] DecompilerSettings: change default of ThrowOnAssemblyResolveErrors to true. Note: this is only in effect, when using CSharpDecompiler directly. --- ICSharpCode.Decompiler/DecompilerSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/DecompilerSettings.cs b/ICSharpCode.Decompiler/DecompilerSettings.cs index d4cb9a34a..5e8858356 100644 --- a/ICSharpCode.Decompiler/DecompilerSettings.cs +++ b/ICSharpCode.Decompiler/DecompilerSettings.cs @@ -404,7 +404,7 @@ namespace ICSharpCode.Decompiler } } - bool throwOnAssemblyResolveErrors = false; + bool throwOnAssemblyResolveErrors = true; public bool ThrowOnAssemblyResolveErrors { get { return throwOnAssemblyResolveErrors; } From 79ef84426ab76437c30301d1697bbd23d160703d Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 31 Oct 2017 16:04:09 +0100 Subject: [PATCH 3/3] Fix possible bug in DotNetCorePathFinder. --- ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinder.cs b/ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinder.cs index 4c399903b..7c09186f1 100644 --- a/ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinder.cs +++ b/ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinder.cs @@ -99,7 +99,7 @@ namespace ICSharpCode.Decompiler string FallbackToDotNetSharedDirectory(AssemblyNameReference name, string version) { if (dotnetBasePath == null) return null; - var basePath = Path.Combine(dotnetBasePath, "shared\\Microsoft.NETCore.App", version); + var basePath = Path.Combine(dotnetBasePath, "shared", "Microsoft.NETCore.App", version); if (File.Exists(Path.Combine(basePath, name.Name + ".dll"))) { return Path.Combine(basePath, name.Name + ".dll"); } else if (File.Exists(Path.Combine(basePath, name.Name + ".exe"))) {