diff --git a/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs b/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
index 44ea9d215..3054a9a66 100644
--- a/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
+++ b/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
@@ -54,6 +54,14 @@ namespace ICSharpCode.Decompiler.Tests
{
CompilerOptions.None,
CompilerOptions.Optimize,
+ CompilerOptions.UseRoslyn1_3_2 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn1_3_2 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
CompilerOptions.UseRoslyn1_3_2,
CompilerOptions.Optimize | CompilerOptions.UseRoslyn1_3_2,
CompilerOptions.UseRoslyn2_10_0,
@@ -68,6 +76,14 @@ namespace ICSharpCode.Decompiler.Tests
{
CompilerOptions.None,
CompilerOptions.Optimize,
+ CompilerOptions.UseRoslyn1_3_2 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn1_3_2 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
CompilerOptions.UseRoslyn1_3_2,
CompilerOptions.Optimize | CompilerOptions.UseRoslyn1_3_2,
CompilerOptions.UseRoslyn2_10_0,
@@ -83,7 +99,15 @@ namespace ICSharpCode.Decompiler.Tests
};
static readonly CompilerOptions[] roslynOnlyOptions =
-{
+ {
+ CompilerOptions.UseRoslyn1_3_2 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn1_3_2 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
CompilerOptions.UseRoslyn1_3_2,
CompilerOptions.Optimize | CompilerOptions.UseRoslyn1_3_2,
CompilerOptions.UseRoslyn2_10_0,
@@ -96,6 +120,12 @@ namespace ICSharpCode.Decompiler.Tests
static readonly CompilerOptions[] roslyn2OrNewerOptions =
{
+ CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
CompilerOptions.UseRoslyn2_10_0,
CompilerOptions.Optimize | CompilerOptions.UseRoslyn2_10_0,
CompilerOptions.UseRoslyn3_11_0,
@@ -106,6 +136,8 @@ namespace ICSharpCode.Decompiler.Tests
static readonly CompilerOptions[] roslynLatestOnlyOptions =
{
+ CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
CompilerOptions.UseRoslynLatest,
CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
};
@@ -361,7 +393,7 @@ namespace ICSharpCode.Decompiler.Tests
async Task RunCS([CallerMemberName] string testName = null, CompilerOptions options = CompilerOptions.UseDebug)
{
- if ((options & CompilerOptions.UseRoslynMask) != 0)
+ if ((options & CompilerOptions.UseRoslynMask) != 0 && (options & CompilerOptions.TargetNet40) == 0)
options |= CompilerOptions.UseTestRunner;
string testFileName = testName + ".cs";
string testOutputFileName = testName + Tester.GetSuffix(options) + ".exe";
@@ -379,7 +411,14 @@ namespace ICSharpCode.Decompiler.Tests
// for example when there's unreachable code due to other compiler bugs in the first mcs run.
options &= ~CompilerOptions.UseMcsMask;
options |= CompilerOptions.UseRoslynLatest;
- options |= CompilerOptions.UseTestRunner;
+ // Also, add an .exe.config so that we consistently use the .NET 4.x runtime.
+ File.WriteAllText(outputFile.PathToAssembly + ".config", @"
+
+
+
+
+");
+ options |= CompilerOptions.TargetNet40;
}
decompiledOutputFile = await Tester.CompileCSharp(decompiledCodeFile, options).ConfigureAwait(false);
diff --git a/ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs b/ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs
index 9342c11ec..5ce1bf96b 100644
--- a/ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs
+++ b/ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs
@@ -60,7 +60,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
var vbcPath = roslynToolset.GetVBCompiler(roslynVersion);
IEnumerable references;
- if ((flags & CompilerOptions.UseRoslynMask) != 0)
+ if ((flags & CompilerOptions.UseRoslynMask) != 0 && (flags & CompilerOptions.TargetNet40) == 0)
{
references = coreDefaultReferences.Select(r => "-r:\"" + r + "\"");
}
diff --git a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
index b9715385d..b864ce078 100644
--- a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
+++ b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
@@ -18,7 +18,6 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection.PortableExecutable;
@@ -59,7 +58,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
UseRoslyn1_3_2 = 0x10,
UseMcs2_6_4 = 0x20,
ReferenceVisualBasic = 0x40,
- //ReferenceCore = 0x80,
+ TargetNet40 = 0x80,
GeneratePdb = 0x100,
Preview = 0x200,
UseRoslyn2_10_0 = 0x400,
@@ -212,10 +211,12 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
return outputFile;
}
- string ildasmPath = SdkUtility.GetSdkPath("ildasm.exe");
+ string ildasmPath = Path.Combine(
+ Path.GetDirectoryName(typeof(Tester).Assembly.Location),
+ "ildasm.exe");
var command = Cli.Wrap(ildasmPath)
- .WithArguments($"/nobar /utf8 /out=\"{outputFile}\" \"{sourceFileName}\"")
+ .WithArguments($"/utf8 /out=\"{outputFile}\" \"{sourceFileName}\"")
.WithValidation(CommandResultValidation.None);
var result = await command.ExecuteBufferedAsync().ConfigureAwait(false);
@@ -310,6 +311,10 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
{
preprocessorSymbols.Add("OPT");
}
+ if (flags.HasFlag(CompilerOptions.TargetNet40))
+ {
+ preprocessorSymbols.Add("NET40");
+ }
if ((flags & CompilerOptions.UseRoslynMask) != 0)
{
preprocessorSymbols.Add("NETCORE");
@@ -373,7 +378,9 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
{
sourceFileNames.Add(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(sourceFileName), match.Groups[1].Value)));
}
- if ((flags & CompilerOptions.UseRoslynMask) != 0)
+ bool targetNet40 = (flags & CompilerOptions.TargetNet40) != 0;
+ bool useRoslyn = (flags & CompilerOptions.UseRoslynMask) != 0;
+ if (useRoslyn && !targetNet40)
{
sourceFileNames.Add(targetFrameworkAttributeSnippetFile.Value);
}
@@ -397,7 +404,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
string libPath;
IEnumerable references;
- if ((flags & CompilerOptions.UseRoslynMask) != 0)
+ if (useRoslyn && !targetNet40)
{
libPath = "\"" + coreRefAsmPath + "\"";
references = coreDefaultReferences.Select(r => "-r:\"" + Path.Combine(coreRefAsmPath, r) + "\"");
@@ -420,7 +427,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
if (roslynVersion != "legacy")
{
otherOptions += "/shared ";
- if (Version.Parse(roslynVersion).Major > 2)
+ if (!targetNet40 && Version.Parse(roslynVersion).Major > 2)
{
if (flags.HasFlag(CompilerOptions.NullableEnable))
otherOptions += "/nullable+ ";
@@ -611,6 +618,8 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
suffix += ".32";
if ((cscOptions & CompilerOptions.UseDebug) != 0)
suffix += ".dbg";
+ if ((cscOptions & CompilerOptions.TargetNet40) != 0)
+ suffix += ".net40";
if ((cscOptions & CompilerOptions.UseRoslyn1_3_2) != 0)
suffix += ".roslyn1";
if ((cscOptions & CompilerOptions.UseRoslyn2_10_0) != 0)
diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
index 12a03df02..b8cce13c2 100644
--- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
+++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
@@ -11,7 +11,9 @@
1701;1702;1705,67,169,1058,728,1720,649,168,251,660,661,675
- False
+ False
+ False
+ False
false
True
@@ -56,6 +58,7 @@
+
diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
index 13f3b49ea..ef79a1359 100644
--- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
+++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
@@ -17,7 +17,6 @@
// DEALINGS IN THE SOFTWARE.
using System;
-using System.CodeDom.Compiler;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
@@ -58,6 +57,26 @@ namespace ICSharpCode.Decompiler.Tests
CompilerOptions.Optimize
};
+ static readonly CompilerOptions[] roslynOnlyWithNet40Options =
+ {
+ CompilerOptions.UseRoslyn1_3_2 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn1_3_2 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn1_3_2,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn1_3_2,
+ CompilerOptions.UseRoslyn2_10_0,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn2_10_0,
+ CompilerOptions.UseRoslyn3_11_0,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0,
+ CompilerOptions.UseRoslynLatest,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
+ };
+
static readonly CompilerOptions[] roslynOnlyOptions =
{
CompilerOptions.UseRoslyn1_3_2,
@@ -70,6 +89,22 @@ namespace ICSharpCode.Decompiler.Tests
CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
};
+ static readonly CompilerOptions[] roslyn2OrNewerWithNet40Options =
+ {
+ CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn2_10_0,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn2_10_0,
+ CompilerOptions.UseRoslyn3_11_0,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0,
+ CompilerOptions.UseRoslynLatest,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
+ };
+
static readonly CompilerOptions[] roslyn2OrNewerOptions =
{
CompilerOptions.UseRoslyn2_10_0,
@@ -80,6 +115,18 @@ namespace ICSharpCode.Decompiler.Tests
CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
};
+ static readonly CompilerOptions[] roslyn3OrNewerWithNet40Options =
+ {
+ CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn3_11_0,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0,
+ CompilerOptions.UseRoslynLatest,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
+ };
+
static readonly CompilerOptions[] roslyn3OrNewerOptions =
{
CompilerOptions.UseRoslyn3_11_0,
@@ -88,6 +135,14 @@ namespace ICSharpCode.Decompiler.Tests
CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
};
+ static readonly CompilerOptions[] roslynLatestOnlyWithNet40Options =
+ {
+ CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslynLatest,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
+ };
+
static readonly CompilerOptions[] roslynLatestOnlyOptions =
{
CompilerOptions.UseRoslynLatest,
@@ -98,6 +153,14 @@ namespace ICSharpCode.Decompiler.Tests
{
CompilerOptions.None,
CompilerOptions.Optimize,
+ CompilerOptions.UseRoslyn1_3_2 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn1_3_2 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
CompilerOptions.UseRoslyn1_3_2,
CompilerOptions.Optimize | CompilerOptions.UseRoslyn1_3_2,
CompilerOptions.UseRoslyn2_10_0,
@@ -112,6 +175,14 @@ namespace ICSharpCode.Decompiler.Tests
{
CompilerOptions.None,
CompilerOptions.Optimize,
+ CompilerOptions.UseRoslyn1_3_2 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn1_3_2 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn2_10_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0 | CompilerOptions.TargetNet40,
+ CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
+ CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest | CompilerOptions.TargetNet40,
CompilerOptions.UseRoslyn1_3_2,
CompilerOptions.Optimize | CompilerOptions.UseRoslyn1_3_2,
CompilerOptions.UseRoslyn2_10_0,
@@ -238,7 +309,7 @@ namespace ICSharpCode.Decompiler.Tests
}
[Test]
- public async Task UsingVariables([ValueSource(nameof(roslyn3OrNewerOptions))] CompilerOptions cscOptions)
+ public async Task UsingVariables([ValueSource(nameof(roslyn3OrNewerWithNet40Options))] CompilerOptions cscOptions)
{
await RunForLibrary(cscOptions: cscOptions);
}
@@ -459,9 +530,9 @@ namespace ICSharpCode.Decompiler.Tests
}
[Test]
- public async Task StringInterpolation([ValueSource(nameof(roslynOnlyOptions))] CompilerOptions cscOptions)
+ public async Task StringInterpolation([ValueSource(nameof(roslynOnlyWithNet40Options))] CompilerOptions cscOptions)
{
- if (cscOptions.HasFlag(CompilerOptions.UseRoslynLatest))
+ if (!cscOptions.HasFlag(CompilerOptions.TargetNet40) && cscOptions.HasFlag(CompilerOptions.UseRoslynLatest))
{
Assert.Ignore("DefaultInterpolatedStringHandler is not yet supported!");
return;
@@ -621,15 +692,15 @@ namespace ICSharpCode.Decompiler.Tests
}
[Test]
- public async Task CS9_ExtensionGetEnumerator([ValueSource(nameof(roslyn3OrNewerOptions))] CompilerOptions cscOptions)
+ public async Task CS9_ExtensionGetEnumerator([ValueSource(nameof(roslyn3OrNewerWithNet40Options))] CompilerOptions cscOptions)
{
- await RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview);
+ await RunForLibrary(cscOptions: cscOptions);
}
[Test]
public async Task CovariantReturns([ValueSource(nameof(roslyn3OrNewerOptions))] CompilerOptions cscOptions)
{
- await RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview);
+ await RunForLibrary(cscOptions: cscOptions);
}
[Test]
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS9_ExtensionGetEnumerator.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS9_ExtensionGetEnumerator.cs
index 1cc7523a0..53db65dc1 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS9_ExtensionGetEnumerator.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS9_ExtensionGetEnumerator.cs
@@ -29,7 +29,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine(item);
}
}
-
+#if !NET40
public async void TestAsync(Generic c)
{
await foreach (int item in c)
@@ -37,6 +37,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine(item);
}
}
+#endif
}
public static class CS9_ExtensionGetEnumerator_Ext
@@ -49,9 +50,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
throw null;
}
+#if !NET40
public static IAsyncEnumerator GetAsyncEnumerator(this CS9_ExtensionGetEnumerator.Generic c)
{
throw null;
}
+#endif
}
}
\ No newline at end of file
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DeconstructionTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DeconstructionTests.cs
index 79bdbfee8..512a1b192 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DeconstructionTests.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DeconstructionTests.cs
@@ -22,6 +22,15 @@ using System.Runtime.InteropServices;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
+ public static class DeconstructionExt
+ {
+ public static void Deconstruct(this KeyValuePair pair, out K key, out V value)
+ {
+ key = pair.Key;
+ value = pair.Value;
+ }
+ }
+
internal class DeconstructionTests
{
[StructLayout(LayoutKind.Sequential, Size = 1)]
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs
index ca1298d36..84387b606 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs
@@ -376,7 +376,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
{ 1, 1, 1 }
};
-#if CS73
+#if CS73 && !NET40
public static ReadOnlySpan StaticData1 => new byte[1] { 0 };
public static ReadOnlySpan StaticData3 => new byte[3] { 1, 2, 3 };
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InterfaceTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InterfaceTests.cs
index 65591278d..d80623929 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InterfaceTests.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InterfaceTests.cs
@@ -24,7 +24,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
public interface IA
{
-#if CS80
+#if CS80 && !NET40
static int Field;
#endif
int Property1 { get; }
@@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
event EventHandler MyEvent;
void Method();
-#if CS80
+#if CS80 && !NET40
static IA()
{
@@ -69,7 +69,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
public interface IA2 : IA
{
-#if CS80
+#if CS80 && !NET40
int IA.Property3 {
get {
return 0;
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs
index fd306db7d..f334ce24c 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs
@@ -20,7 +20,9 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
-#if ROSLYN4
+#if ROSLYN4 && !NET40
+// This is needed because there are some nullability attributes on compiler-generated lambdas,
+// which are removed after IntroduceUsingDeclarations ran.
using System.Runtime.CompilerServices;
#endif
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UnsafeCode.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UnsafeCode.cs
index 784d7d8b2..d24744dc7 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UnsafeCode.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UnsafeCode.cs
@@ -411,7 +411,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
}
-#if CS73
+#if CS73 && !NET40
public unsafe void FixedSpan(Span span)
{
fixed (int* ptr = span)
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UsingVariables.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UsingVariables.cs
index 911e948c0..b36ce1b6e 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UsingVariables.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UsingVariables.cs
@@ -17,7 +17,9 @@
// DEALINGS IN THE SOFTWARE.
using System;
+#if !NET40
using System.Threading.Tasks;
+#endif
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
@@ -28,20 +30,22 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
return null;
}
- public IAsyncDisposable GetAsyncDisposable()
+ private void Use(IDisposable disposable)
{
- return null;
+
}
- private void Use(IDisposable disposable)
+#if !NET40
+ public IAsyncDisposable GetAsyncDisposable()
{
-
+ return null;
}
private void Use(IAsyncDisposable asyncDisposable)
{
}
+#endif
public void SimpleUsingVar()
{
@@ -83,7 +87,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Use(disposable);
Use(disposable2);
}
-
+#if !NET40
public async Task SimpleUsingVarAsync()
{
Console.WriteLine("before using");
@@ -91,5 +95,6 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine("inside using");
Use(asyncDisposable);
}
+#endif
}
}
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/WellKnownConstants.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/WellKnownConstants.cs
index 4fb154f30..9170a8d89 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/WellKnownConstants.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/WellKnownConstants.cs
@@ -83,7 +83,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public const float Float_Tenth = 0.1f;
public const double Double_Tenth = 0.1;
-#if ROSLYN
+#if ROSLYN && !NET40
public const float Float_PI = MathF.PI;
public const float Float_HalfOfPI = MathF.PI / 2f;
public const float Float_QuarterOfPI = MathF.PI / 4f;
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Ugly/AggressiveScalarReplacementOfAggregates.net40.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/AggressiveScalarReplacementOfAggregates.net40.roslyn.il
new file mode 100644
index 000000000..50a820f92
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/AggressiveScalarReplacementOfAggregates.net40.roslyn.il
@@ -0,0 +1,577 @@
+
+
+
+
+// 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 tmp4B37
+{
+ .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 tmp4B37.tmp
+.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.Ugly.DisplayClass
+ extends [mscorlib]System.Object
+{
+ .field public class ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program thisField
+ .field public int32 field1
+ .field public string field2
+ .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 DisplayClass::.ctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass
+
+.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass
+ extends [mscorlib]System.Object
+{
+ .field public class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass field3
+ .field public int32 field1
+ .field public string field2
+ .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 NestedDisplayClass::.ctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass
+
+.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig instance int32
+ Rand() cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: newobj instance void [mscorlib]System.NotImplementedException::.ctor()
+ IL_0006: throw
+ } // end of method Program::Rand
+
+ .method public hidebysig instance void
+ Test1() cil managed
+ {
+ // Code size 55 (0x37)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0)
+ IL_0000: nop
+ IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0006: dup
+ IL_0007: ldc.i4.s 42
+ IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000e: dup
+ IL_000f: ldstr "Hello World!"
+ IL_0014: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0019: stloc.0
+ IL_001a: ldstr "{0} {1}"
+ IL_001f: ldloc.0
+ IL_0020: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0025: box [mscorlib]System.Int32
+ IL_002a: ldloc.0
+ IL_002b: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0030: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0035: nop
+ IL_0036: ret
+ } // end of method Program::Test1
+
+ .method public hidebysig instance void
+ Test2() cil managed
+ {
+ // Code size 60 (0x3c)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0)
+ IL_0000: nop
+ IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0006: dup
+ IL_0007: ldc.i4.s 42
+ IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000e: dup
+ IL_000f: ldstr "Hello World!"
+ IL_0014: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0019: stloc.0
+ IL_001a: ldstr "{0} {1}"
+ IL_001f: ldloc.0
+ IL_0020: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0025: box [mscorlib]System.Int32
+ IL_002a: ldloc.0
+ IL_002b: callvirt instance int32 [mscorlib]System.Object::GetHashCode()
+ IL_0030: box [mscorlib]System.Int32
+ IL_0035: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_003a: nop
+ IL_003b: ret
+ } // end of method Program::Test2
+
+ .method public hidebysig instance void
+ Test3() cil managed
+ {
+ // Code size 50 (0x32)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0)
+ IL_0000: nop
+ IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0006: dup
+ IL_0007: ldc.i4.s 42
+ IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000e: dup
+ IL_000f: ldstr "Hello World!"
+ IL_0014: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0019: stloc.0
+ IL_001a: ldstr "{0} {1}"
+ IL_001f: ldloc.0
+ IL_0020: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0025: box [mscorlib]System.Int32
+ IL_002a: ldloc.0
+ IL_002b: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0030: nop
+ IL_0031: ret
+ } // end of method Program::Test3
+
+ .method public hidebysig instance void
+ Test4() cil managed
+ {
+ // Code size 114 (0x72)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0,
+ class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass V_1,
+ bool V_2)
+ IL_0000: nop
+ IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0006: dup
+ IL_0007: ldarg.0
+ IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::thisField
+ IL_000d: dup
+ IL_000e: ldc.i4.s 42
+ IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0015: dup
+ IL_0016: ldstr "Hello World!"
+ IL_001b: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0020: stloc.0
+ IL_0021: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::.ctor()
+ IL_0026: dup
+ IL_0027: ldc.i4 0x1267
+ IL_002c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field1
+ IL_0031: dup
+ IL_0032: ldstr "ILSpy"
+ IL_0037: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field2
+ IL_003c: stloc.1
+ IL_003d: ldloc.0
+ IL_003e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0043: ldc.i4.s 100
+ IL_0045: cgt
+ IL_0047: stloc.2
+ IL_0048: ldloc.2
+ IL_0049: brfalse.s IL_0056
+
+ IL_004b: nop
+ IL_004c: ldloc.1
+ IL_004d: ldloc.0
+ IL_004e: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_0053: nop
+ IL_0054: br.s IL_005f
+
+ IL_0056: nop
+ IL_0057: ldloc.1
+ IL_0058: ldnull
+ IL_0059: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_005e: nop
+ IL_005f: ldstr "{0} {1}"
+ IL_0064: ldloc.0
+ IL_0065: ldloc.1
+ IL_0066: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_006b: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0070: nop
+ IL_0071: ret
+ } // end of method Program::Test4
+
+ .method public hidebysig instance void
+ Test5() cil managed
+ {
+ // Code size 135 (0x87)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0,
+ class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass V_1,
+ bool V_2)
+ IL_0000: nop
+ IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0006: dup
+ IL_0007: ldarg.0
+ IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::thisField
+ IL_000d: dup
+ IL_000e: ldc.i4.s 42
+ IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0015: dup
+ IL_0016: ldstr "Hello World!"
+ IL_001b: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0020: stloc.0
+ IL_0021: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::.ctor()
+ IL_0026: dup
+ IL_0027: ldc.i4 0x1267
+ IL_002c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field1
+ IL_0031: dup
+ IL_0032: ldstr "ILSpy"
+ IL_0037: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field2
+ IL_003c: stloc.1
+ IL_003d: ldloc.0
+ IL_003e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0043: ldc.i4.s 100
+ IL_0045: cgt
+ IL_0047: stloc.2
+ IL_0048: ldloc.2
+ IL_0049: brfalse.s IL_0056
+
+ IL_004b: nop
+ IL_004c: ldloc.1
+ IL_004d: ldloc.0
+ IL_004e: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_0053: nop
+ IL_0054: br.s IL_005f
+
+ IL_0056: nop
+ IL_0057: ldloc.1
+ IL_0058: ldnull
+ IL_0059: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_005e: nop
+ IL_005f: ldstr "{0} {1}"
+ IL_0064: ldloc.1
+ IL_0065: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field2
+ IL_006a: ldloc.1
+ IL_006b: ldflda int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field1
+ IL_0070: call instance string [mscorlib]System.Int32::ToString()
+ IL_0075: call string [mscorlib]System.String::Concat(string,
+ string)
+ IL_007a: ldloc.1
+ IL_007b: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_0080: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0085: nop
+ IL_0086: ret
+ } // end of method Program::Test5
+
+ .method public hidebysig instance void
+ Issue1898(int32 i) cil managed
+ {
+ // Code size 151 (0x97)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0,
+ class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass V_1,
+ int32 V_2,
+ int32 V_3,
+ int32 V_4,
+ bool V_5)
+ IL_0000: nop
+ IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0006: dup
+ IL_0007: ldarg.0
+ IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::thisField
+ IL_000d: dup
+ IL_000e: ldarg.1
+ IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0014: stloc.0
+ IL_0015: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::.ctor()
+ IL_001a: stloc.1
+ IL_001b: br.s IL_0092
+
+ IL_001d: nop
+ IL_001e: ldarg.0
+ IL_001f: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program::Rand()
+ IL_0024: stloc.3
+ IL_0025: ldloc.3
+ IL_0026: stloc.2
+ IL_0027: ldloc.2
+ IL_0028: ldc.i4.1
+ IL_0029: sub
+ IL_002a: switch (
+ IL_003d,
+ IL_004b,
+ IL_0062)
+ IL_003b: br.s IL_006b
+
+ IL_003d: ldloc.1
+ IL_003e: ldarg.0
+ IL_003f: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program::Rand()
+ IL_0044: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field1
+ IL_0049: br.s IL_0091
+
+ IL_004b: ldloc.1
+ IL_004c: ldarg.0
+ IL_004d: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program::Rand()
+ IL_0052: stloc.s V_4
+ IL_0054: ldloca.s V_4
+ IL_0056: call instance string [mscorlib]System.Int32::ToString()
+ IL_005b: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field2
+ IL_0060: br.s IL_0091
+
+ IL_0062: ldloc.1
+ IL_0063: ldloc.0
+ IL_0064: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_0069: br.s IL_0091
+
+ IL_006b: ldloc.1
+ IL_006c: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field1
+ IL_0071: call void [mscorlib]System.Console::WriteLine(int32)
+ IL_0076: nop
+ IL_0077: ldloc.1
+ IL_0078: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field2
+ IL_007d: call void [mscorlib]System.Console::WriteLine(string)
+ IL_0082: nop
+ IL_0083: ldloc.1
+ IL_0084: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_0089: call void [mscorlib]System.Console::WriteLine(object)
+ IL_008e: nop
+ IL_008f: br.s IL_0091
+
+ IL_0091: nop
+ IL_0092: ldc.i4.1
+ IL_0093: stloc.s V_5
+ IL_0095: br.s IL_001d
+ } // end of method Program::Issue1898
+
+ .method public hidebysig instance void
+ Test6(int32 i) cil managed
+ {
+ // Code size 68 (0x44)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0,
+ bool V_1)
+ IL_0000: nop
+ IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0006: dup
+ IL_0007: ldarg.1
+ IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000d: dup
+ IL_000e: ldstr "Hello World!"
+ IL_0013: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0018: stloc.0
+ IL_0019: ldarg.1
+ IL_001a: ldc.i4.0
+ IL_001b: clt
+ IL_001d: stloc.1
+ IL_001e: ldloc.1
+ IL_001f: brfalse.s IL_0027
+
+ IL_0021: nop
+ IL_0022: ldarg.1
+ IL_0023: neg
+ IL_0024: starg.s i
+ IL_0026: nop
+ IL_0027: ldstr "{0} {1}"
+ IL_002c: ldloc.0
+ IL_002d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0032: box [mscorlib]System.Int32
+ IL_0037: ldloc.0
+ IL_0038: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_003d: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0042: nop
+ IL_0043: ret
+ } // end of method Program::Test6
+
+ .method public hidebysig instance void
+ Test6b(int32 i) cil managed
+ {
+ // Code size 69 (0x45)
+ .maxstack 3
+ .locals init (int32 V_0,
+ class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_1,
+ bool V_2)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: stloc.0
+ IL_0003: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0008: dup
+ IL_0009: ldloc.0
+ IL_000a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000f: dup
+ IL_0010: ldstr "Hello World!"
+ IL_0015: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_001a: stloc.1
+ IL_001b: ldloc.0
+ IL_001c: ldc.i4.0
+ IL_001d: clt
+ IL_001f: stloc.2
+ IL_0020: ldloc.2
+ IL_0021: brfalse.s IL_0028
+
+ IL_0023: nop
+ IL_0024: ldloc.0
+ IL_0025: neg
+ IL_0026: stloc.0
+ IL_0027: nop
+ IL_0028: ldstr "{0} {1}"
+ IL_002d: ldloc.1
+ IL_002e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0033: box [mscorlib]System.Int32
+ IL_0038: ldloc.1
+ IL_0039: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_003e: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0043: nop
+ IL_0044: ret
+ } // end of method Program::Test6b
+
+ .method public hidebysig instance void
+ Test7(int32 i) cil managed
+ {
+ // Code size 71 (0x47)
+ .maxstack 4
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0,
+ int32 V_1)
+ IL_0000: nop
+ IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0006: dup
+ IL_0007: ldarg.1
+ IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000d: dup
+ IL_000e: ldstr "Hello World!"
+ IL_0013: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0018: stloc.0
+ IL_0019: ldstr "{0} {1} {2}"
+ IL_001e: ldloc.0
+ IL_001f: dup
+ IL_0020: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0025: stloc.1
+ IL_0026: ldloc.1
+ IL_0027: ldc.i4.1
+ IL_0028: add
+ IL_0029: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_002e: ldloc.1
+ IL_002f: box [mscorlib]System.Int32
+ IL_0034: ldloc.0
+ IL_0035: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_003a: ldarg.1
+ IL_003b: box [mscorlib]System.Int32
+ IL_0040: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object,
+ object)
+ IL_0045: nop
+ IL_0046: ret
+ } // end of method Program::Test7
+
+ .method public hidebysig instance void
+ Test8(int32 i) cil managed
+ {
+ // Code size 58 (0x3a)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0)
+ IL_0000: nop
+ IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0006: dup
+ IL_0007: ldarg.1
+ IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000d: dup
+ IL_000e: ldstr "Hello World!"
+ IL_0013: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0018: stloc.0
+ IL_0019: ldc.i4.s 42
+ IL_001b: starg.s i
+ IL_001d: ldstr "{0} {1}"
+ IL_0022: ldloc.0
+ IL_0023: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0028: box [mscorlib]System.Int32
+ IL_002d: ldloc.0
+ IL_002e: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0033: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0038: nop
+ IL_0039: ret
+ } // end of method Program::Test8
+
+ .method public hidebysig instance void
+ Test8b(int32 i) cil managed
+ {
+ // Code size 59 (0x3b)
+ .maxstack 3
+ .locals init (int32 V_0,
+ class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_1)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: stloc.0
+ IL_0003: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0008: dup
+ IL_0009: ldloc.0
+ IL_000a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000f: dup
+ IL_0010: ldstr "Hello World!"
+ IL_0015: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_001a: stloc.1
+ IL_001b: ldc.i4.s 42
+ IL_001d: stloc.0
+ IL_001e: ldstr "{0} {1}"
+ IL_0023: ldloc.1
+ IL_0024: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0029: box [mscorlib]System.Int32
+ IL_002e: ldloc.1
+ IL_002f: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0034: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0039: nop
+ IL_003a: ret
+ } // end of method Program::Test8b
+
+ .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 Program::.ctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program
+
+
+// =============================================================
+
+// *********** DISASSEMBLY COMPLETE ***********************
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Ugly/AggressiveScalarReplacementOfAggregates.opt.net40.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/AggressiveScalarReplacementOfAggregates.opt.net40.roslyn.il
new file mode 100644
index 000000000..1d4bca556
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/AggressiveScalarReplacementOfAggregates.opt.net40.roslyn.il
@@ -0,0 +1,509 @@
+
+
+
+
+// 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 tmp96F5
+{
+ .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 tmp96F5.tmp
+.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.Ugly.DisplayClass
+ extends [mscorlib]System.Object
+{
+ .field public class ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program thisField
+ .field public int32 field1
+ .field public string field2
+ .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 DisplayClass::.ctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass
+
+.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass
+ extends [mscorlib]System.Object
+{
+ .field public class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass field3
+ .field public int32 field1
+ .field public string field2
+ .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 NestedDisplayClass::.ctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass
+
+.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig instance int32
+ Rand() cil managed
+ {
+ // Code size 6 (0x6)
+ .maxstack 8
+ IL_0000: newobj instance void [mscorlib]System.NotImplementedException::.ctor()
+ IL_0005: throw
+ } // end of method Program::Rand
+
+ .method public hidebysig instance void
+ Test1() cil managed
+ {
+ // Code size 53 (0x35)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0)
+ IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0005: dup
+ IL_0006: ldc.i4.s 42
+ IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000d: dup
+ IL_000e: ldstr "Hello World!"
+ IL_0013: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0018: stloc.0
+ IL_0019: ldstr "{0} {1}"
+ IL_001e: ldloc.0
+ IL_001f: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0024: box [mscorlib]System.Int32
+ IL_0029: ldloc.0
+ IL_002a: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_002f: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0034: ret
+ } // end of method Program::Test1
+
+ .method public hidebysig instance void
+ Test2() cil managed
+ {
+ // Code size 58 (0x3a)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0)
+ IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0005: dup
+ IL_0006: ldc.i4.s 42
+ IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000d: dup
+ IL_000e: ldstr "Hello World!"
+ IL_0013: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0018: stloc.0
+ IL_0019: ldstr "{0} {1}"
+ IL_001e: ldloc.0
+ IL_001f: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0024: box [mscorlib]System.Int32
+ IL_0029: ldloc.0
+ IL_002a: callvirt instance int32 [mscorlib]System.Object::GetHashCode()
+ IL_002f: box [mscorlib]System.Int32
+ IL_0034: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0039: ret
+ } // end of method Program::Test2
+
+ .method public hidebysig instance void
+ Test3() cil managed
+ {
+ // Code size 48 (0x30)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0)
+ IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0005: dup
+ IL_0006: ldc.i4.s 42
+ IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000d: dup
+ IL_000e: ldstr "Hello World!"
+ IL_0013: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0018: stloc.0
+ IL_0019: ldstr "{0} {1}"
+ IL_001e: ldloc.0
+ IL_001f: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0024: box [mscorlib]System.Int32
+ IL_0029: ldloc.0
+ IL_002a: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_002f: ret
+ } // end of method Program::Test3
+
+ .method public hidebysig instance void
+ Test4() cil managed
+ {
+ // Code size 104 (0x68)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0,
+ class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass V_1)
+ IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0005: dup
+ IL_0006: ldarg.0
+ IL_0007: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::thisField
+ IL_000c: dup
+ IL_000d: ldc.i4.s 42
+ IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0014: dup
+ IL_0015: ldstr "Hello World!"
+ IL_001a: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_001f: stloc.0
+ IL_0020: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::.ctor()
+ IL_0025: dup
+ IL_0026: ldc.i4 0x1267
+ IL_002b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field1
+ IL_0030: dup
+ IL_0031: ldstr "ILSpy"
+ IL_0036: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field2
+ IL_003b: stloc.1
+ IL_003c: ldloc.0
+ IL_003d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0042: ldc.i4.s 100
+ IL_0044: ble.s IL_004f
+
+ IL_0046: ldloc.1
+ IL_0047: ldloc.0
+ IL_0048: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_004d: br.s IL_0056
+
+ IL_004f: ldloc.1
+ IL_0050: ldnull
+ IL_0051: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_0056: ldstr "{0} {1}"
+ IL_005b: ldloc.0
+ IL_005c: ldloc.1
+ IL_005d: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_0062: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0067: ret
+ } // end of method Program::Test4
+
+ .method public hidebysig instance void
+ Test5() cil managed
+ {
+ // Code size 125 (0x7d)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0,
+ class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass V_1)
+ IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0005: dup
+ IL_0006: ldarg.0
+ IL_0007: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::thisField
+ IL_000c: dup
+ IL_000d: ldc.i4.s 42
+ IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0014: dup
+ IL_0015: ldstr "Hello World!"
+ IL_001a: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_001f: stloc.0
+ IL_0020: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::.ctor()
+ IL_0025: dup
+ IL_0026: ldc.i4 0x1267
+ IL_002b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field1
+ IL_0030: dup
+ IL_0031: ldstr "ILSpy"
+ IL_0036: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field2
+ IL_003b: stloc.1
+ IL_003c: ldloc.0
+ IL_003d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0042: ldc.i4.s 100
+ IL_0044: ble.s IL_004f
+
+ IL_0046: ldloc.1
+ IL_0047: ldloc.0
+ IL_0048: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_004d: br.s IL_0056
+
+ IL_004f: ldloc.1
+ IL_0050: ldnull
+ IL_0051: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_0056: ldstr "{0} {1}"
+ IL_005b: ldloc.1
+ IL_005c: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field2
+ IL_0061: ldloc.1
+ IL_0062: ldflda int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field1
+ IL_0067: call instance string [mscorlib]System.Int32::ToString()
+ IL_006c: call string [mscorlib]System.String::Concat(string,
+ string)
+ IL_0071: ldloc.1
+ IL_0072: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_0077: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_007c: ret
+ } // end of method Program::Test5
+
+ .method public hidebysig instance void
+ Issue1898(int32 i) cil managed
+ {
+ // Code size 135 (0x87)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0,
+ class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass V_1,
+ int32 V_2,
+ int32 V_3)
+ IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0005: dup
+ IL_0006: ldarg.0
+ IL_0007: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::thisField
+ IL_000c: dup
+ IL_000d: ldarg.1
+ IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0013: stloc.0
+ IL_0014: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::.ctor()
+ IL_0019: stloc.1
+ IL_001a: ldarg.0
+ IL_001b: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program::Rand()
+ IL_0020: stloc.2
+ IL_0021: ldloc.2
+ IL_0022: ldc.i4.1
+ IL_0023: sub
+ IL_0024: switch (
+ IL_0037,
+ IL_0045,
+ IL_005b)
+ IL_0035: br.s IL_0064
+
+ IL_0037: ldloc.1
+ IL_0038: ldarg.0
+ IL_0039: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program::Rand()
+ IL_003e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field1
+ IL_0043: br.s IL_001a
+
+ IL_0045: ldloc.1
+ IL_0046: ldarg.0
+ IL_0047: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program::Rand()
+ IL_004c: stloc.3
+ IL_004d: ldloca.s V_3
+ IL_004f: call instance string [mscorlib]System.Int32::ToString()
+ IL_0054: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field2
+ IL_0059: br.s IL_001a
+
+ IL_005b: ldloc.1
+ IL_005c: ldloc.0
+ IL_005d: stfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_0062: br.s IL_001a
+
+ IL_0064: ldloc.1
+ IL_0065: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field1
+ IL_006a: call void [mscorlib]System.Console::WriteLine(int32)
+ IL_006f: ldloc.1
+ IL_0070: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field2
+ IL_0075: call void [mscorlib]System.Console::WriteLine(string)
+ IL_007a: ldloc.1
+ IL_007b: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass ICSharpCode.Decompiler.Tests.TestCases.Ugly.NestedDisplayClass::field3
+ IL_0080: call void [mscorlib]System.Console::WriteLine(object)
+ IL_0085: br.s IL_001a
+ } // end of method Program::Issue1898
+
+ .method public hidebysig instance void
+ Test6(int32 i) cil managed
+ {
+ // Code size 60 (0x3c)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0)
+ IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0005: dup
+ IL_0006: ldarg.1
+ IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000c: dup
+ IL_000d: ldstr "Hello World!"
+ IL_0012: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0017: stloc.0
+ IL_0018: ldarg.1
+ IL_0019: ldc.i4.0
+ IL_001a: bge.s IL_0020
+
+ IL_001c: ldarg.1
+ IL_001d: neg
+ IL_001e: starg.s i
+ IL_0020: ldstr "{0} {1}"
+ IL_0025: ldloc.0
+ IL_0026: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_002b: box [mscorlib]System.Int32
+ IL_0030: ldloc.0
+ IL_0031: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0036: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_003b: ret
+ } // end of method Program::Test6
+
+ .method public hidebysig instance void
+ Test6b(int32 i) cil managed
+ {
+ // Code size 61 (0x3d)
+ .maxstack 3
+ .locals init (int32 V_0,
+ class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_1)
+ IL_0000: ldarg.1
+ IL_0001: stloc.0
+ IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0007: dup
+ IL_0008: ldloc.0
+ IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000e: dup
+ IL_000f: ldstr "Hello World!"
+ IL_0014: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0019: stloc.1
+ IL_001a: ldloc.0
+ IL_001b: ldc.i4.0
+ IL_001c: bge.s IL_0021
+
+ IL_001e: ldloc.0
+ IL_001f: neg
+ IL_0020: stloc.0
+ IL_0021: ldstr "{0} {1}"
+ IL_0026: ldloc.1
+ IL_0027: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_002c: box [mscorlib]System.Int32
+ IL_0031: ldloc.1
+ IL_0032: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0037: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_003c: ret
+ } // end of method Program::Test6b
+
+ .method public hidebysig instance void
+ Test7(int32 i) cil managed
+ {
+ // Code size 69 (0x45)
+ .maxstack 4
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0,
+ int32 V_1)
+ IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0005: dup
+ IL_0006: ldarg.1
+ IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000c: dup
+ IL_000d: ldstr "Hello World!"
+ IL_0012: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0017: stloc.0
+ IL_0018: ldstr "{0} {1} {2}"
+ IL_001d: ldloc.0
+ IL_001e: dup
+ IL_001f: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0024: stloc.1
+ IL_0025: ldloc.1
+ IL_0026: ldc.i4.1
+ IL_0027: add
+ IL_0028: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_002d: ldloc.1
+ IL_002e: box [mscorlib]System.Int32
+ IL_0033: ldloc.0
+ IL_0034: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0039: ldarg.1
+ IL_003a: box [mscorlib]System.Int32
+ IL_003f: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object,
+ object)
+ IL_0044: ret
+ } // end of method Program::Test7
+
+ .method public hidebysig instance void
+ Test8(int32 i) cil managed
+ {
+ // Code size 56 (0x38)
+ .maxstack 3
+ .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_0)
+ IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0005: dup
+ IL_0006: ldarg.1
+ IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000c: dup
+ IL_000d: ldstr "Hello World!"
+ IL_0012: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0017: stloc.0
+ IL_0018: ldc.i4.s 42
+ IL_001a: starg.s i
+ IL_001c: ldstr "{0} {1}"
+ IL_0021: ldloc.0
+ IL_0022: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0027: box [mscorlib]System.Int32
+ IL_002c: ldloc.0
+ IL_002d: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0032: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0037: ret
+ } // end of method Program::Test8
+
+ .method public hidebysig instance void
+ Test8b(int32 i) cil managed
+ {
+ // Code size 57 (0x39)
+ .maxstack 3
+ .locals init (int32 V_0,
+ class ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass V_1)
+ IL_0000: ldarg.1
+ IL_0001: stloc.0
+ IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::.ctor()
+ IL_0007: dup
+ IL_0008: ldloc.0
+ IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_000e: dup
+ IL_000f: ldstr "Hello World!"
+ IL_0014: stfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0019: stloc.1
+ IL_001a: ldc.i4.s 42
+ IL_001c: stloc.0
+ IL_001d: ldstr "{0} {1}"
+ IL_0022: ldloc.1
+ IL_0023: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field1
+ IL_0028: box [mscorlib]System.Int32
+ IL_002d: ldloc.1
+ IL_002e: ldfld string ICSharpCode.Decompiler.Tests.TestCases.Ugly.DisplayClass::field2
+ IL_0033: call void [mscorlib]System.Console::WriteLine(string,
+ object,
+ object)
+ IL_0038: ret
+ } // end of method Program::Test8b
+
+ .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 Program::.ctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.Program
+
+
+// =============================================================
+
+// *********** DISASSEMBLY COMPLETE ***********************
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoArrayInitializers.net40.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoArrayInitializers.net40.roslyn.il
new file mode 100644
index 000000000..b70013f67
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoArrayInitializers.net40.roslyn.il
@@ -0,0 +1,116 @@
+
+
+
+
+// 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 tmp9704
+{
+ .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 tmp9704.tmp
+.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.Ugly.NoArrayInitializers
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig instance int32[]
+ LiteralArray() cil managed
+ {
+ // Code size 23 (0x17)
+ .maxstack 3
+ .locals init (int32[] V_0)
+ IL_0000: nop
+ IL_0001: ldc.i4.3
+ IL_0002: newarr [mscorlib]System.Int32
+ IL_0007: dup
+ IL_0008: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=12' ''::'4636993D3E1DA4E9D6B8F87B79E8F7C6D018580D52661950EABC3845C5897A4D'
+ IL_000d: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array,
+ valuetype [mscorlib]System.RuntimeFieldHandle)
+ IL_0012: stloc.0
+ IL_0013: br.s IL_0015
+
+ IL_0015: ldloc.0
+ IL_0016: ret
+ } // end of method NoArrayInitializers::LiteralArray
+
+ .method public hidebysig instance int32[]
+ VariableArray(int32 a,
+ int32 b) cil managed
+ {
+ // Code size 20 (0x14)
+ .maxstack 4
+ .locals init (int32[] V_0)
+ IL_0000: nop
+ IL_0001: ldc.i4.2
+ IL_0002: newarr [mscorlib]System.Int32
+ IL_0007: dup
+ IL_0008: ldc.i4.0
+ IL_0009: ldarg.1
+ IL_000a: stelem.i4
+ IL_000b: dup
+ IL_000c: ldc.i4.1
+ IL_000d: ldarg.2
+ IL_000e: stelem.i4
+ IL_000f: stloc.0
+ IL_0010: br.s IL_0012
+
+ IL_0012: ldloc.0
+ IL_0013: ret
+ } // end of method NoArrayInitializers::VariableArray
+
+ .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 NoArrayInitializers::.ctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoArrayInitializers
+
+.class private auto ansi sealed ''
+ extends [mscorlib]System.Object
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
+ .class explicit ansi sealed nested private '__StaticArrayInitTypeSize=12'
+ extends [mscorlib]System.ValueType
+ {
+ .pack 1
+ .size 12
+ } // end of class '__StaticArrayInitTypeSize=12'
+
+ .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '4636993D3E1DA4E9D6B8F87B79E8F7C6D018580D52661950EABC3845C5897A4D' at I_000026C0
+} // end of class ''
+
+
+// =============================================================
+
+.data cil I_000026C0 = bytearray (
+ 01 00 00 00 02 00 00 00 03 00 00 00)
+// *********** DISASSEMBLY COMPLETE ***********************
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoArrayInitializers.opt.net40.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoArrayInitializers.opt.net40.roslyn.il
new file mode 100644
index 000000000..bb1945af4
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoArrayInitializers.opt.net40.roslyn.il
@@ -0,0 +1,103 @@
+
+
+
+
+// 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 tmp9705
+{
+ .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 tmp9705.tmp
+.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.Ugly.NoArrayInitializers
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig instance int32[]
+ LiteralArray() cil managed
+ {
+ // Code size 18 (0x12)
+ .maxstack 8
+ IL_0000: ldc.i4.3
+ IL_0001: newarr [mscorlib]System.Int32
+ IL_0006: dup
+ IL_0007: ldtoken field valuetype ''/'__StaticArrayInitTypeSize=12' ''::'4636993D3E1DA4E9D6B8F87B79E8F7C6D018580D52661950EABC3845C5897A4D'
+ IL_000c: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array,
+ valuetype [mscorlib]System.RuntimeFieldHandle)
+ IL_0011: ret
+ } // end of method NoArrayInitializers::LiteralArray
+
+ .method public hidebysig instance int32[]
+ VariableArray(int32 a,
+ int32 b) cil managed
+ {
+ // Code size 15 (0xf)
+ .maxstack 8
+ IL_0000: ldc.i4.2
+ IL_0001: newarr [mscorlib]System.Int32
+ IL_0006: dup
+ IL_0007: ldc.i4.0
+ IL_0008: ldarg.1
+ IL_0009: stelem.i4
+ IL_000a: dup
+ IL_000b: ldc.i4.1
+ IL_000c: ldarg.2
+ IL_000d: stelem.i4
+ IL_000e: ret
+ } // end of method NoArrayInitializers::VariableArray
+
+ .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 NoArrayInitializers::.ctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoArrayInitializers
+
+.class private auto ansi sealed ''
+ extends [mscorlib]System.Object
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
+ .class explicit ansi sealed nested private '__StaticArrayInitTypeSize=12'
+ extends [mscorlib]System.ValueType
+ {
+ .pack 1
+ .size 12
+ } // end of class '__StaticArrayInitTypeSize=12'
+
+ .field static assembly initonly valuetype ''/'__StaticArrayInitTypeSize=12' '4636993D3E1DA4E9D6B8F87B79E8F7C6D018580D52661950EABC3845C5897A4D' at I_00002690
+} // end of class ''
+
+
+// =============================================================
+
+.data cil I_00002690 = bytearray (
+ 01 00 00 00 02 00 00 00 03 00 00 00)
+// *********** DISASSEMBLY COMPLETE ***********************
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoDecimalConstants.net40.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoDecimalConstants.net40.roslyn.il
new file mode 100644
index 000000000..77ebf3a58
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoDecimalConstants.net40.roslyn.il
@@ -0,0 +1,97 @@
+
+
+
+
+// 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 tmpA278
+{
+ .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 tmpA278.tmp
+.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.Ugly.NoDecimalConstants
+ extends [mscorlib]System.Object
+{
+ .field private static initonly valuetype [mscorlib]System.Decimal constant
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.DecimalConstantAttribute::.ctor(uint8,
+ uint8,
+ uint32,
+ uint32,
+ uint32) = ( 01 00 01 00 00 00 00 00 00 00 00 00 0A 00 00 00
+ 00 00 )
+ .method private hidebysig instance void
+ MethodWithOptionalParameter([opt] valuetype [mscorlib]System.Decimal parameter) cil managed
+ {
+ .param [1]
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.DecimalConstantAttribute::.ctor(uint8,
+ uint8,
+ uint32,
+ uint32,
+ uint32) = ( 01 00 01 00 00 00 00 00 00 00 00 00 0A 00 00 00
+ 00 00 )
+ // Code size 2 (0x2)
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ret
+ } // end of method NoDecimalConstants::MethodWithOptionalParameter
+
+ .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 NoDecimalConstants::.ctor
+
+ .method private hidebysig specialname rtspecialname static
+ void .cctor() cil managed
+ {
+ // Code size 17 (0x11)
+ .maxstack 8
+ IL_0000: ldc.i4.s 10
+ IL_0002: ldc.i4.0
+ IL_0003: ldc.i4.0
+ IL_0004: ldc.i4.0
+ IL_0005: ldc.i4.1
+ IL_0006: newobj instance void [mscorlib]System.Decimal::.ctor(int32,
+ int32,
+ int32,
+ bool,
+ uint8)
+ IL_000b: stsfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoDecimalConstants::constant
+ IL_0010: ret
+ } // end of method NoDecimalConstants::.cctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoDecimalConstants
+
+
+// =============================================================
+
+// *********** DISASSEMBLY COMPLETE ***********************
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoDecimalConstants.opt.net40.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoDecimalConstants.opt.net40.roslyn.il
new file mode 100644
index 000000000..0d34cff05
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoDecimalConstants.opt.net40.roslyn.il
@@ -0,0 +1,95 @@
+
+
+
+
+// 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 tmpA279
+{
+ .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 tmpA279.tmp
+.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.Ugly.NoDecimalConstants
+ extends [mscorlib]System.Object
+{
+ .field private static initonly valuetype [mscorlib]System.Decimal constant
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.DecimalConstantAttribute::.ctor(uint8,
+ uint8,
+ uint32,
+ uint32,
+ uint32) = ( 01 00 01 00 00 00 00 00 00 00 00 00 0A 00 00 00
+ 00 00 )
+ .method private hidebysig instance void
+ MethodWithOptionalParameter([opt] valuetype [mscorlib]System.Decimal parameter) cil managed
+ {
+ .param [1]
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.DecimalConstantAttribute::.ctor(uint8,
+ uint8,
+ uint32,
+ uint32,
+ uint32) = ( 01 00 01 00 00 00 00 00 00 00 00 00 0A 00 00 00
+ 00 00 )
+ // Code size 1 (0x1)
+ .maxstack 8
+ IL_0000: ret
+ } // end of method NoDecimalConstants::MethodWithOptionalParameter
+
+ .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 NoDecimalConstants::.ctor
+
+ .method private hidebysig specialname rtspecialname static
+ void .cctor() cil managed
+ {
+ // Code size 17 (0x11)
+ .maxstack 8
+ IL_0000: ldc.i4.s 10
+ IL_0002: ldc.i4.0
+ IL_0003: ldc.i4.0
+ IL_0004: ldc.i4.0
+ IL_0005: ldc.i4.1
+ IL_0006: newobj instance void [mscorlib]System.Decimal::.ctor(int32,
+ int32,
+ int32,
+ bool,
+ uint8)
+ IL_000b: stsfld valuetype [mscorlib]System.Decimal ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoDecimalConstants::constant
+ IL_0010: ret
+ } // end of method NoDecimalConstants::.cctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoDecimalConstants
+
+
+// =============================================================
+
+// *********** DISASSEMBLY COMPLETE ***********************
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoExtensionMethods.net40.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoExtensionMethods.net40.roslyn.il
new file mode 100644
index 000000000..1c03c6440
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Ugly/NoExtensionMethods.net40.roslyn.il
@@ -0,0 +1,117 @@
+
+
+
+
+// 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 tmpA29B
+{
+ .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 )
+ .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 tmpA29B.tmp
+.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 private abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods
+ extends [mscorlib]System.Object
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
+ .method assembly hidebysig static class [mscorlib]System.Func`1
+ AsFunc(!!T 'value') cil managed
+ {
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
+ // Code size 23 (0x17)
+ .maxstack 2
+ .locals init (class [mscorlib]System.Func`1 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.0
+ IL_0002: box !!T
+ IL_0007: ldftn !!0 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods::Return(!!0)
+ IL_000d: newobj instance void class [mscorlib]System.Func`1::.ctor(object,
+ native int)
+ IL_0012: stloc.0
+ IL_0013: br.s IL_0015
+
+ IL_0015: ldloc.0
+ IL_0016: ret
+ } // end of method NoExtensionMethods::AsFunc
+
+ .method private hidebysig static !!T Return(!!T 'value') cil managed
+ {
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
+ // Code size 7 (0x7)
+ .maxstack 1
+ .locals init (!!T V_0)
+ IL_0000: nop
+ IL_0001: ldarg.0
+ IL_0002: stloc.0
+ IL_0003: br.s IL_0005
+
+ IL_0005: ldloc.0
+ IL_0006: ret
+ } // end of method NoExtensionMethods::Return
+
+ .method assembly hidebysig static class [mscorlib]System.Func`2
+ ExtensionMethodAsStaticFunc() cil managed
+ {
+ // Code size 18 (0x12)
+ .maxstack 2
+ .locals init (class [mscorlib]System.Func`2 V_0)
+ IL_0000: nop
+ IL_0001: ldnull
+ IL_0002: ldftn !!0 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods::Return(!!0)
+ IL_0008: newobj instance void class [mscorlib]System.Func`2::.ctor(object,
+ native int)
+ IL_000d: stloc.0
+ IL_000e: br.s IL_0010
+
+ IL_0010: ldloc.0
+ IL_0011: ret
+ } // end of method NoExtensionMethods::ExtensionMethodAsStaticFunc
+
+ .method assembly hidebysig static class [mscorlib]System.Func`1