diff --git a/.gitignore b/.gitignore index a4055404f..86be8d458 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ _ReSharper*/ *.ReSharper *.patch .vs/ -/ILSpy.AddIn/Packages/* \ No newline at end of file +/ILSpy.AddIn/Packages/* +/ICSharpCode.Decompiler.Tests/TestCases/Correctness/*.exe diff --git a/BuildTools/appveyor-install.ps1 b/BuildTools/appveyor-install.ps1 index ec98f7bcf..63afea63c 100644 --- a/BuildTools/appveyor-install.ps1 +++ b/BuildTools/appveyor-install.ps1 @@ -23,9 +23,16 @@ if ($env:APPVEYOR_REPO_BRANCH -ne 'master') { } else { $branch = ""; } +if ($env:APPVEYOR_PULL_REQUEST_NUMBER) { + $suffix = "-pr$env:APPVEYOR_PULL_REQUEST_NUMBER"; +} else { + $suffix = ""; +} $revision = [Int32]::Parse((git rev-list --count "$baseCommit..HEAD")) + $baseCommitRev; $newVersion="$major.$minor.$build.$revision"; -$env:appveyor_build_version="$newVersion$branch$versionName"; -appveyor UpdateBuild -Version "$newVersion$branch$versionName"; \ No newline at end of file +$env:APPVEYOR_BUILD_VERSION="$newVersion$branch$versionName$suffix"; +$env:ILSPY_VERSION_NUMBER="$newVersion$branch$versionName$suffix"; +appveyor UpdateBuild -Version "$newVersion$branch$versionName$suffix"; +Write-Host "new version: $newVersion$branch$versionName$suffix"; \ No newline at end of file diff --git a/BuildTools/update-assemblyinfo.ps1 b/BuildTools/update-assemblyinfo.ps1 index 38a0f0df4..fbf59b6f9 100644 --- a/BuildTools/update-assemblyinfo.ps1 +++ b/BuildTools/update-assemblyinfo.ps1 @@ -42,6 +42,7 @@ function gitBranch() { $templateFiles = ( @{Input=$globalAssemblyInfoTemplateFile; Output="ILSpy/Properties/AssemblyInfo.cs"}, @{Input="ICSharpCode.Decompiler/Properties/AssemblyInfo.template.cs"; Output="ICSharpCode.Decompiler/Properties/AssemblyInfo.cs"}, + @{Input="ICSharpCode.Decompiler/ICSharpCode.Decompiler.nuspec.template"; Output="ICSharpCode.Decompiler/ICSharpCode.Decompiler.nuspec"}, @{Input="ILSpy/Properties/app.config.template"; Output = "ILSpy/app.config"} ); [string]$mutexId = "ILSpyUpdateAssemblyInfo" + $PSScriptRoot.GetHashCode(); diff --git a/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs b/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs index bfeaf5e85..cd774b27f 100644 --- a/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs @@ -162,6 +162,12 @@ namespace ICSharpCode.Decompiler.Tests RunIL("BitNot.il", CompilerOptions.UseDebug | CompilerOptions.Force32Bit, AssemblerOptions.Force32Bit); } + [Test] + public void Jmp() + { + RunIL("Jmp.il"); + } + [Test] public void UnsafeCode([ValueSource("defaultOptions")] CompilerOptions options) { @@ -192,8 +198,14 @@ namespace ICSharpCode.Decompiler.Tests RunCS(options: options); } - [Test, Ignore("Run() method cannot be fully decompiled.")] - public void Async([ValueSource("defaultOptions")] CompilerOptions options) + [Test] + public void Async([Values(CompilerOptions.None, CompilerOptions.Optimize)] CompilerOptions options) + { + RunCS(options: options); + } + + [Test] + public void LINQRaytracer([ValueSource("defaultOptions")] CompilerOptions options) { RunCS(options: options); } @@ -201,17 +213,18 @@ namespace ICSharpCode.Decompiler.Tests void RunCS([CallerMemberName] string testName = null, CompilerOptions options = CompilerOptions.UseDebug) { string testFileName = testName + ".cs"; + string testOutputFileName = testName + Tester.GetSuffix(options) + ".exe"; CompilerResults outputFile = null, decompiledOutputFile = null; try { - outputFile = Tester.CompileCSharp(Path.Combine(TestCasePath, testFileName), options); + outputFile = Tester.CompileCSharp(Path.Combine(TestCasePath, testFileName), options, + outputFileName: Path.Combine(TestCasePath, testOutputFileName)); string decompiledCodeFile = Tester.DecompileCSharp(outputFile.PathToAssembly); decompiledOutputFile = Tester.CompileCSharp(decompiledCodeFile, options); Tester.RunAndCompareOutput(testFileName, outputFile.PathToAssembly, decompiledOutputFile.PathToAssembly, decompiledCodeFile); File.Delete(decompiledCodeFile); - File.Delete(outputFile.PathToAssembly); File.Delete(decompiledOutputFile.PathToAssembly); } finally { if (outputFile != null) diff --git a/ICSharpCode.Decompiler.Tests/DataFlowTest.cs b/ICSharpCode.Decompiler.Tests/DataFlowTest.cs index e42850616..a6b8ebfeb 100644 --- a/ICSharpCode.Decompiler.Tests/DataFlowTest.cs +++ b/ICSharpCode.Decompiler.Tests/DataFlowTest.cs @@ -55,7 +55,7 @@ namespace ICSharpCode.Decompiler.Tests public void TryFinallyWithAssignmentInFinally() { ILVariable v = new ILVariable(VariableKind.Local, SpecialType.UnknownType, 0); - ILFunction f = new ILFunction(null, new TryFinally( + ILFunction f = new ILFunction(null, null, new TryFinally( new Nop(), new StLoc(v, new LdcI4(0)) )); diff --git a/ICSharpCode.Decompiler.Tests/DelegateConstruction.cs b/ICSharpCode.Decompiler.Tests/DelegateConstruction.cs deleted file mode 100644 index 70c00fc65..000000000 --- a/ICSharpCode.Decompiler.Tests/DelegateConstruction.cs +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Linq; - -public static class DelegateConstruction -{ - class InstanceTests - { - public Action CaptureOfThis() - { - return delegate { - CaptureOfThis(); - }; - } - - public Action CaptureOfThisAndParameter(int a) - { - return delegate { - CaptureOfThisAndParameter(a); - }; - } - - public Action CaptureOfThisAndParameterInForEach(int a) - { - foreach (int item in Enumerable.Empty()) { - if (item > 0) { - return delegate { - CaptureOfThisAndParameter(item + a); - }; - } - } - return null; - } - - public Action CaptureOfThisAndParameterInForEachWithItemCopy(int a) - { - foreach (int item in Enumerable.Empty()) { - int copyOfItem = item; - if (item > 0) { - return delegate { - CaptureOfThisAndParameter(item + a + copyOfItem); - }; - } - } - return null; - } - - public void LambdaInForLoop() - { - for (int i = 0; i < 100000; i++) { - Bar(() => Foo()); - } - } - - public int Foo() - { - return 0; - } - - public void Bar(Func f) - { - } - } - - public static void Test(this string a) - { - } - - public static Action ExtensionMethodUnbound() - { - return new Action(DelegateConstruction.Test); - } - - public static Action ExtensionMethodBound() - { - return new Action("abc".Test); - } - - public static Action ExtensionMethodBoundOnNull() - { - return new Action(((string)null).Test); - } - - public static object StaticMethod() - { - return new Func(DelegateConstruction.ExtensionMethodBound); - } - - public static object InstanceMethod() - { - return new Func("hello".ToUpper); - } - - public static object InstanceMethodOnNull() - { - return new Func(((string)null).ToUpper); - } - - public static List> AnonymousMethodStoreWithinLoop() - { - List> list = new List>(); - for (int i = 0; i < 10; i++) - { - int counter; - list.Add(delegate(int x) - { - counter = x; - } - ); - } - return list; - } - - public static List> AnonymousMethodStoreOutsideLoop() - { - List> list = new List>(); - int counter; - for (int i = 0; i < 10; i++) - { - list.Add(delegate(int x) - { - counter = x; - } - ); - } - return list; - } - - public static Action StaticAnonymousMethodNoClosure() - { - return delegate - { - Console.WriteLine(); - }; - } - - public static void NameConflict() - { - // i is captured variable, - // j is parameter in anonymous method - // k is local in anonymous method, - // l is local in main method - // Ensure that the decompiler doesn't introduce name conflicts - List> list = new List>(); - for (int l = 0; l < 10; l++) { - int i; - for (i = 0; i < 10; i++) { - list.Add( - delegate (int j) { - for (int k = 0; k < i; k += j) { - Console.WriteLine(); - } - }); - } - } - } - - public static void NameConflict2(int j) - { - List> list = new List>(); - for (int k = 0; k < 10; k++) { - list.Add( - delegate(int i) { - Console.WriteLine(i); - }); - } - } - - public static Action NameConflict3(int i) - { - return delegate(int j) { - for (int k = 0; k < j; k++) { - Console.WriteLine(k); - } - }; - } - - public static Func> CurriedAddition(int a) - { - return b => c => a + b + c; - } - - public static Func>> CurriedAddition2(int a) - { - return b => c => d => a + b + c + d; - } -} diff --git a/ICSharpCode.Decompiler.Tests/Helpers/SdkUtility.cs b/ICSharpCode.Decompiler.Tests/Helpers/SdkUtility.cs index 4ad1af0eb..d25d076c3 100644 --- a/ICSharpCode.Decompiler.Tests/Helpers/SdkUtility.cs +++ b/ICSharpCode.Decompiler.Tests/Helpers/SdkUtility.cs @@ -160,6 +160,19 @@ namespace ICSharpCode.Decompiler.Tests.Helpers return windowsSdk80InstallRoot; } } + + static string WindowsSdk461InstallRoot = null; + /// + /// Location of the .NET 4.6.1 SDK install root. + /// + public static string WindowsSdk461NetFxTools { + get { + if (WindowsSdk461InstallRoot == null) { + WindowsSdk461InstallRoot = GetPathFromRegistryX86(@"SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1\WinSDK-NetFx40Tools", "InstallationFolder") ?? string.Empty; + } + return WindowsSdk461InstallRoot; + } + } #endregion /// @@ -170,6 +183,10 @@ namespace ICSharpCode.Decompiler.Tests.Helpers /// The path of the executable, or null if the exe is not found. public static string GetSdkPath(string exeName) { string execPath; + if (!string.IsNullOrEmpty(WindowsSdk461NetFxTools)) { + execPath = Path.Combine(WindowsSdk461NetFxTools, exeName); + if (File.Exists(execPath)) { return execPath; } + } if (!string.IsNullOrEmpty(WindowsSdk80NetFxTools)) { execPath = Path.Combine(WindowsSdk80NetFxTools, exeName); if (File.Exists(execPath)) { return execPath; } diff --git a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs index 1a3420fc9..05de0357e 100644 --- a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs +++ b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs @@ -65,7 +65,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers public static string AssembleIL(string sourceFileName, AssemblerOptions options = AssemblerOptions.UseDebug) { string ilasmPath = Path.Combine(Environment.GetEnvironmentVariable("windir"), @"Microsoft.NET\Framework\v4.0.30319\ilasm.exe"); - string outputFile = Path.GetFileNameWithoutExtension(sourceFileName); + string outputFile = Path.Combine(Path.GetDirectoryName(sourceFileName), Path.GetFileNameWithoutExtension(sourceFileName)); string otherOptions = " "; if (options.HasFlag(AssemblerOptions.Library)) { outputFile += ".dll"; @@ -111,7 +111,8 @@ namespace ICSharpCode.Decompiler.Tests.Helpers using (var writer = new StreamWriter(outputFile)) { module.Name = Path.GetFileNameWithoutExtension(outputFile); var output = new PlainTextOutput(writer); - ReflectionDisassembler rd = new ReflectionDisassembler(output, false, CancellationToken.None); + ReflectionDisassembler rd = new ReflectionDisassembler(output, CancellationToken.None); + rd.DetectControlStructure = false; rd.WriteAssemblyReferences(module); if (module.Assembly != null) rd.WriteAssemblyHeader(module.Assembly); @@ -156,7 +157,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers }; }); - public static CompilerResults CompileCSharp(string sourceFileName, CompilerOptions flags = CompilerOptions.UseDebug) + public static CompilerResults CompileCSharp(string sourceFileName, CompilerOptions flags = CompilerOptions.UseDebug, string outputFileName = null) { List sourceFileNames = new List { sourceFileName }; foreach (Match match in Regex.Matches(File.ReadAllText(sourceFileName), @"#include ""([\w\d./]+)""")) { @@ -181,7 +182,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers deterministic: true )); CompilerResults results = new CompilerResults(new TempFileCollection()); - results.PathToAssembly = Path.GetTempFileName(); + results.PathToAssembly = outputFileName ?? Path.GetTempFileName(); var emitResult = compilation.Emit(results.PathToAssembly); if (!emitResult.Success) { StringBuilder b = new StringBuilder("Compiler error:"); @@ -202,6 +203,9 @@ namespace ICSharpCode.Decompiler.Tests.Helpers if (preprocessorSymbols.Count > 0) { options.CompilerOptions += " /d:" + string.Join(";", preprocessorSymbols); } + if (outputFileName != null) { + options.OutputAssembly = outputFileName; + } options.ReferencedAssemblies.Add("System.Core.dll"); CompilerResults results = provider.CompileAssemblyFromFile(options, sourceFileNames.ToArray()); @@ -216,6 +220,20 @@ namespace ICSharpCode.Decompiler.Tests.Helpers } } + internal static string GetSuffix(CompilerOptions cscOptions) + { + string suffix = ""; + if ((cscOptions & CompilerOptions.Optimize) != 0) + suffix += ".opt"; + if ((cscOptions & CompilerOptions.Force32Bit) != 0) + suffix += ".32"; + if ((cscOptions & CompilerOptions.UseDebug) != 0) + suffix += ".dbg"; + if ((cscOptions & CompilerOptions.UseRoslyn) != 0) + suffix += ".roslyn"; + return suffix; + } + public static int Run(string assemblyFileName, out string output, out string error) { ProcessStartInfo info = new ProcessStartInfo(assemblyFileName); diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj index eec8a43b6..cd71918fa 100644 --- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj +++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj @@ -44,6 +44,7 @@ + @@ -53,6 +54,8 @@ + + @@ -67,6 +70,8 @@ + + @@ -106,6 +111,7 @@ + diff --git a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs index 97f7fa0e4..799ea3924 100644 --- a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs @@ -41,7 +41,7 @@ namespace ICSharpCode.Decompiler.Tests { Run(); } - + [Test] public void FSharpUsing_Debug() { diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs index f0033e239..dd00235d2 100644 --- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs @@ -97,6 +97,18 @@ namespace ICSharpCode.Decompiler.Tests Run(cscOptions: cscOptions); } + [Test] + public void Switch([ValueSource("defaultOptions")] CompilerOptions cscOptions) + { + Run(cscOptions: cscOptions); + } + + [Test] + public void DelegateConstruction([ValueSource("defaultOptions")] CompilerOptions cscOptions) + { + Run(cscOptions: cscOptions); + } + [Test] public void AnonymousTypes([Values(CompilerOptions.None, CompilerOptions.Optimize)] CompilerOptions cscOptions) { @@ -176,18 +188,21 @@ namespace ICSharpCode.Decompiler.Tests Run(cscOptions: cscOptions, asmOptions: AssemblerOptions.UseOwnDisassembler); } + [Test] + public void InitializerTests([ValueSource("defaultOptions")] CompilerOptions cscOptions) + { + Run(cscOptions: cscOptions); + } + + [Test] + public void FixProxyCalls([Values(CompilerOptions.None, CompilerOptions.Optimize, CompilerOptions.UseRoslyn)] CompilerOptions cscOptions) + { + Run(cscOptions: cscOptions); + } + void Run([CallerMemberName] string testName = null, AssemblerOptions asmOptions = AssemblerOptions.None, CompilerOptions cscOptions = CompilerOptions.None) { - var ilFile = Path.Combine(TestCasePath, testName); - if ((cscOptions & CompilerOptions.Optimize) != 0) - ilFile += ".opt"; - if ((cscOptions & CompilerOptions.Force32Bit) != 0) - ilFile += ".32"; - if ((cscOptions & CompilerOptions.UseDebug) != 0) - ilFile += ".dbg"; - if ((cscOptions & CompilerOptions.UseRoslyn) != 0) - ilFile += ".roslyn"; - ilFile += ".il"; + var ilFile = Path.Combine(TestCasePath, testName) + Tester.GetSuffix(cscOptions) + ".il"; var csFile = Path.Combine(TestCasePath, testName + ".cs"); if (!File.Exists(ilFile)) { diff --git a/ICSharpCode.Decompiler.Tests/Switch.cs b/ICSharpCode.Decompiler.Tests/Switch.cs deleted file mode 100644 index 4a20a6392..000000000 --- a/ICSharpCode.Decompiler.Tests/Switch.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; - -public static class Switch -{ - public static string ShortSwitchOverString(string text) - { - switch (text) { - case "First case": - return "Text"; - default: - return "Default"; - } - } - - public static string SwitchOverString1(string text) - { - switch (text) - { - case "First case": - return "Text1"; - case "Second case": - case "2nd case": - return "Text2"; - case "Third case": - return "Text3"; - case "Fourth case": - return "Text4"; - case "Fifth case": - return "Text5"; - case "Sixth case": - return "Text6"; - case null: - return null; - default: - return "Default"; - } - } - - public static string SwitchOverString2() - { - switch (Environment.UserName) - { - case "First case": - return "Text1"; - case "Second case": - return "Text2"; - case "Third case": - return "Text3"; - case "Fourth case": - return "Text4"; - case "Fifth case": - return "Text5"; - case "Sixth case": - return "Text6"; - default: - return "Default"; - } - } - - public static string SwitchOverBool(bool b) - { - switch (b) { - case true: - return bool.TrueString; - case false: - return bool.FalseString; - default: - return null; - } - } -} diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Async.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Async.cs index 2d35dab5f..751f14d41 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Async.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Async.cs @@ -30,15 +30,15 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness { public static void Main() { - new Async().Run(); + new Async().Run().Wait(); } - public async void Run() + public async Task Run() { await SimpleBoolTaskMethod(); StreamCopyTo(new MemoryStream(new byte[1024]), 16); StreamCopyToWithConfigureAwait(new MemoryStream(new byte[1024]), 16); - await AwaitInForEach(Enumerable.Range(0, 100).Select(i => Task.FromResult(i))); + await AwaitInForEach(Enumerable.Range(0, 100).Select(i => Task.FromResult(i))); await TaskMethodWithoutAwaitButWithExceptionHandling(); #if !LEGACY_CSC await AwaitCatch(Task.FromResult(1)); diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Jmp.il b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Jmp.il new file mode 100644 index 000000000..fc87d3ff8 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Jmp.il @@ -0,0 +1,47 @@ +.assembly extern mscorlib +{ + .publickeytoken = ( b7 7a 5c 56 19 34 e0 89 ) + .ver 4:0:0:0 +} + +.assembly 'Jmp' +{ + .ver 0:0:0:0 +} + +.module Jmp.exe +.corflags 0x00000001 // ILOnly + +.class private auto ansi abstract sealed beforefieldinit Program + extends [mscorlib]System.Object +{ + .method public hidebysig static void Main (string[] args) cil managed + { + .maxstack 8 + .entrypoint + + ldstr "Method1(100) = {0}" + ldc.i4 100 + call int32 Program::Method1(int32) + box int32 + call void [mscorlib]System.Console::WriteLine(string, object) + ret + } // end of method Main + + .method public static int32 Method1(int32 val) + { + ldarg.0 + ldc.i4.1 + add + starg.s 0 + jmp int32 Program::Method2(int32) + } + + .method public static int32 Method2(int32 val) + { + ldarg.0 + ldc.i4.5 + mul + ret + } +} diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/LINQRaytracer.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/LINQRaytracer.cs new file mode 100644 index 000000000..c18201788 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/LINQRaytracer.cs @@ -0,0 +1,390 @@ +// This test case is taken from https://blogs.msdn.microsoft.com/lukeh/2007/10/01/taking-linq-to-objects-to-extremes-a-fully-linqified-raytracer/ + +using System.Linq; +using System; +using System.Collections.Generic; + +namespace RayTracer +{ + public class RayTracer + { + static void Main() + { + const int width = 50; + const int height = 50; + + RayTracer rayTracer = new RayTracer(width, height, (int x, int y, Color color) => { + Console.Write("{0},{1}:{2};", x, y, color); + }); + rayTracer.Render(rayTracer.DefaultScene); + } + + private int screenWidth; + private int screenHeight; + private const int MaxDepth = 5; + + public Action setPixel; + + public RayTracer(int screenWidth, int screenHeight, Action setPixel) + { + this.screenWidth = screenWidth; + this.screenHeight = screenHeight; + this.setPixel = setPixel; + } + + private class Wrap + { + public readonly Func, T> It; + public Wrap(Func, T> it) { It = it; } + } + + public static Func Y(Func, Func> f) + { + Func>, Func> g = wx => f(wx.It(wx)); + return g(new Wrap>(wx => f(y => wx.It(wx)(y)))); + } + + class TraceRayArgs + { + public readonly Ray Ray; + public readonly Scene Scene; + public readonly int Depth; + + public TraceRayArgs(Ray ray, Scene scene, int depth) { Ray = ray; Scene = scene; Depth = depth; } + } + + internal void Render(Scene scene) + { + var pixelsQuery = + from y in Enumerable.Range(0, screenHeight) + let recenterY = -(y - (screenHeight / 2.0)) / (2.0 * screenHeight) + select from x in Enumerable.Range(0, screenWidth) + let recenterX = (x - (screenWidth / 2.0)) / (2.0 * screenWidth) + let point = + Vector.Norm(Vector.Plus(scene.Camera.Forward, + Vector.Plus(Vector.Times(recenterX, scene.Camera.Right), + Vector.Times(recenterY, scene.Camera.Up)))) + let ray = new Ray() { Start = scene.Camera.Pos, Dir = point } + let computeTraceRay = (Func, Func>) + (f => traceRayArgs => + (from isect in + from thing in traceRayArgs.Scene.Things + select thing.Intersect(traceRayArgs.Ray) + where isect != null + orderby isect.Dist + let d = isect.Ray.Dir + let pos = Vector.Plus(Vector.Times(isect.Dist, isect.Ray.Dir), isect.Ray.Start) + let normal = isect.Thing.Normal(pos) + let reflectDir = Vector.Minus(d, Vector.Times(2 * Vector.Dot(normal, d), normal)) + let naturalColors = + from light in traceRayArgs.Scene.Lights + let ldis = Vector.Minus(light.Pos, pos) + let livec = Vector.Norm(ldis) + let testRay = new Ray() { Start = pos, Dir = livec } + let testIsects = from inter in + from thing in traceRayArgs.Scene.Things + select thing.Intersect(testRay) + where inter != null + orderby inter.Dist + select inter + let testIsect = testIsects.FirstOrDefault() + let neatIsect = testIsect == null ? 0 : testIsect.Dist + let isInShadow = !((neatIsect > Vector.Mag(ldis)) || (neatIsect == 0)) + where !isInShadow + let illum = Vector.Dot(livec, normal) + let lcolor = illum > 0 ? Color.Times(illum, light.Color) : Color.Make(0, 0, 0) + let specular = Vector.Dot(livec, Vector.Norm(reflectDir)) + let scolor = specular > 0 + ? Color.Times(Math.Pow(specular, isect.Thing.Surface.Roughness), + light.Color) + : Color.Make(0, 0, 0) + select Color.Plus(Color.Times(isect.Thing.Surface.Diffuse(pos), lcolor), + Color.Times(isect.Thing.Surface.Specular(pos), scolor)) + let reflectPos = Vector.Plus(pos, Vector.Times(.001, reflectDir)) + let reflectColor = traceRayArgs.Depth >= MaxDepth + ? Color.Make(.5, .5, .5) + : Color.Times(isect.Thing.Surface.Reflect(reflectPos), + f(new TraceRayArgs(new Ray() { + Start = reflectPos, + Dir = reflectDir + }, + traceRayArgs.Scene, + traceRayArgs.Depth + 1))) + select naturalColors.Aggregate(reflectColor, + (color, natColor) => Color.Plus(color, natColor)) + ).DefaultIfEmpty(Color.Background).First()) + let traceRay = Y(computeTraceRay) + select new { X = x, Y = y, Color = traceRay(new TraceRayArgs(ray, scene, 0)) }; + + foreach (var row in pixelsQuery) + foreach (var pixel in row) + setPixel(pixel.X, pixel.Y, pixel.Color); + } + + internal readonly Scene DefaultScene = + new Scene() { + Things = new SceneObject[] { + new Plane() { + Norm = Vector.Make(0,1,0), + Offset = 0, + Surface = Surfaces.CheckerBoard + }, + new Sphere() { + Center = Vector.Make(0,1,0), + Radius = 1, + Surface = Surfaces.Shiny + }, + new Sphere() { + Center = Vector.Make(-1,.5,1.5), + Radius = .5, + Surface = Surfaces.Shiny + }}, + Lights = new Light[] { + new Light() { + Pos = Vector.Make(-2,2.5,0), + Color = Color.Make(.49,.07,.07) + }, + new Light() { + Pos = Vector.Make(1.5,2.5,1.5), + Color = Color.Make(.07,.07,.49) + }, + new Light() { + Pos = Vector.Make(1.5,2.5,-1.5), + Color = Color.Make(.07,.49,.071) + }, + new Light() { + Pos = Vector.Make(0,3.5,0), + Color = Color.Make(.21,.21,.35) + }}, + Camera = Camera.Create(Vector.Make(3, 2, 4), Vector.Make(-1, .5, 0)) + }; + } + + static class Surfaces + { + // Only works with X-Z plane. + public static readonly Surface CheckerBoard = + new Surface() { + Diffuse = pos => ((Math.Floor(pos.Z) + Math.Floor(pos.X)) % 2 != 0) + ? Color.Make(1, 1, 1) + : Color.Make(0, 0, 0), + Specular = pos => Color.Make(1, 1, 1), + Reflect = pos => ((Math.Floor(pos.Z) + Math.Floor(pos.X)) % 2 != 0) + ? .1 + : .7, + Roughness = 150 + }; + + + public static readonly Surface Shiny = + new Surface() { + Diffuse = pos => Color.Make(1, 1, 1), + Specular = pos => Color.Make(.5, .5, .5), + Reflect = pos => .6, + Roughness = 50 + }; + } + + class Vector + { + public readonly double X; + public readonly double Y; + public readonly double Z; + + public Vector(double x, double y, double z) { X = x; Y = y; Z = z; } + + public static Vector Make(double x, double y, double z) { return new Vector(x, y, z); } + public static Vector Times(double n, Vector v) + { + return new Vector(v.X * n, v.Y * n, v.Z * n); + } + public static Vector Minus(Vector v1, Vector v2) + { + return new Vector(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z); + } + public static Vector Plus(Vector v1, Vector v2) + { + return new Vector(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z); + } + public static double Dot(Vector v1, Vector v2) + { + return (v1.X * v2.X) + (v1.Y * v2.Y) + (v1.Z * v2.Z); + } + public static double Mag(Vector v) { return Math.Sqrt(Dot(v, v)); } + public static Vector Norm(Vector v) + { + double mag = Mag(v); + double div = mag == 0 ? double.PositiveInfinity : 1 / mag; + return Times(div, v); + } + public static Vector Cross(Vector v1, Vector v2) + { + return new Vector(((v1.Y * v2.Z) - (v1.Z * v2.Y)), + ((v1.Z * v2.X) - (v1.X * v2.Z)), + ((v1.X * v2.Y) - (v1.Y * v2.X))); + } + public static bool Equals(Vector v1, Vector v2) + { + return (v1.X == v2.X) && (v1.Y == v2.Y) && (v1.Z == v2.Z); + } + } + + public class Color + { + public double R; + public double G; + public double B; + + public Color(double r, double g, double b) { R = r; G = g; B = b; } + + public static Color Make(double r, double g, double b) { return new Color(r, g, b); } + + public static Color Times(double n, Color v) + { + return new Color(n * v.R, n * v.G, n * v.B); + } + public static Color Times(Color v1, Color v2) + { + return new Color(v1.R * v2.R, v1.G * v2.G, v1.B * v2.B); + } + + public static Color Plus(Color v1, Color v2) + { + return new Color(v1.R + v2.R, v1.G + v2.G, v1.B + v2.B); + } + public static Color Minus(Color v1, Color v2) + { + return new Color(v1.R - v2.R, v1.G - v2.G, v1.B - v2.B); + } + + public static readonly Color Background = Make(0, 0, 0); + public static readonly Color DefaultColor = Make(0, 0, 0); + + private double Legalize(double d) + { + return d > 1 ? 1 : d; + } + + public override string ToString() + { + return string.Format("[{0},{1},{2}]", R, G, B); + } + } + + class Ray + { + public Vector Start; + public Vector Dir; + } + + class ISect + { + public SceneObject Thing; + public Ray Ray; + public double Dist; + } + + class Surface + { + public Func Diffuse; + public Func Specular; + public Func Reflect; + public double Roughness; + } + + class Camera + { + public Vector Pos; + public Vector Forward; + public Vector Up; + public Vector Right; + + public static Camera Create(Vector pos, Vector lookAt) + { + Vector forward = Vector.Norm(Vector.Minus(lookAt, pos)); + Vector down = new Vector(0, -1, 0); + Vector right = Vector.Times(1.5, Vector.Norm(Vector.Cross(forward, down))); + Vector up = Vector.Times(1.5, Vector.Norm(Vector.Cross(forward, right))); + + return new Camera() { Pos = pos, Forward = forward, Up = up, Right = right }; + } + } + + class Light + { + public Vector Pos; + public Color Color; + } + + abstract class SceneObject + { + public Surface Surface; + public abstract ISect Intersect(Ray ray); + public abstract Vector Normal(Vector pos); + } + + class Sphere : SceneObject + { + public Vector Center; + public double Radius; + + public override ISect Intersect(Ray ray) + { + Vector eo = Vector.Minus(Center, ray.Start); + double v = Vector.Dot(eo, ray.Dir); + double dist; + if (v < 0) { + dist = 0; + } else { + double disc = Math.Pow(Radius, 2) - (Vector.Dot(eo, eo) - Math.Pow(v, 2)); + dist = disc < 0 ? 0 : v - Math.Sqrt(disc); + } + if (dist == 0) return null; + return new ISect() { + Thing = this, + Ray = ray, + Dist = dist + }; + } + + public override Vector Normal(Vector pos) + { + return Vector.Norm(Vector.Minus(pos, Center)); + } + } + + class Plane : SceneObject + { + public Vector Norm; + public double Offset; + + public override ISect Intersect(Ray ray) + { + double denom = Vector.Dot(Norm, ray.Dir); + if (denom > 0) return null; + return new ISect() { + Thing = this, + Ray = ray, + Dist = (Vector.Dot(Norm, ray.Start) + Offset) / (-denom) + }; + } + + public override Vector Normal(Vector pos) + { + return Norm; + } + } + + class Scene + { + public SceneObject[] Things; + public Light[] Lights; + public Camera Camera; + + public IEnumerable Intersect(Ray r) + { + return from thing in Things + select thing.Intersect(r); + } + } +} \ No newline at end of file diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Switch.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Switch.cs index 61ed2f347..f28e691cf 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Switch.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Switch.cs @@ -26,10 +26,17 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness { TestCase(SparseIntegerSwitch, -100, 1, 2, 3, 4); TestCase(ShortSwitchOverString, "First case", "Else"); + TestCase(ShortSwitchOverString2, "First case", "Second case", "Third case", "Else"); + TestCase(ShortSwitchOverStringNoExplicitDefault, "First case", "Second case", "Third case", "Else"); TestCase(SwitchOverString1, "First case", "Second case", "2nd case", "Third case", "Fourth case", "Fifth case", "Sixth case", null, "default", "else"); Console.WriteLine(SwitchOverString2()); Console.WriteLine(SwitchOverBool(true)); Console.WriteLine(SwitchOverBool(false)); + SwitchInLoop(0); + SwitchWithGoto(1); + SwitchWithGoto(2); + SwitchWithGoto(3); + SwitchWithGoto(4); } static void TestCase(Func target, params T[] args) @@ -41,6 +48,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness public static string SparseIntegerSwitch(int i) { + Console.WriteLine("SparseIntegerSwitch: " + i); switch (i) { case -10000000: return "-10 mln"; case -100: return "-hundred"; @@ -59,6 +67,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness public static string ShortSwitchOverString(string text) { + Console.WriteLine("ShortSwitchOverString: " + text); switch (text) { case "First case": return "Text"; @@ -67,8 +76,38 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness } } + public static string ShortSwitchOverString2(string text) + { + Console.WriteLine("ShortSwitchOverString2: " + text); + switch (text) { + case "First case": + return "Text1"; + case "Second case": + return "Text2"; + case "Third case": + return "Text3"; + default: + return "Default"; + } + } + + public static string ShortSwitchOverStringNoExplicitDefault(string text) + { + Console.WriteLine("ShortSwitchOverStringNoExplicitDefault: " + text); + switch (text) { + case "First case": + return "Text1"; + case "Second case": + return "Text2"; + case "Third case": + return "Text3"; + } + return "Default"; + } + public static string SwitchOverString1(string text) { + Console.WriteLine("SwitchOverString1: " + text); switch (text) { case "First case": return "Text1"; @@ -92,6 +131,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness public static string SwitchOverString2() { + Console.WriteLine("SwitchOverString2:"); switch (Environment.UserName) { case "First case": return "Text1"; @@ -105,6 +145,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness return "Text5"; case "Sixth case": return "Text6"; + case "Seventh case": + return "Text7"; + case "Eighth case": + return "Text8"; + case "Ninth case": + return "Text9"; + case "Tenth case": + return "Text10"; + case "Eleventh case": + return "Text11"; default: return "Default"; } @@ -112,6 +162,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness public static string SwitchOverBool(bool b) { + Console.WriteLine("SwitchOverBool: " + b); switch (b) { case true: return bool.TrueString; @@ -124,6 +175,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness public static void SwitchInLoop(int i) { + Console.WriteLine("SwitchInLoop: " + i); while (true) { switch (i) { case 1: @@ -141,10 +193,32 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness default: Console.WriteLine("default"); Console.WriteLine("more code"); - throw new ArgumentException(); + return; } i++; } } + + public static void SwitchWithGoto(int i) + { + Console.WriteLine("SwitchWithGoto: " + i); + switch (i) { + case 1: + Console.WriteLine("one"); + goto default; + case 2: + Console.WriteLine("two"); + goto case 3; + case 3: + Console.WriteLine("three"); + break; + case 4: + Console.WriteLine("four"); + return; + default: + Console.WriteLine("default"); + break; + } + } } } \ No newline at end of file diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/.gitignore b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/.gitignore index 95060aaca..a520eba40 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/.gitignore +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/.gitignore @@ -1 +1,3 @@ /*.res +/*.dll +/*.exe diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CheckedUnchecked.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CheckedUnchecked.cs index 62e28d983..f58fa70b4 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CheckedUnchecked.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CheckedUnchecked.cs @@ -83,16 +83,15 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty }); } - public void ArrayInitializerChecked() { this.TestHelp(new int[2] { 1, 2 - }, (Func)((int[] n) => checked(new int[2] { + }, (int[] n) => checked(new int[2] { n[0] + 1, n[1] + 1 - }))); + })); } public T TestHelp(T t, Func f) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs new file mode 100644 index 000000000..d4033768b --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs @@ -0,0 +1,199 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty +{ + public static class DelegateConstruction + { + private class InstanceTests + { + public Action CaptureOfThis() + { + return delegate { + this.CaptureOfThis(); + }; + } + + public Action CaptureOfThisAndParameter(int a) + { + return delegate { + this.CaptureOfThisAndParameter(a); + }; + } + + public Action CaptureOfThisAndParameterInForEach(int a) + { + foreach (int item in Enumerable.Empty()) { + if (item > 0) { + return delegate { + this.CaptureOfThisAndParameter(item + a); + }; + } + } + return null; + } + + public Action CaptureOfThisAndParameterInForEachWithItemCopy(int a) + { + foreach (int item in Enumerable.Empty()) { + int copyOfItem = item; + if (item > 0) { + return delegate { + this.CaptureOfThisAndParameter(item + a + copyOfItem); + }; + } + } + return null; + } + + public void LambdaInForLoop() + { + for (int i = 0; i < 100000; i++) { + this.Bar(() => this.Foo()); + } + } + + public int Foo() + { + return 0; + } + + public void Bar(Func f) + { + } + } + + public static void Test(this string a) + { + } + + public static Action ExtensionMethodUnbound() + { + return DelegateConstruction.Test; + } + + public static Action ExtensionMethodBound() + { + return "abc".Test; + } + + public static Action ExtensionMethodBoundOnNull() + { + return ((string)null).Test; + } + + public static object StaticMethod() + { + return new Func(DelegateConstruction.ExtensionMethodBound); + } + + public static object InstanceMethod() + { + return new Func("hello".ToUpper); + } + + public static object InstanceMethodOnNull() + { + return new Func(((string)null).ToUpper); + } + + public static List> AnonymousMethodStoreWithinLoop() + { + List> list = new List>(); + for (int i = 0; i < 10; i++) { + int counter; + list.Add(delegate(int x) { + counter = x; + }); + } + return list; + } + + public static List> AnonymousMethodStoreOutsideLoop() + { + List> list = new List>(); + int counter; + for (int i = 0; i < 10; i++) { + list.Add(delegate(int x) { + counter = x; + }); + } + return list; + } + + public static Action StaticAnonymousMethodNoClosure() + { + return delegate { + Console.WriteLine(); + }; + } + + public static void NameConflict() + { + // i is captured variable, + // j is parameter in anonymous method + // l is local in anonymous method, + // k is local in main method + // Ensure that the decompiler doesn't introduce name conflicts + List> list = new List>(); + for (int k = 0; k < 10; k++) { + int i; + for (i = 0; i < 10; i++) { + list.Add(delegate(int j) { + for (int l = 0; l < i; l += j) { + Console.WriteLine(); + } + }); + } + } + } + + public static void NameConflict2(int j) + { + List> list = new List>(); + for (int k = 0; k < 10; k++) { + list.Add(delegate(int i) { + Console.WriteLine(i); + }); + } + } + + public static Action NameConflict3(int i) + { + return delegate(int j) { + for (int k = 0; k < j; k++) { + Console.WriteLine(k); + } + }; + } + + public static Func> CurriedAddition(int a) + { + return (int b) => (int c) => a + b + c; + } + + public static Func>> CurriedAddition2(int a) + { + return (int b) => (int c) => (int d) => a + b + c + d; + } + } +} diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.il new file mode 100644 index 000000000..b3a565c14 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.il @@ -0,0 +1,1400 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. All rights reserved. + + + +// 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 extern System.Core +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly kdaefnvq +{ + .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.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module kdaefnvq.dll +// MVID: {568C8EB4-6E17-4688-8B36-6BFD1BF31DEB} +.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: 0x00C30000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction + extends [mscorlib]System.Object +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .class auto ansi nested private beforefieldinit InstanceTests + extends [mscorlib]System.Object + { + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass22' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests '<>4__this' + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass22'::.ctor + + .method public hidebysig instance void + 'b__21'() cil managed + { + // Code size 20 (0x14) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22'::'<>4__this' + IL_0007: ldarg.0 + IL_0008: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22'::a + IL_000d: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThisAndParameter(int32) + IL_0012: pop + IL_0013: ret + } // end of method '<>c__DisplayClass22'::'b__21' + + } // end of class '<>c__DisplayClass22' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass25' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests '<>4__this' + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass25'::.ctor + + } // end of class '<>c__DisplayClass25' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass28' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25' 'CS$<>8__locals26' + .field public int32 item + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass28'::.ctor + + .method public hidebysig instance void + 'b__24'() cil managed + { + // Code size 37 (0x25) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::'CS$<>8__locals26' + IL_0007: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25'::'<>4__this' + IL_000c: ldarg.0 + IL_000d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::item + IL_0012: ldarg.0 + IL_0013: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::'CS$<>8__locals26' + IL_0018: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25'::a + IL_001d: add + IL_001e: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThisAndParameter(int32) + IL_0023: pop + IL_0024: ret + } // end of method '<>c__DisplayClass28'::'b__24' + + } // end of class '<>c__DisplayClass28' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass2b' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests '<>4__this' + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass2b'::.ctor + + } // end of class '<>c__DisplayClass2b' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass2d' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 item + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass2d'::.ctor + + } // end of class '<>c__DisplayClass2d' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass30' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d' 'CS$<>8__locals2e' + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b' 'CS$<>8__locals2c' + .field public int32 copyOfItem + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass30'::.ctor + + .method public hidebysig instance void + 'b__2a'() cil managed + { + // Code size 49 (0x31) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::'CS$<>8__locals2c' + IL_0007: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b'::'<>4__this' + IL_000c: ldarg.0 + IL_000d: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::'CS$<>8__locals2e' + IL_0012: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d'::item + IL_0017: ldarg.0 + IL_0018: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::'CS$<>8__locals2c' + IL_001d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b'::a + IL_0022: add + IL_0023: ldarg.0 + IL_0024: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::copyOfItem + IL_0029: add + IL_002a: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThisAndParameter(int32) + IL_002f: pop + IL_0030: ret + } // end of method '<>c__DisplayClass30'::'b__2a' + + } // end of class '<>c__DisplayClass30' + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThis() cil managed + { + // Code size 18 (0x12) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::'b__20'() + IL_0008: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: br.s IL_0010 + + IL_0010: ldloc.0 + IL_0011: ret + } // end of method InstanceTests::CaptureOfThis + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThisAndParameter(int32 a) cil managed + { + // Code size 38 (0x26) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22' V_0, + class [mscorlib]System.Action V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22'::a + IL_000d: ldloc.0 + IL_000e: ldarg.0 + IL_000f: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22'::'<>4__this' + IL_0014: nop + IL_0015: ldloc.0 + IL_0016: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22'::'b__21'() + IL_001c: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0021: stloc.1 + IL_0022: br.s IL_0024 + + IL_0024: ldloc.1 + IL_0025: ret + } // end of method InstanceTests::CaptureOfThisAndParameter + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThisAndParameterInForEach(int32 a) cil managed + { + // Code size 150 (0x96) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28' V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25' V_2, + class [mscorlib]System.Action V_3, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_4, + bool V_5) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25'::.ctor() + IL_0005: stloc.2 + IL_0006: ldloc.2 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25'::a + IL_000d: ldloc.2 + IL_000e: ldarg.0 + IL_000f: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25'::'<>4__this' + IL_0014: nop + IL_0015: nop + IL_0016: call class [mscorlib]System.Collections.Generic.IEnumerable`1 [System.Core]System.Linq.Enumerable::Empty() + IL_001b: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0020: stloc.s V_4 + .try + { + IL_0022: br.s IL_006b + + IL_0024: ldnull + IL_0025: stloc.0 + IL_0026: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::.ctor() + IL_002b: stloc.1 + IL_002c: ldloc.1 + IL_002d: ldloc.2 + IL_002e: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::'CS$<>8__locals26' + IL_0033: ldloc.1 + IL_0034: ldloc.s V_4 + IL_0036: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_003b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::item + IL_0040: nop + IL_0041: ldloc.1 + IL_0042: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::item + IL_0047: ldc.i4.0 + IL_0048: cgt + IL_004a: ldc.i4.0 + IL_004b: ceq + IL_004d: stloc.s V_5 + IL_004f: ldloc.s V_5 + IL_0051: brtrue.s IL_006a + + IL_0053: nop + IL_0054: ldloc.0 + IL_0055: brtrue.s IL_0066 + + IL_0057: ldloc.1 + IL_0058: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::'b__24'() + IL_005e: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0063: stloc.0 + IL_0064: br.s IL_0066 + + IL_0066: ldloc.0 + IL_0067: stloc.3 + IL_0068: leave.s IL_0093 + + IL_006a: nop + IL_006b: ldloc.s V_4 + IL_006d: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() + IL_0072: stloc.s V_5 + IL_0074: ldloc.s V_5 + IL_0076: brtrue.s IL_0024 + + IL_0078: leave.s IL_008e + + } // end .try + finally + { + IL_007a: ldloc.s V_4 + IL_007c: ldnull + IL_007d: ceq + IL_007f: stloc.s V_5 + IL_0081: ldloc.s V_5 + IL_0083: brtrue.s IL_008d + + IL_0085: ldloc.s V_4 + IL_0087: callvirt instance void [mscorlib]System.IDisposable::Dispose() + IL_008c: nop + IL_008d: endfinally + } // end handler + IL_008e: nop + IL_008f: ldnull + IL_0090: stloc.3 + IL_0091: br.s IL_0093 + + IL_0093: nop + IL_0094: ldloc.3 + IL_0095: ret + } // end of method InstanceTests::CaptureOfThisAndParameterInForEach + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThisAndParameterInForEachWithItemCopy(int32 a) cil managed + { + // Code size 178 (0xb2) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30' V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d' V_2, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b' V_3, + class [mscorlib]System.Action V_4, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_5, + bool V_6) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b'::.ctor() + IL_0005: stloc.3 + IL_0006: ldloc.3 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b'::a + IL_000d: ldloc.3 + IL_000e: ldarg.0 + IL_000f: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b'::'<>4__this' + IL_0014: nop + IL_0015: nop + IL_0016: call class [mscorlib]System.Collections.Generic.IEnumerable`1 [System.Core]System.Linq.Enumerable::Empty() + IL_001b: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0020: stloc.s V_5 + .try + { + IL_0022: br.s IL_0085 + + IL_0024: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d'::.ctor() + IL_0029: stloc.2 + IL_002a: ldloc.2 + IL_002b: ldloc.s V_5 + IL_002d: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0032: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d'::item + IL_0037: ldnull + IL_0038: stloc.0 + IL_0039: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::.ctor() + IL_003e: stloc.1 + IL_003f: ldloc.1 + IL_0040: ldloc.2 + IL_0041: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::'CS$<>8__locals2e' + IL_0046: ldloc.1 + IL_0047: ldloc.3 + IL_0048: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::'CS$<>8__locals2c' + IL_004d: nop + IL_004e: ldloc.1 + IL_004f: ldloc.2 + IL_0050: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d'::item + IL_0055: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::copyOfItem + IL_005a: ldloc.2 + IL_005b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d'::item + IL_0060: ldc.i4.0 + IL_0061: cgt + IL_0063: ldc.i4.0 + IL_0064: ceq + IL_0066: stloc.s V_6 + IL_0068: ldloc.s V_6 + IL_006a: brtrue.s IL_0084 + + IL_006c: nop + IL_006d: ldloc.0 + IL_006e: brtrue.s IL_007f + + IL_0070: ldloc.1 + IL_0071: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::'b__2a'() + IL_0077: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_007c: stloc.0 + IL_007d: br.s IL_007f + + IL_007f: ldloc.0 + IL_0080: stloc.s V_4 + IL_0082: leave.s IL_00ae + + IL_0084: nop + IL_0085: ldloc.s V_5 + IL_0087: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() + IL_008c: stloc.s V_6 + IL_008e: ldloc.s V_6 + IL_0090: brtrue.s IL_0024 + + IL_0092: leave.s IL_00a8 + + } // end .try + finally + { + IL_0094: ldloc.s V_5 + IL_0096: ldnull + IL_0097: ceq + IL_0099: stloc.s V_6 + IL_009b: ldloc.s V_6 + IL_009d: brtrue.s IL_00a7 + + IL_009f: ldloc.s V_5 + IL_00a1: callvirt instance void [mscorlib]System.IDisposable::Dispose() + IL_00a6: nop + IL_00a7: endfinally + } // end handler + IL_00a8: nop + IL_00a9: ldnull + IL_00aa: stloc.s V_4 + IL_00ac: br.s IL_00ae + + IL_00ae: nop + IL_00af: ldloc.s V_4 + IL_00b1: ret + } // end of method InstanceTests::CaptureOfThisAndParameterInForEachWithItemCopy + + .method public hidebysig instance void + LambdaInForLoop() cil managed + { + // Code size 53 (0x35) + .maxstack 3 + .locals init (int32 V_0, + class [mscorlib]System.Func`1 V_1, + bool V_2) + IL_0000: ldnull + IL_0001: stloc.1 + IL_0002: nop + IL_0003: ldc.i4.0 + IL_0004: stloc.0 + IL_0005: br.s IL_0027 + + IL_0007: nop + IL_0008: ldarg.0 + IL_0009: ldloc.1 + IL_000a: brtrue.s IL_001b + + IL_000c: ldarg.0 + IL_000d: ldftn instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::'b__32'() + IL_0013: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_0018: stloc.1 + IL_0019: br.s IL_001b + + IL_001b: ldloc.1 + IL_001c: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::Bar(class [mscorlib]System.Func`1) + IL_0021: nop + IL_0022: nop + IL_0023: ldloc.0 + IL_0024: ldc.i4.1 + IL_0025: add + IL_0026: stloc.0 + IL_0027: ldloc.0 + IL_0028: ldc.i4 0x186a0 + IL_002d: clt + IL_002f: stloc.2 + IL_0030: ldloc.2 + IL_0031: brtrue.s IL_0007 + + IL_0033: nop + IL_0034: ret + } // end of method InstanceTests::LambdaInForLoop + + .method public hidebysig instance int32 + Foo() cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (int32 V_0) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method InstanceTests::Foo + + .method public hidebysig instance void + Bar(class [mscorlib]System.Func`1 f) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method InstanceTests::Bar + + .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 InstanceTests::.ctor + + .method private hidebysig instance void + 'b__20'() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThis() + IL_0007: pop + IL_0008: ret + } // end of method InstanceTests::'b__20' + + .method private hidebysig instance int32 + 'b__32'() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 11 (0xb) + .maxstack 1 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::Foo() + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method InstanceTests::'b__32' + + } // end of class InstanceTests + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 counter + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1'::.ctor + + .method public hidebysig instance void + 'b__0'(int32 x) cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1'::counter + IL_0008: ret + } // end of method '<>c__DisplayClass1'::'b__0' + + } // end of class '<>c__DisplayClass1' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass5' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 counter + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass5'::.ctor + + .method public hidebysig instance void + 'b__3'(int32 x) cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass5'::counter + IL_0008: ret + } // end of method '<>c__DisplayClass5'::'b__3' + + } // end of class '<>c__DisplayClass5' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClassb' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 i + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClassb'::.ctor + + .method public hidebysig instance void + 'b__9'(int32 j) cil managed + { + // Code size 31 (0x1f) + .maxstack 2 + .locals init (int32 V_0, + bool V_1) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: stloc.0 + IL_0003: br.s IL_0011 + + IL_0005: nop + IL_0006: call void [mscorlib]System.Console::WriteLine() + IL_000b: nop + IL_000c: nop + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: add + IL_0010: stloc.0 + IL_0011: ldloc.0 + IL_0012: ldarg.0 + IL_0013: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::i + IL_0018: clt + IL_001a: stloc.1 + IL_001b: ldloc.1 + IL_001c: brtrue.s IL_0005 + + IL_001e: ret + } // end of method '<>c__DisplayClassb'::'b__9' + + } // end of class '<>c__DisplayClassb' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass13' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass15' + extends [mscorlib]System.Object + { + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13' 'CS$<>8__locals14' + .field public int32 b + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass15'::.ctor + + .method public hidebysig instance int32 + 'b__12'(int32 c) cil managed + { + // Code size 25 (0x19) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15'::'CS$<>8__locals14' + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'::a + IL_000b: ldarg.0 + IL_000c: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15'::b + IL_0011: add + IL_0012: ldarg.1 + IL_0013: add + IL_0014: stloc.0 + IL_0015: br.s IL_0017 + + IL_0017: ldloc.0 + IL_0018: ret + } // end of method '<>c__DisplayClass15'::'b__12' + + } // end of class '<>c__DisplayClass15' + + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass13'::.ctor + + .method public hidebysig instance class [mscorlib]System.Func`2 + 'b__11'(int32 b) cil managed + { + // Code size 37 (0x25) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15' V_0, + class [mscorlib]System.Func`2 V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15'::'CS$<>8__locals14' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15'::b + IL_0014: ldloc.0 + IL_0015: ldftn instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15'::'b__12'(int32) + IL_001b: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_0020: stloc.1 + IL_0021: br.s IL_0023 + + IL_0023: ldloc.1 + IL_0024: ret + } // end of method '<>c__DisplayClass13'::'b__11' + + } // end of class '<>c__DisplayClass13' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1a' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1c' + extends [mscorlib]System.Object + { + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1e' + extends [mscorlib]System.Object + { + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c' 'CS$<>8__locals1d' + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' 'CS$<>8__locals1b' + .field public int32 c + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1e'::.ctor + + .method public hidebysig instance int32 + 'b__19'(int32 d) cil managed + { + // Code size 37 (0x25) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::'CS$<>8__locals1b' + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'::a + IL_000b: ldarg.0 + IL_000c: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::'CS$<>8__locals1d' + IL_0011: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'::b + IL_0016: add + IL_0017: ldarg.0 + IL_0018: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::c + IL_001d: add + IL_001e: ldarg.1 + IL_001f: add + IL_0020: stloc.0 + IL_0021: br.s IL_0023 + + IL_0023: ldloc.0 + IL_0024: ret + } // end of method '<>c__DisplayClass1e'::'b__19' + + } // end of class '<>c__DisplayClass1e' + + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' 'CS$<>8__locals1b' + .field public int32 b + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1c'::.ctor + + .method public hidebysig instance class [mscorlib]System.Func`2 + 'b__18'(int32 c) cil managed + { + // Code size 49 (0x31) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e' V_0, + class [mscorlib]System.Func`2 V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::'CS$<>8__locals1d' + IL_000d: ldloc.0 + IL_000e: ldarg.0 + IL_000f: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'::'CS$<>8__locals1b' + IL_0014: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::'CS$<>8__locals1b' + IL_0019: ldloc.0 + IL_001a: ldarg.1 + IL_001b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::c + IL_0020: ldloc.0 + IL_0021: ldftn instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::'b__19'(int32) + IL_0027: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_002c: stloc.1 + IL_002d: br.s IL_002f + + IL_002f: ldloc.1 + IL_0030: ret + } // end of method '<>c__DisplayClass1c'::'b__18' + + } // end of class '<>c__DisplayClass1c' + + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1a'::.ctor + + .method public hidebysig instance class [mscorlib]System.Func`2> + 'b__17'(int32 b) cil managed + { + // Code size 37 (0x25) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c' V_0, + class [mscorlib]System.Func`2> V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'::'CS$<>8__locals1b' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'::b + IL_0014: ldloc.0 + IL_0015: ldftn instance class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'::'b__18'(int32) + IL_001b: newobj instance void class [mscorlib]System.Func`2>::.ctor(object, + native int) + IL_0020: stloc.1 + IL_0021: br.s IL_0023 + + IL_0023: ldloc.1 + IL_0024: ret + } // end of method '<>c__DisplayClass1a'::'b__17' + + } // end of class '<>c__DisplayClass1a' + + .field private static class [mscorlib]System.Action 'CS$<>9__CachedAnonymousMethodDelegate8' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private static class [mscorlib]System.Action`1 'CS$<>9__CachedAnonymousMethodDelegatee' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private static class [mscorlib]System.Action`1 'CS$<>9__CachedAnonymousMethodDelegate10' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method public hidebysig static void Test(string a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method DelegateConstruction::Test + + .method public hidebysig static class [mscorlib]System.Action`1 + ExtensionMethodUnbound() cil managed + { + // Code size 18 (0x12) + .maxstack 2 + .locals init (class [mscorlib]System.Action`1 V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::Test(string) + IL_0008: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: br.s IL_0010 + + IL_0010: ldloc.0 + IL_0011: ret + } // end of method DelegateConstruction::ExtensionMethodUnbound + + .method public hidebysig static class [mscorlib]System.Action + ExtensionMethodBound() cil managed + { + // Code size 22 (0x16) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0) + IL_0000: nop + IL_0001: ldstr "abc" + IL_0006: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::Test(string) + IL_000c: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0011: stloc.0 + IL_0012: br.s IL_0014 + + IL_0014: ldloc.0 + IL_0015: ret + } // end of method DelegateConstruction::ExtensionMethodBound + + .method public hidebysig static class [mscorlib]System.Action + ExtensionMethodBoundOnNull() cil managed + { + // Code size 18 (0x12) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::Test(string) + IL_0008: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: br.s IL_0010 + + IL_0010: ldloc.0 + IL_0011: ret + } // end of method DelegateConstruction::ExtensionMethodBoundOnNull + + .method public hidebysig static object + StaticMethod() cil managed + { + // Code size 18 (0x12) + .maxstack 2 + .locals init (object V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: ldftn class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::ExtensionMethodBound() + IL_0008: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: br.s IL_0010 + + IL_0010: ldloc.0 + IL_0011: ret + } // end of method DelegateConstruction::StaticMethod + + .method public hidebysig static object + InstanceMethod() cil managed + { + // Code size 22 (0x16) + .maxstack 2 + .locals init (object V_0) + IL_0000: nop + IL_0001: ldstr "hello" + IL_0006: ldftn instance string [mscorlib]System.String::ToUpper() + IL_000c: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_0011: stloc.0 + IL_0012: br.s IL_0014 + + IL_0014: ldloc.0 + IL_0015: ret + } // end of method DelegateConstruction::InstanceMethod + + .method public hidebysig static object + InstanceMethodOnNull() cil managed + { + // Code size 18 (0x12) + .maxstack 2 + .locals init (object V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: ldftn instance string [mscorlib]System.String::ToUpper() + IL_0008: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: br.s IL_0010 + + IL_0010: ldloc.0 + IL_0011: ret + } // end of method DelegateConstruction::InstanceMethodOnNull + + .method public hidebysig static class [mscorlib]System.Collections.Generic.List`1> + AnonymousMethodStoreWithinLoop() cil managed + { + // Code size 59 (0x3b) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1' V_2, + class [mscorlib]System.Collections.Generic.List`1> V_3, + bool V_4) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: stloc.1 + IL_0009: br.s IL_002a + + IL_000b: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1'::.ctor() + IL_0010: stloc.2 + IL_0011: nop + IL_0012: ldloc.0 + IL_0013: ldloc.2 + IL_0014: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1'::'b__0'(int32) + IL_001a: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_001f: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_0024: nop + IL_0025: nop + IL_0026: ldloc.1 + IL_0027: ldc.i4.1 + IL_0028: add + IL_0029: stloc.1 + IL_002a: ldloc.1 + IL_002b: ldc.i4.s 10 + IL_002d: clt + IL_002f: stloc.s V_4 + IL_0031: ldloc.s V_4 + IL_0033: brtrue.s IL_000b + + IL_0035: ldloc.0 + IL_0036: stloc.3 + IL_0037: br.s IL_0039 + + IL_0039: ldloc.3 + IL_003a: ret + } // end of method DelegateConstruction::AnonymousMethodStoreWithinLoop + + .method public hidebysig static class [mscorlib]System.Collections.Generic.List`1> + AnonymousMethodStoreOutsideLoop() cil managed + { + // Code size 70 (0x46) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1, + class [mscorlib]System.Action`1 V_2, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass5' V_3, + class [mscorlib]System.Collections.Generic.List`1> V_4, + bool V_5) + IL_0000: ldnull + IL_0001: stloc.2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass5'::.ctor() + IL_0007: stloc.3 + IL_0008: nop + IL_0009: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_000e: stloc.0 + IL_000f: ldc.i4.0 + IL_0010: stloc.1 + IL_0011: br.s IL_0033 + + IL_0013: nop + IL_0014: ldloc.0 + IL_0015: ldloc.2 + IL_0016: brtrue.s IL_0027 + + IL_0018: ldloc.3 + IL_0019: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass5'::'b__3'(int32) + IL_001f: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_0024: stloc.2 + IL_0025: br.s IL_0027 + + IL_0027: ldloc.2 + IL_0028: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_002d: nop + IL_002e: nop + IL_002f: ldloc.1 + IL_0030: ldc.i4.1 + IL_0031: add + IL_0032: stloc.1 + IL_0033: ldloc.1 + IL_0034: ldc.i4.s 10 + IL_0036: clt + IL_0038: stloc.s V_5 + IL_003a: ldloc.s V_5 + IL_003c: brtrue.s IL_0013 + + IL_003e: ldloc.0 + IL_003f: stloc.s V_4 + IL_0041: br.s IL_0043 + + IL_0043: ldloc.s V_4 + IL_0045: ret + } // end of method DelegateConstruction::AnonymousMethodStoreOutsideLoop + + .method public hidebysig static class [mscorlib]System.Action + StaticAnonymousMethodNoClosure() cil managed + { + // Code size 37 (0x25) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0) + IL_0000: nop + IL_0001: ldsfld class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegate8' + IL_0006: brtrue.s IL_001b + + IL_0008: ldnull + IL_0009: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'b__7'() + IL_000f: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0014: stsfld class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegate8' + IL_0019: br.s IL_001b + + IL_001b: ldsfld class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegate8' + IL_0020: stloc.0 + IL_0021: br.s IL_0023 + + IL_0023: ldloc.0 + IL_0024: ret + } // end of method DelegateConstruction::StaticAnonymousMethodNoClosure + + .method public hidebysig static void NameConflict() cil managed + { + // Code size 104 (0x68) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1, + class [mscorlib]System.Action`1 V_2, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb' V_3, + bool V_4) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: stloc.1 + IL_0009: br.s IL_005c + + IL_000b: ldnull + IL_000c: stloc.2 + IL_000d: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::.ctor() + IL_0012: stloc.3 + IL_0013: nop + IL_0014: ldloc.3 + IL_0015: ldc.i4.0 + IL_0016: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::i + IL_001b: br.s IL_0047 + + IL_001d: nop + IL_001e: ldloc.0 + IL_001f: ldloc.2 + IL_0020: brtrue.s IL_0031 + + IL_0022: ldloc.3 + IL_0023: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::'b__9'(int32) + IL_0029: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_002e: stloc.2 + IL_002f: br.s IL_0031 + + IL_0031: ldloc.2 + IL_0032: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_0037: nop + IL_0038: nop + IL_0039: ldloc.3 + IL_003a: dup + IL_003b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::i + IL_0040: ldc.i4.1 + IL_0041: add + IL_0042: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::i + IL_0047: ldloc.3 + IL_0048: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::i + IL_004d: ldc.i4.s 10 + IL_004f: clt + IL_0051: stloc.s V_4 + IL_0053: ldloc.s V_4 + IL_0055: brtrue.s IL_001d + + IL_0057: nop + IL_0058: ldloc.1 + IL_0059: ldc.i4.1 + IL_005a: add + IL_005b: stloc.1 + IL_005c: ldloc.1 + IL_005d: ldc.i4.s 10 + IL_005f: clt + IL_0061: stloc.s V_4 + IL_0063: ldloc.s V_4 + IL_0065: brtrue.s IL_000b + + IL_0067: ret + } // end of method DelegateConstruction::NameConflict + + .method public hidebysig static void NameConflict2(int32 j) cil managed + { + // Code size 65 (0x41) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1, + bool V_2) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: stloc.1 + IL_0009: br.s IL_0037 + + IL_000b: nop + IL_000c: ldloc.0 + IL_000d: ldsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegatee' + IL_0012: brtrue.s IL_0027 + + IL_0014: ldnull + IL_0015: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'b__d'(int32) + IL_001b: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_0020: stsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegatee' + IL_0025: br.s IL_0027 + + IL_0027: ldsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegatee' + IL_002c: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_0031: nop + IL_0032: nop + IL_0033: ldloc.1 + IL_0034: ldc.i4.1 + IL_0035: add + IL_0036: stloc.1 + IL_0037: ldloc.1 + IL_0038: ldc.i4.s 10 + IL_003a: clt + IL_003c: stloc.2 + IL_003d: ldloc.2 + IL_003e: brtrue.s IL_000b + + IL_0040: ret + } // end of method DelegateConstruction::NameConflict2 + + .method public hidebysig static class [mscorlib]System.Action`1 + NameConflict3(int32 i) cil managed + { + // Code size 37 (0x25) + .maxstack 2 + .locals init (class [mscorlib]System.Action`1 V_0) + IL_0000: nop + IL_0001: ldsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegate10' + IL_0006: brtrue.s IL_001b + + IL_0008: ldnull + IL_0009: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'b__f'(int32) + IL_000f: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_0014: stsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegate10' + IL_0019: br.s IL_001b + + IL_001b: ldsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegate10' + IL_0020: stloc.0 + IL_0021: br.s IL_0023 + + IL_0023: ldloc.0 + IL_0024: ret + } // end of method DelegateConstruction::NameConflict3 + + .method public hidebysig static class [mscorlib]System.Func`2> + CurriedAddition(int32 a) cil managed + { + // Code size 31 (0x1f) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13' V_0, + class [mscorlib]System.Func`2> V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'::a + IL_000d: nop + IL_000e: ldloc.0 + IL_000f: ldftn instance class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'::'b__11'(int32) + IL_0015: newobj instance void class [mscorlib]System.Func`2>::.ctor(object, + native int) + IL_001a: stloc.1 + IL_001b: br.s IL_001d + + IL_001d: ldloc.1 + IL_001e: ret + } // end of method DelegateConstruction::CurriedAddition + + .method public hidebysig static class [mscorlib]System.Func`2>> + CurriedAddition2(int32 a) cil managed + { + // Code size 31 (0x1f) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' V_0, + class [mscorlib]System.Func`2>> V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'::a + IL_000d: nop + IL_000e: ldloc.0 + IL_000f: ldftn instance class [mscorlib]System.Func`2> ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'::'b__17'(int32) + IL_0015: newobj instance void class [mscorlib]System.Func`2>>::.ctor(object, + native int) + IL_001a: stloc.1 + IL_001b: br.s IL_001d + + IL_001d: ldloc.1 + IL_001e: ret + } // end of method DelegateConstruction::CurriedAddition2 + + .method private hidebysig static void 'b__7'() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void [mscorlib]System.Console::WriteLine() + IL_0006: nop + IL_0007: ret + } // end of method DelegateConstruction::'b__7' + + .method private hidebysig static void 'b__d'(int32 i) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call void [mscorlib]System.Console::WriteLine(int32) + IL_0007: nop + IL_0008: ret + } // end of method DelegateConstruction::'b__d' + + .method private hidebysig static void 'b__f'(int32 j) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 27 (0x1b) + .maxstack 2 + .locals init (int32 V_0, + bool V_1) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: stloc.0 + IL_0003: br.s IL_0012 + + IL_0005: nop + IL_0006: ldloc.0 + IL_0007: call void [mscorlib]System.Console::WriteLine(int32) + IL_000c: nop + IL_000d: nop + IL_000e: ldloc.0 + IL_000f: ldc.i4.1 + IL_0010: add + IL_0011: stloc.0 + IL_0012: ldloc.0 + IL_0013: ldarg.0 + IL_0014: clt + IL_0016: stloc.1 + IL_0017: ldloc.1 + IL_0018: brtrue.s IL_0005 + + IL_001a: ret + } // end of method DelegateConstruction::'b__f' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** +// WARNING: Created Win32 resource file ../../../TestCases/Pretty\DelegateConstruction.res diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.opt.il new file mode 100644 index 000000000..f12117f03 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.opt.il @@ -0,0 +1,1150 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. All rights reserved. + + + +// 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 extern System.Core +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly c0bnf0jn +{ + .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.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module c0bnf0jn.dll +// MVID: {ABE4DCE9-5E34-4357-84BA-7850DA8457DD} +.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: 0x00E80000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction + extends [mscorlib]System.Object +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .class auto ansi nested private beforefieldinit InstanceTests + extends [mscorlib]System.Object + { + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass22' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests '<>4__this' + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass22'::.ctor + + .method public hidebysig instance void + 'b__21'() cil managed + { + // Code size 19 (0x13) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22'::'<>4__this' + IL_0006: ldarg.0 + IL_0007: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22'::a + IL_000c: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThisAndParameter(int32) + IL_0011: pop + IL_0012: ret + } // end of method '<>c__DisplayClass22'::'b__21' + + } // end of class '<>c__DisplayClass22' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass25' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests '<>4__this' + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass25'::.ctor + + } // end of class '<>c__DisplayClass25' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass28' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25' 'CS$<>8__locals26' + .field public int32 item + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass28'::.ctor + + .method public hidebysig instance void + 'b__24'() cil managed + { + // Code size 36 (0x24) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::'CS$<>8__locals26' + IL_0006: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25'::'<>4__this' + IL_000b: ldarg.0 + IL_000c: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::item + IL_0011: ldarg.0 + IL_0012: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::'CS$<>8__locals26' + IL_0017: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25'::a + IL_001c: add + IL_001d: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThisAndParameter(int32) + IL_0022: pop + IL_0023: ret + } // end of method '<>c__DisplayClass28'::'b__24' + + } // end of class '<>c__DisplayClass28' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass2b' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests '<>4__this' + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass2b'::.ctor + + } // end of class '<>c__DisplayClass2b' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass2d' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 item + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass2d'::.ctor + + } // end of class '<>c__DisplayClass2d' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass30' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d' 'CS$<>8__locals2e' + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b' 'CS$<>8__locals2c' + .field public int32 copyOfItem + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass30'::.ctor + + .method public hidebysig instance void + 'b__2a'() cil managed + { + // Code size 48 (0x30) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::'CS$<>8__locals2c' + IL_0006: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b'::'<>4__this' + IL_000b: ldarg.0 + IL_000c: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::'CS$<>8__locals2e' + IL_0011: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d'::item + IL_0016: ldarg.0 + IL_0017: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::'CS$<>8__locals2c' + IL_001c: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b'::a + IL_0021: add + IL_0022: ldarg.0 + IL_0023: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::copyOfItem + IL_0028: add + IL_0029: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThisAndParameter(int32) + IL_002e: pop + IL_002f: ret + } // end of method '<>c__DisplayClass30'::'b__2a' + + } // end of class '<>c__DisplayClass30' + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThis() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::'b__20'() + IL_0007: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_000c: ret + } // end of method InstanceTests::CaptureOfThis + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThisAndParameter(int32 a) cil managed + { + // Code size 33 (0x21) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22' V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22'::a + IL_000d: ldloc.0 + IL_000e: ldarg.0 + IL_000f: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22'::'<>4__this' + IL_0014: ldloc.0 + IL_0015: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass22'::'b__21'() + IL_001b: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0020: ret + } // end of method InstanceTests::CaptureOfThisAndParameter + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThisAndParameterInForEach(int32 a) cil managed + { + // Code size 118 (0x76) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28' V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25' V_2, + class [mscorlib]System.Action V_3, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_4) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25'::.ctor() + IL_0005: stloc.2 + IL_0006: ldloc.2 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25'::a + IL_000d: ldloc.2 + IL_000e: ldarg.0 + IL_000f: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25'::'<>4__this' + IL_0014: call class [mscorlib]System.Collections.Generic.IEnumerable`1 [System.Core]System.Linq.Enumerable::Empty() + IL_0019: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_001e: stloc.s V_4 + .try + { + IL_0020: br.s IL_005b + + IL_0022: ldnull + IL_0023: stloc.0 + IL_0024: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::.ctor() + IL_0029: stloc.1 + IL_002a: ldloc.1 + IL_002b: ldloc.2 + IL_002c: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass25' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::'CS$<>8__locals26' + IL_0031: ldloc.1 + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0039: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::item + IL_003e: ldloc.1 + IL_003f: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::item + IL_0044: ldc.i4.0 + IL_0045: ble.s IL_005b + + IL_0047: ldloc.0 + IL_0048: brtrue.s IL_0057 + + IL_004a: ldloc.1 + IL_004b: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass28'::'b__24'() + IL_0051: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0056: stloc.0 + IL_0057: ldloc.0 + IL_0058: stloc.3 + IL_0059: leave.s IL_0074 + + IL_005b: ldloc.s V_4 + IL_005d: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() + IL_0062: brtrue.s IL_0022 + + IL_0064: leave.s IL_0072 + + } // end .try + finally + { + IL_0066: ldloc.s V_4 + IL_0068: brfalse.s IL_0071 + + IL_006a: ldloc.s V_4 + IL_006c: callvirt instance void [mscorlib]System.IDisposable::Dispose() + IL_0071: endfinally + } // end handler + IL_0072: ldnull + IL_0073: ret + + IL_0074: ldloc.3 + IL_0075: ret + } // end of method InstanceTests::CaptureOfThisAndParameterInForEach + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThisAndParameterInForEachWithItemCopy(int32 a) cil managed + { + // Code size 145 (0x91) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30' V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d' V_2, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b' V_3, + class [mscorlib]System.Action V_4, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_5) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b'::.ctor() + IL_0005: stloc.3 + IL_0006: ldloc.3 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b'::a + IL_000d: ldloc.3 + IL_000e: ldarg.0 + IL_000f: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b'::'<>4__this' + IL_0014: call class [mscorlib]System.Collections.Generic.IEnumerable`1 [System.Core]System.Linq.Enumerable::Empty() + IL_0019: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_001e: stloc.s V_5 + .try + { + IL_0020: br.s IL_0075 + + IL_0022: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d'::.ctor() + IL_0027: stloc.2 + IL_0028: ldloc.2 + IL_0029: ldloc.s V_5 + IL_002b: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0030: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d'::item + IL_0035: ldnull + IL_0036: stloc.0 + IL_0037: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::.ctor() + IL_003c: stloc.1 + IL_003d: ldloc.1 + IL_003e: ldloc.2 + IL_003f: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::'CS$<>8__locals2e' + IL_0044: ldloc.1 + IL_0045: ldloc.3 + IL_0046: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2b' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::'CS$<>8__locals2c' + IL_004b: ldloc.1 + IL_004c: ldloc.2 + IL_004d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d'::item + IL_0052: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::copyOfItem + IL_0057: ldloc.2 + IL_0058: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2d'::item + IL_005d: ldc.i4.0 + IL_005e: ble.s IL_0075 + + IL_0060: ldloc.0 + IL_0061: brtrue.s IL_0070 + + IL_0063: ldloc.1 + IL_0064: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass30'::'b__2a'() + IL_006a: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_006f: stloc.0 + IL_0070: ldloc.0 + IL_0071: stloc.s V_4 + IL_0073: leave.s IL_008e + + IL_0075: ldloc.s V_5 + IL_0077: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() + IL_007c: brtrue.s IL_0022 + + IL_007e: leave.s IL_008c + + } // end .try + finally + { + IL_0080: ldloc.s V_5 + IL_0082: brfalse.s IL_008b + + IL_0084: ldloc.s V_5 + IL_0086: callvirt instance void [mscorlib]System.IDisposable::Dispose() + IL_008b: endfinally + } // end handler + IL_008c: ldnull + IL_008d: ret + + IL_008e: ldloc.s V_4 + IL_0090: ret + } // end of method InstanceTests::CaptureOfThisAndParameterInForEachWithItemCopy + + .method public hidebysig instance void + LambdaInForLoop() cil managed + { + // Code size 42 (0x2a) + .maxstack 3 + .locals init (int32 V_0, + class [mscorlib]System.Func`1 V_1) + IL_0000: ldnull + IL_0001: stloc.1 + IL_0002: ldc.i4.0 + IL_0003: stloc.0 + IL_0004: br.s IL_0021 + + IL_0006: ldarg.0 + IL_0007: ldloc.1 + IL_0008: brtrue.s IL_0017 + + IL_000a: ldarg.0 + IL_000b: ldftn instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::'b__32'() + IL_0011: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_0016: stloc.1 + IL_0017: ldloc.1 + IL_0018: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::Bar(class [mscorlib]System.Func`1) + IL_001d: ldloc.0 + IL_001e: ldc.i4.1 + IL_001f: add + IL_0020: stloc.0 + IL_0021: ldloc.0 + IL_0022: ldc.i4 0x186a0 + IL_0027: blt.s IL_0006 + + IL_0029: ret + } // end of method InstanceTests::LambdaInForLoop + + .method public hidebysig instance int32 + Foo() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } // end of method InstanceTests::Foo + + .method public hidebysig instance void + Bar(class [mscorlib]System.Func`1 f) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method InstanceTests::Bar + + .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 InstanceTests::.ctor + + .method private hidebysig instance void + 'b__20'() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThis() + IL_0006: pop + IL_0007: ret + } // end of method InstanceTests::'b__20' + + .method private hidebysig instance int32 + 'b__32'() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::Foo() + IL_0006: ret + } // end of method InstanceTests::'b__32' + + } // end of class InstanceTests + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 counter + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1'::.ctor + + .method public hidebysig instance void + 'b__0'(int32 x) cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1'::counter + IL_0007: ret + } // end of method '<>c__DisplayClass1'::'b__0' + + } // end of class '<>c__DisplayClass1' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass5' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 counter + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass5'::.ctor + + .method public hidebysig instance void + 'b__3'(int32 x) cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass5'::counter + IL_0007: ret + } // end of method '<>c__DisplayClass5'::'b__3' + + } // end of class '<>c__DisplayClass5' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClassb' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 i + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClassb'::.ctor + + .method public hidebysig instance void + 'b__9'(int32 j) cil managed + { + // Code size 23 (0x17) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldc.i4.0 + IL_0001: stloc.0 + IL_0002: br.s IL_000d + + IL_0004: call void [mscorlib]System.Console::WriteLine() + IL_0009: ldloc.0 + IL_000a: ldarg.1 + IL_000b: add + IL_000c: stloc.0 + IL_000d: ldloc.0 + IL_000e: ldarg.0 + IL_000f: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::i + IL_0014: blt.s IL_0004 + + IL_0016: ret + } // end of method '<>c__DisplayClassb'::'b__9' + + } // end of class '<>c__DisplayClassb' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass13' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass15' + extends [mscorlib]System.Object + { + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13' 'CS$<>8__locals14' + .field public int32 b + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass15'::.ctor + + .method public hidebysig instance int32 + 'b__12'(int32 c) cil managed + { + // Code size 21 (0x15) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15'::'CS$<>8__locals14' + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'::a + IL_000b: ldarg.0 + IL_000c: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15'::b + IL_0011: add + IL_0012: ldarg.1 + IL_0013: add + IL_0014: ret + } // end of method '<>c__DisplayClass15'::'b__12' + + } // end of class '<>c__DisplayClass15' + + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass13'::.ctor + + .method public hidebysig instance class [mscorlib]System.Func`2 + 'b__11'(int32 b) cil managed + { + // Code size 33 (0x21) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15' V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15'::'CS$<>8__locals14' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15'::b + IL_0014: ldloc.0 + IL_0015: ldftn instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'/'<>c__DisplayClass15'::'b__12'(int32) + IL_001b: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_0020: ret + } // end of method '<>c__DisplayClass13'::'b__11' + + } // end of class '<>c__DisplayClass13' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1a' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1c' + extends [mscorlib]System.Object + { + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1e' + extends [mscorlib]System.Object + { + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c' 'CS$<>8__locals1d' + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' 'CS$<>8__locals1b' + .field public int32 c + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1e'::.ctor + + .method public hidebysig instance int32 + 'b__19'(int32 d) cil managed + { + // Code size 33 (0x21) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::'CS$<>8__locals1b' + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'::a + IL_000b: ldarg.0 + IL_000c: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::'CS$<>8__locals1d' + IL_0011: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'::b + IL_0016: add + IL_0017: ldarg.0 + IL_0018: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::c + IL_001d: add + IL_001e: ldarg.1 + IL_001f: add + IL_0020: ret + } // end of method '<>c__DisplayClass1e'::'b__19' + + } // end of class '<>c__DisplayClass1e' + + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' 'CS$<>8__locals1b' + .field public int32 b + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1c'::.ctor + + .method public hidebysig instance class [mscorlib]System.Func`2 + 'b__18'(int32 c) cil managed + { + // Code size 45 (0x2d) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e' V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::'CS$<>8__locals1d' + IL_000d: ldloc.0 + IL_000e: ldarg.0 + IL_000f: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'::'CS$<>8__locals1b' + IL_0014: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::'CS$<>8__locals1b' + IL_0019: ldloc.0 + IL_001a: ldarg.1 + IL_001b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::c + IL_0020: ldloc.0 + IL_0021: ldftn instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'/'<>c__DisplayClass1e'::'b__19'(int32) + IL_0027: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_002c: ret + } // end of method '<>c__DisplayClass1c'::'b__18' + + } // end of class '<>c__DisplayClass1c' + + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1a'::.ctor + + .method public hidebysig instance class [mscorlib]System.Func`2> + 'b__17'(int32 b) cil managed + { + // Code size 33 (0x21) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c' V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'::'CS$<>8__locals1b' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'::b + IL_0014: ldloc.0 + IL_0015: ldftn instance class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'/'<>c__DisplayClass1c'::'b__18'(int32) + IL_001b: newobj instance void class [mscorlib]System.Func`2>::.ctor(object, + native int) + IL_0020: ret + } // end of method '<>c__DisplayClass1a'::'b__17' + + } // end of class '<>c__DisplayClass1a' + + .field private static class [mscorlib]System.Action 'CS$<>9__CachedAnonymousMethodDelegate8' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private static class [mscorlib]System.Action`1 'CS$<>9__CachedAnonymousMethodDelegatee' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private static class [mscorlib]System.Action`1 'CS$<>9__CachedAnonymousMethodDelegate10' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method public hidebysig static void Test(string a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method DelegateConstruction::Test + + .method public hidebysig static class [mscorlib]System.Action`1 + ExtensionMethodUnbound() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::Test(string) + IL_0007: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_000c: ret + } // end of method DelegateConstruction::ExtensionMethodUnbound + + .method public hidebysig static class [mscorlib]System.Action + ExtensionMethodBound() cil managed + { + // Code size 17 (0x11) + .maxstack 8 + IL_0000: ldstr "abc" + IL_0005: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::Test(string) + IL_000b: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0010: ret + } // end of method DelegateConstruction::ExtensionMethodBound + + .method public hidebysig static class [mscorlib]System.Action + ExtensionMethodBoundOnNull() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::Test(string) + IL_0007: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_000c: ret + } // end of method DelegateConstruction::ExtensionMethodBoundOnNull + + .method public hidebysig static object + StaticMethod() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::ExtensionMethodBound() + IL_0007: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_000c: ret + } // end of method DelegateConstruction::StaticMethod + + .method public hidebysig static object + InstanceMethod() cil managed + { + // Code size 17 (0x11) + .maxstack 8 + IL_0000: ldstr "hello" + IL_0005: ldftn instance string [mscorlib]System.String::ToUpper() + IL_000b: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_0010: ret + } // end of method DelegateConstruction::InstanceMethod + + .method public hidebysig static object + InstanceMethodOnNull() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn instance string [mscorlib]System.String::ToUpper() + IL_0007: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_000c: ret + } // end of method DelegateConstruction::InstanceMethodOnNull + + .method public hidebysig static class [mscorlib]System.Collections.Generic.List`1> + AnonymousMethodStoreWithinLoop() cil managed + { + // Code size 45 (0x2d) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1' V_2) + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0005: stloc.0 + IL_0006: ldc.i4.0 + IL_0007: stloc.1 + IL_0008: br.s IL_0026 + + IL_000a: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1'::.ctor() + IL_000f: stloc.2 + IL_0010: ldloc.0 + IL_0011: ldloc.2 + IL_0012: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1'::'b__0'(int32) + IL_0018: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_001d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_0022: ldloc.1 + IL_0023: ldc.i4.1 + IL_0024: add + IL_0025: stloc.1 + IL_0026: ldloc.1 + IL_0027: ldc.i4.s 10 + IL_0029: blt.s IL_000a + + IL_002b: ldloc.0 + IL_002c: ret + } // end of method DelegateConstruction::AnonymousMethodStoreWithinLoop + + .method public hidebysig static class [mscorlib]System.Collections.Generic.List`1> + AnonymousMethodStoreOutsideLoop() cil managed + { + // Code size 52 (0x34) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1, + class [mscorlib]System.Action`1 V_2, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass5' V_3) + IL_0000: ldnull + IL_0001: stloc.2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass5'::.ctor() + IL_0007: stloc.3 + IL_0008: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_000d: stloc.0 + IL_000e: ldc.i4.0 + IL_000f: stloc.1 + IL_0010: br.s IL_002d + + IL_0012: ldloc.0 + IL_0013: ldloc.2 + IL_0014: brtrue.s IL_0023 + + IL_0016: ldloc.3 + IL_0017: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass5'::'b__3'(int32) + IL_001d: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_0022: stloc.2 + IL_0023: ldloc.2 + IL_0024: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_0029: ldloc.1 + IL_002a: ldc.i4.1 + IL_002b: add + IL_002c: stloc.1 + IL_002d: ldloc.1 + IL_002e: ldc.i4.s 10 + IL_0030: blt.s IL_0012 + + IL_0032: ldloc.0 + IL_0033: ret + } // end of method DelegateConstruction::AnonymousMethodStoreOutsideLoop + + .method public hidebysig static class [mscorlib]System.Action + StaticAnonymousMethodNoClosure() cil managed + { + // Code size 30 (0x1e) + .maxstack 8 + IL_0000: ldsfld class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegate8' + IL_0005: brtrue.s IL_0018 + + IL_0007: ldnull + IL_0008: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'b__7'() + IL_000e: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0013: stsfld class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegate8' + IL_0018: ldsfld class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegate8' + IL_001d: ret + } // end of method DelegateConstruction::StaticAnonymousMethodNoClosure + + .method public hidebysig static void NameConflict() cil managed + { + // Code size 84 (0x54) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1, + class [mscorlib]System.Action`1 V_2, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb' V_3) + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0005: stloc.0 + IL_0006: ldc.i4.0 + IL_0007: stloc.1 + IL_0008: br.s IL_004e + + IL_000a: ldnull + IL_000b: stloc.2 + IL_000c: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::.ctor() + IL_0011: stloc.3 + IL_0012: ldloc.3 + IL_0013: ldc.i4.0 + IL_0014: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::i + IL_0019: br.s IL_0040 + + IL_001b: ldloc.0 + IL_001c: ldloc.2 + IL_001d: brtrue.s IL_002c + + IL_001f: ldloc.3 + IL_0020: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::'b__9'(int32) + IL_0026: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_002b: stloc.2 + IL_002c: ldloc.2 + IL_002d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_0032: ldloc.3 + IL_0033: dup + IL_0034: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::i + IL_0039: ldc.i4.1 + IL_003a: add + IL_003b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::i + IL_0040: ldloc.3 + IL_0041: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClassb'::i + IL_0046: ldc.i4.s 10 + IL_0048: blt.s IL_001b + + IL_004a: ldloc.1 + IL_004b: ldc.i4.1 + IL_004c: add + IL_004d: stloc.1 + IL_004e: ldloc.1 + IL_004f: ldc.i4.s 10 + IL_0051: blt.s IL_000a + + IL_0053: ret + } // end of method DelegateConstruction::NameConflict + + .method public hidebysig static void NameConflict2(int32 j) cil managed + { + // Code size 55 (0x37) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1) + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0005: stloc.0 + IL_0006: ldc.i4.0 + IL_0007: stloc.1 + IL_0008: br.s IL_0031 + + IL_000a: ldloc.0 + IL_000b: ldsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegatee' + IL_0010: brtrue.s IL_0023 + + IL_0012: ldnull + IL_0013: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'b__d'(int32) + IL_0019: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_001e: stsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegatee' + IL_0023: ldsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegatee' + IL_0028: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_002d: ldloc.1 + IL_002e: ldc.i4.1 + IL_002f: add + IL_0030: stloc.1 + IL_0031: ldloc.1 + IL_0032: ldc.i4.s 10 + IL_0034: blt.s IL_000a + + IL_0036: ret + } // end of method DelegateConstruction::NameConflict2 + + .method public hidebysig static class [mscorlib]System.Action`1 + NameConflict3(int32 i) cil managed + { + // Code size 30 (0x1e) + .maxstack 8 + IL_0000: ldsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegate10' + IL_0005: brtrue.s IL_0018 + + IL_0007: ldnull + IL_0008: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'b__f'(int32) + IL_000e: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_0013: stsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegate10' + IL_0018: ldsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::'CS$<>9__CachedAnonymousMethodDelegate10' + IL_001d: ret + } // end of method DelegateConstruction::NameConflict3 + + .method public hidebysig static class [mscorlib]System.Func`2> + CurriedAddition(int32 a) cil managed + { + // Code size 26 (0x1a) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13' V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'::a + IL_000d: ldloc.0 + IL_000e: ldftn instance class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass13'::'b__11'(int32) + IL_0014: newobj instance void class [mscorlib]System.Func`2>::.ctor(object, + native int) + IL_0019: ret + } // end of method DelegateConstruction::CurriedAddition + + .method public hidebysig static class [mscorlib]System.Func`2>> + CurriedAddition2(int32 a) cil managed + { + // Code size 26 (0x1a) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a' V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'::a + IL_000d: ldloc.0 + IL_000e: ldftn instance class [mscorlib]System.Func`2> ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass1a'::'b__17'(int32) + IL_0014: newobj instance void class [mscorlib]System.Func`2>>::.ctor(object, + native int) + IL_0019: ret + } // end of method DelegateConstruction::CurriedAddition2 + + .method private hidebysig static void 'b__7'() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 6 (0x6) + .maxstack 8 + IL_0000: call void [mscorlib]System.Console::WriteLine() + IL_0005: ret + } // end of method DelegateConstruction::'b__7' + + .method private hidebysig static void 'b__d'(int32 i) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call void [mscorlib]System.Console::WriteLine(int32) + IL_0006: ret + } // end of method DelegateConstruction::'b__d' + + .method private hidebysig static void 'b__f'(int32 j) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 19 (0x13) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldc.i4.0 + IL_0001: stloc.0 + IL_0002: br.s IL_000e + + IL_0004: ldloc.0 + IL_0005: call void [mscorlib]System.Console::WriteLine(int32) + IL_000a: ldloc.0 + IL_000b: ldc.i4.1 + IL_000c: add + IL_000d: stloc.0 + IL_000e: ldloc.0 + IL_000f: ldarg.0 + IL_0010: blt.s IL_0004 + + IL_0012: ret + } // end of method DelegateConstruction::'b__f' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** +// WARNING: Created Win32 resource file ../../../TestCases/Pretty\DelegateConstruction.opt.res diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.opt.roslyn.il new file mode 100644 index 000000000..e4f4a6bff --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.opt.roslyn.il @@ -0,0 +1,1144 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. All rights reserved. + + + +// 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 extern System.Core +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly DelegateConstruction +{ + .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 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 DelegateConstruction.dll +// MVID: {534F3E90-3206-4E6A-821F-26BFD75A6959} +.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: 0x01460000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction + extends [mscorlib]System.Object +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .class auto ansi nested private beforefieldinit InstanceTests + extends [mscorlib]System.Object + { + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 a + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests '<>4__this' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1_0'::.ctor + + .method assembly hidebysig instance void + 'b__0'() cil managed + { + // Code size 19 (0x13) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0'::'<>4__this' + IL_0006: ldarg.0 + IL_0007: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0'::a + IL_000c: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThisAndParameter(int32) + IL_0011: pop + IL_0012: ret + } // end of method '<>c__DisplayClass1_0'::'b__0' + + } // end of class '<>c__DisplayClass1_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass2_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 item + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1' 'CS$<>8__locals1' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass2_0'::.ctor + + .method assembly hidebysig instance void + 'b__0'() cil managed + { + // Code size 36 (0x24) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::'CS$<>8__locals1' + IL_0006: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1'::'<>4__this' + IL_000b: ldarg.0 + IL_000c: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::item + IL_0011: ldarg.0 + IL_0012: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::'CS$<>8__locals1' + IL_0017: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1'::a + IL_001c: add + IL_001d: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThisAndParameter(int32) + IL_0022: pop + IL_0023: ret + } // end of method '<>c__DisplayClass2_0'::'b__0' + + } // end of class '<>c__DisplayClass2_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass2_1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 a + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests '<>4__this' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass2_1'::.ctor + + } // end of class '<>c__DisplayClass2_1' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass3_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 item + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1' 'CS$<>8__locals1' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass3_0'::.ctor + + } // end of class '<>c__DisplayClass3_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass3_1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 a + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests '<>4__this' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass3_1'::.ctor + + } // end of class '<>c__DisplayClass3_1' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass3_2' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 copyOfItem + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' 'CS$<>8__locals2' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass3_2'::.ctor + + .method assembly hidebysig instance void + 'b__0'() cil managed + { + // Code size 58 (0x3a) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'CS$<>8__locals2' + IL_0006: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::'CS$<>8__locals1' + IL_000b: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1'::'<>4__this' + IL_0010: ldarg.0 + IL_0011: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'CS$<>8__locals2' + IL_0016: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::item + IL_001b: ldarg.0 + IL_001c: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'CS$<>8__locals2' + IL_0021: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::'CS$<>8__locals1' + IL_0026: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1'::a + IL_002b: add + IL_002c: ldarg.0 + IL_002d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::copyOfItem + IL_0032: add + IL_0033: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThisAndParameter(int32) + IL_0038: pop + IL_0039: ret + } // end of method '<>c__DisplayClass3_2'::'b__0' + + } // end of class '<>c__DisplayClass3_2' + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThis() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::'b__0_0'() + IL_0007: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_000c: ret + } // end of method InstanceTests::CaptureOfThis + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThisAndParameter(int32 a) cil managed + { + // Code size 31 (0x1f) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0'::.ctor() + IL_0005: dup + IL_0006: ldarg.0 + IL_0007: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0'::'<>4__this' + IL_000c: dup + IL_000d: ldarg.1 + IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0'::a + IL_0013: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0'::'b__0'() + IL_0019: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_001e: ret + } // end of method InstanceTests::CaptureOfThisAndParameter + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThisAndParameterInForEach(int32 a) cil managed + { + // Code size 106 (0x6a) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1' V_0, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0' V_2, + class [mscorlib]System.Action V_3) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1'::'<>4__this' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1'::a + IL_0014: call class [mscorlib]System.Collections.Generic.IEnumerable`1 [System.Core]System.Linq.Enumerable::Empty() + IL_0019: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_001e: stloc.1 + .try + { + IL_001f: br.s IL_0052 + + IL_0021: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::.ctor() + IL_0026: stloc.2 + IL_0027: ldloc.2 + IL_0028: ldloc.0 + IL_0029: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::'CS$<>8__locals1' + IL_002e: ldloc.2 + IL_002f: ldloc.1 + IL_0030: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0035: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::item + IL_003a: ldloc.2 + IL_003b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::item + IL_0040: ldc.i4.0 + IL_0041: ble.s IL_0052 + + IL_0043: ldloc.2 + IL_0044: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::'b__0'() + IL_004a: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_004f: stloc.3 + IL_0050: leave.s IL_0068 + + IL_0052: ldloc.1 + IL_0053: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() + IL_0058: brtrue.s IL_0021 + + IL_005a: leave.s IL_0066 + + } // end .try + finally + { + IL_005c: ldloc.1 + IL_005d: brfalse.s IL_0065 + + IL_005f: ldloc.1 + IL_0060: callvirt instance void [mscorlib]System.IDisposable::Dispose() + IL_0065: endfinally + } // end handler + IL_0066: ldnull + IL_0067: ret + + IL_0068: ldloc.3 + IL_0069: ret + } // end of method InstanceTests::CaptureOfThisAndParameterInForEach + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThisAndParameterInForEachWithItemCopy(int32 a) cil managed + { + // Code size 143 (0x8f) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1' V_0, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' V_2, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2' V_3, + class [mscorlib]System.Action V_4) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1'::'<>4__this' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1'::a + IL_0014: call class [mscorlib]System.Collections.Generic.IEnumerable`1 [System.Core]System.Linq.Enumerable::Empty() + IL_0019: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_001e: stloc.1 + .try + { + IL_001f: br.s IL_0076 + + IL_0021: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::.ctor() + IL_0026: stloc.2 + IL_0027: ldloc.2 + IL_0028: ldloc.0 + IL_0029: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::'CS$<>8__locals1' + IL_002e: ldloc.2 + IL_002f: ldloc.1 + IL_0030: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0035: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::item + IL_003a: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::.ctor() + IL_003f: stloc.3 + IL_0040: ldloc.3 + IL_0041: ldloc.2 + IL_0042: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'CS$<>8__locals2' + IL_0047: ldloc.3 + IL_0048: ldloc.3 + IL_0049: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'CS$<>8__locals2' + IL_004e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::item + IL_0053: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::copyOfItem + IL_0058: ldloc.3 + IL_0059: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'CS$<>8__locals2' + IL_005e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::item + IL_0063: ldc.i4.0 + IL_0064: ble.s IL_0076 + + IL_0066: ldloc.3 + IL_0067: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'b__0'() + IL_006d: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0072: stloc.s V_4 + IL_0074: leave.s IL_008c + + IL_0076: ldloc.1 + IL_0077: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() + IL_007c: brtrue.s IL_0021 + + IL_007e: leave.s IL_008a + + } // end .try + finally + { + IL_0080: ldloc.1 + IL_0081: brfalse.s IL_0089 + + IL_0083: ldloc.1 + IL_0084: callvirt instance void [mscorlib]System.IDisposable::Dispose() + IL_0089: endfinally + } // end handler + IL_008a: ldnull + IL_008b: ret + + IL_008c: ldloc.s V_4 + IL_008e: ret + } // end of method InstanceTests::CaptureOfThisAndParameterInForEachWithItemCopy + + .method public hidebysig instance void + LambdaInForLoop() cil managed + { + // Code size 35 (0x23) + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldc.i4.0 + IL_0001: stloc.0 + IL_0002: br.s IL_001a + + IL_0004: ldarg.0 + IL_0005: ldarg.0 + IL_0006: ldftn instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::'b__4_0'() + IL_000c: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_0011: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::Bar(class [mscorlib]System.Func`1) + IL_0016: ldloc.0 + IL_0017: ldc.i4.1 + IL_0018: add + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: ldc.i4 0x186a0 + IL_0020: blt.s IL_0004 + + IL_0022: ret + } // end of method InstanceTests::LambdaInForLoop + + .method public hidebysig instance int32 + Foo() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } // end of method InstanceTests::Foo + + .method public hidebysig instance void + Bar(class [mscorlib]System.Func`1 f) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method InstanceTests::Bar + + .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 InstanceTests::.ctor + + .method private hidebysig instance void + 'b__0_0'() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThis() + IL_0006: pop + IL_0007: ret + } // end of method InstanceTests::'b__0_0' + + .method private hidebysig instance int32 + 'b__4_0'() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::Foo() + IL_0006: ret + } // end of method InstanceTests::'b__4_0' + + } // end of class InstanceTests + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass8_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 counter + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass8_0'::.ctor + + .method assembly hidebysig instance void + 'b__0'(int32 x) cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass8_0'::counter + IL_0007: ret + } // end of method '<>c__DisplayClass8_0'::'b__0' + + } // end of class '<>c__DisplayClass8_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass9_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 counter + .field public class [mscorlib]System.Action`1 '<>9__0' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass9_0'::.ctor + + .method assembly hidebysig instance void + 'b__0'(int32 x) cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass9_0'::counter + IL_0007: ret + } // end of method '<>c__DisplayClass9_0'::'b__0' + + } // end of class '<>c__DisplayClass9_0' + + .class auto ansi serializable sealed nested private beforefieldinit '<>c' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public static initonly class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c' '<>9' + .field public static class [mscorlib]System.Action '<>9__10_0' + .field public static class [mscorlib]System.Action`1 '<>9__12_0' + .field public static class [mscorlib]System.Action`1 '<>9__13_0' + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 11 (0xb) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::.ctor() + IL_0005: stsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9' + IL_000a: ret + } // end of method '<>c'::.cctor + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c'::.ctor + + .method assembly hidebysig instance void + 'b__10_0'() cil managed + { + // Code size 6 (0x6) + .maxstack 8 + IL_0000: call void [mscorlib]System.Console::WriteLine() + IL_0005: ret + } // end of method '<>c'::'b__10_0' + + .method assembly hidebysig instance void + 'b__12_0'(int32 i) cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: call void [mscorlib]System.Console::WriteLine(int32) + IL_0006: ret + } // end of method '<>c'::'b__12_0' + + .method assembly hidebysig instance void + 'b__13_0'(int32 j) cil managed + { + // Code size 19 (0x13) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldc.i4.0 + IL_0001: stloc.0 + IL_0002: br.s IL_000e + + IL_0004: ldloc.0 + IL_0005: call void [mscorlib]System.Console::WriteLine(int32) + IL_000a: ldloc.0 + IL_000b: ldc.i4.1 + IL_000c: add + IL_000d: stloc.0 + IL_000e: ldloc.0 + IL_000f: ldarg.1 + IL_0010: blt.s IL_0004 + + IL_0012: ret + } // end of method '<>c'::'b__13_0' + + } // end of class '<>c' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass11_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 i + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass11_0'::.ctor + + .method assembly hidebysig instance void + 'b__0'(int32 j) cil managed + { + // Code size 23 (0x17) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldc.i4.0 + IL_0001: stloc.0 + IL_0002: br.s IL_000d + + IL_0004: call void [mscorlib]System.Console::WriteLine() + IL_0009: ldloc.0 + IL_000a: ldarg.1 + IL_000b: add + IL_000c: stloc.0 + IL_000d: ldloc.0 + IL_000e: ldarg.0 + IL_000f: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::i + IL_0014: blt.s IL_0004 + + IL_0016: ret + } // end of method '<>c__DisplayClass11_0'::'b__0' + + } // end of class '<>c__DisplayClass11_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass14_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass14_0'::.ctor + + .method assembly hidebysig instance class [mscorlib]System.Func`2 + 'b__0'(int32 b) cil managed + { + // Code size 31 (0x1f) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1'::.ctor() + IL_0005: dup + IL_0006: ldarg.0 + IL_0007: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1'::'CS$<>8__locals1' + IL_000c: dup + IL_000d: ldarg.1 + IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1'::b + IL_0013: ldftn instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1'::'b__1'(int32) + IL_0019: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_001e: ret + } // end of method '<>c__DisplayClass14_0'::'b__0' + + } // end of class '<>c__DisplayClass14_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass14_1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 b + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0' 'CS$<>8__locals1' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass14_1'::.ctor + + .method assembly hidebysig instance int32 + 'b__1'(int32 c) cil managed + { + // Code size 21 (0x15) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1'::'CS$<>8__locals1' + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0'::a + IL_000b: ldarg.0 + IL_000c: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1'::b + IL_0011: add + IL_0012: ldarg.1 + IL_0013: add + IL_0014: ret + } // end of method '<>c__DisplayClass14_1'::'b__1' + + } // end of class '<>c__DisplayClass14_1' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass15_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass15_0'::.ctor + + .method assembly hidebysig instance class [mscorlib]System.Func`2> + 'b__0'(int32 b) cil managed + { + // Code size 31 (0x1f) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1'::.ctor() + IL_0005: dup + IL_0006: ldarg.0 + IL_0007: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1'::'CS$<>8__locals1' + IL_000c: dup + IL_000d: ldarg.1 + IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1'::b + IL_0013: ldftn instance class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1'::'b__1'(int32) + IL_0019: newobj instance void class [mscorlib]System.Func`2>::.ctor(object, + native int) + IL_001e: ret + } // end of method '<>c__DisplayClass15_0'::'b__0' + + } // end of class '<>c__DisplayClass15_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass15_1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 b + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0' 'CS$<>8__locals1' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass15_1'::.ctor + + .method assembly hidebysig instance class [mscorlib]System.Func`2 + 'b__1'(int32 c) cil managed + { + // Code size 31 (0x1f) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::.ctor() + IL_0005: dup + IL_0006: ldarg.0 + IL_0007: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::'CS$<>8__locals2' + IL_000c: dup + IL_000d: ldarg.1 + IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::c + IL_0013: ldftn instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::'b__2'(int32) + IL_0019: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_001e: ret + } // end of method '<>c__DisplayClass15_1'::'b__1' + + } // end of class '<>c__DisplayClass15_1' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass15_2' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 c + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1' 'CS$<>8__locals2' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass15_2'::.ctor + + .method assembly hidebysig instance int32 + 'b__2'(int32 d) cil managed + { + // Code size 38 (0x26) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::'CS$<>8__locals2' + IL_0006: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1'::'CS$<>8__locals1' + IL_000b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0'::a + IL_0010: ldarg.0 + IL_0011: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::'CS$<>8__locals2' + IL_0016: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1'::b + IL_001b: add + IL_001c: ldarg.0 + IL_001d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::c + IL_0022: add + IL_0023: ldarg.1 + IL_0024: add + IL_0025: ret + } // end of method '<>c__DisplayClass15_2'::'b__2' + + } // end of class '<>c__DisplayClass15_2' + + .method public hidebysig static void Test(string a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method DelegateConstruction::Test + + .method public hidebysig static class [mscorlib]System.Action`1 + ExtensionMethodUnbound() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::Test(string) + IL_0007: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_000c: ret + } // end of method DelegateConstruction::ExtensionMethodUnbound + + .method public hidebysig static class [mscorlib]System.Action + ExtensionMethodBound() cil managed + { + // Code size 17 (0x11) + .maxstack 8 + IL_0000: ldstr "abc" + IL_0005: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::Test(string) + IL_000b: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0010: ret + } // end of method DelegateConstruction::ExtensionMethodBound + + .method public hidebysig static class [mscorlib]System.Action + ExtensionMethodBoundOnNull() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::Test(string) + IL_0007: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_000c: ret + } // end of method DelegateConstruction::ExtensionMethodBoundOnNull + + .method public hidebysig static object + StaticMethod() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::ExtensionMethodBound() + IL_0007: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_000c: ret + } // end of method DelegateConstruction::StaticMethod + + .method public hidebysig static object + InstanceMethod() cil managed + { + // Code size 17 (0x11) + .maxstack 8 + IL_0000: ldstr "hello" + IL_0005: ldftn instance string [mscorlib]System.String::ToUpper() + IL_000b: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_0010: ret + } // end of method DelegateConstruction::InstanceMethod + + .method public hidebysig static object + InstanceMethodOnNull() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn instance string [mscorlib]System.String::ToUpper() + IL_0007: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_000c: ret + } // end of method DelegateConstruction::InstanceMethodOnNull + + .method public hidebysig static class [mscorlib]System.Collections.Generic.List`1> + AnonymousMethodStoreWithinLoop() cil managed + { + // Code size 45 (0x2d) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass8_0' V_2) + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0005: stloc.0 + IL_0006: ldc.i4.0 + IL_0007: stloc.1 + IL_0008: br.s IL_0026 + + IL_000a: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass8_0'::.ctor() + IL_000f: stloc.2 + IL_0010: ldloc.0 + IL_0011: ldloc.2 + IL_0012: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass8_0'::'b__0'(int32) + IL_0018: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_001d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_0022: ldloc.1 + IL_0023: ldc.i4.1 + IL_0024: add + IL_0025: stloc.1 + IL_0026: ldloc.1 + IL_0027: ldc.i4.s 10 + IL_0029: blt.s IL_000a + + IL_002b: ldloc.0 + IL_002c: ret + } // end of method DelegateConstruction::AnonymousMethodStoreWithinLoop + + .method public hidebysig static class [mscorlib]System.Collections.Generic.List`1> + AnonymousMethodStoreOutsideLoop() cil managed + { + // Code size 64 (0x40) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass9_0' V_0, + class [mscorlib]System.Collections.Generic.List`1> V_1, + int32 V_2, + class [mscorlib]System.Action`1 V_3) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass9_0'::.ctor() + IL_0005: stloc.0 + IL_0006: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_000b: stloc.1 + IL_000c: ldc.i4.0 + IL_000d: stloc.2 + IL_000e: br.s IL_0039 + + IL_0010: ldloc.1 + IL_0011: ldloc.0 + IL_0012: ldfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass9_0'::'<>9__0' + IL_0017: dup + IL_0018: brtrue.s IL_0030 + + IL_001a: pop + IL_001b: ldloc.0 + IL_001c: ldloc.0 + IL_001d: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass9_0'::'b__0'(int32) + IL_0023: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_0028: dup + IL_0029: stloc.3 + IL_002a: stfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass9_0'::'<>9__0' + IL_002f: ldloc.3 + IL_0030: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_0035: ldloc.2 + IL_0036: ldc.i4.1 + IL_0037: add + IL_0038: stloc.2 + IL_0039: ldloc.2 + IL_003a: ldc.i4.s 10 + IL_003c: blt.s IL_0010 + + IL_003e: ldloc.1 + IL_003f: ret + } // end of method DelegateConstruction::AnonymousMethodStoreOutsideLoop + + .method public hidebysig static class [mscorlib]System.Action + StaticAnonymousMethodNoClosure() cil managed + { + // Code size 32 (0x20) + .maxstack 8 + IL_0000: ldsfld class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9__10_0' + IL_0005: dup + IL_0006: brtrue.s IL_001f + + IL_0008: pop + IL_0009: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9' + IL_000e: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'b__10_0'() + IL_0014: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0019: dup + IL_001a: stsfld class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9__10_0' + IL_001f: ret + } // end of method DelegateConstruction::StaticAnonymousMethodNoClosure + + .method public hidebysig static void NameConflict() cil managed + { + // Code size 79 (0x4f) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0' V_2, + int32 V_3) + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0005: stloc.0 + IL_0006: ldc.i4.0 + IL_0007: stloc.1 + IL_0008: br.s IL_0049 + + IL_000a: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::.ctor() + IL_000f: stloc.2 + IL_0010: ldloc.2 + IL_0011: ldc.i4.0 + IL_0012: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::i + IL_0017: br.s IL_003b + + IL_0019: ldloc.0 + IL_001a: ldloc.2 + IL_001b: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::'b__0'(int32) + IL_0021: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_0026: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_002b: ldloc.2 + IL_002c: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::i + IL_0031: stloc.3 + IL_0032: ldloc.2 + IL_0033: ldloc.3 + IL_0034: ldc.i4.1 + IL_0035: add + IL_0036: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::i + IL_003b: ldloc.2 + IL_003c: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::i + IL_0041: ldc.i4.s 10 + IL_0043: blt.s IL_0019 + + IL_0045: ldloc.1 + IL_0046: ldc.i4.1 + IL_0047: add + IL_0048: stloc.1 + IL_0049: ldloc.1 + IL_004a: ldc.i4.s 10 + IL_004c: blt.s IL_000a + + IL_004e: ret + } // end of method DelegateConstruction::NameConflict + + .method public hidebysig static void NameConflict2(int32 j) cil managed + { + // Code size 57 (0x39) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1) + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0005: stloc.0 + IL_0006: ldc.i4.0 + IL_0007: stloc.1 + IL_0008: br.s IL_0033 + + IL_000a: ldloc.0 + IL_000b: ldsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9__12_0' + IL_0010: dup + IL_0011: brtrue.s IL_002a + + IL_0013: pop + IL_0014: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9' + IL_0019: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'b__12_0'(int32) + IL_001f: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_0024: dup + IL_0025: stsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9__12_0' + IL_002a: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_002f: ldloc.1 + IL_0030: ldc.i4.1 + IL_0031: add + IL_0032: stloc.1 + IL_0033: ldloc.1 + IL_0034: ldc.i4.s 10 + IL_0036: blt.s IL_000a + + IL_0038: ret + } // end of method DelegateConstruction::NameConflict2 + + .method public hidebysig static class [mscorlib]System.Action`1 + NameConflict3(int32 i) cil managed + { + // Code size 32 (0x20) + .maxstack 8 + IL_0000: ldsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9__13_0' + IL_0005: dup + IL_0006: brtrue.s IL_001f + + IL_0008: pop + IL_0009: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9' + IL_000e: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'b__13_0'(int32) + IL_0014: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_0019: dup + IL_001a: stsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9__13_0' + IL_001f: ret + } // end of method DelegateConstruction::NameConflict3 + + .method public hidebysig static class [mscorlib]System.Func`2> + CurriedAddition(int32 a) cil managed + { + // Code size 24 (0x18) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0'::.ctor() + IL_0005: dup + IL_0006: ldarg.0 + IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0'::a + IL_000c: ldftn instance class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0'::'b__0'(int32) + IL_0012: newobj instance void class [mscorlib]System.Func`2>::.ctor(object, + native int) + IL_0017: ret + } // end of method DelegateConstruction::CurriedAddition + + .method public hidebysig static class [mscorlib]System.Func`2>> + CurriedAddition2(int32 a) cil managed + { + // Code size 24 (0x18) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0'::.ctor() + IL_0005: dup + IL_0006: ldarg.0 + IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0'::a + IL_000c: ldftn instance class [mscorlib]System.Func`2> ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0'::'b__0'(int32) + IL_0012: newobj instance void class [mscorlib]System.Func`2>>::.ctor(object, + native int) + IL_0017: ret + } // end of method DelegateConstruction::CurriedAddition2 + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.roslyn.il new file mode 100644 index 000000000..f5ea3ce98 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.roslyn.il @@ -0,0 +1,1362 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. All rights reserved. + + + +// 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 extern System.Core +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly DelegateConstruction +{ + .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 DelegateConstruction.dll +// MVID: {8AC9B4E6-77A7-45DC-BBF4-76DB9EA29AFF} +.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: 0x01820000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction + extends [mscorlib]System.Object +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .class auto ansi nested private beforefieldinit InstanceTests + extends [mscorlib]System.Object + { + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 a + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests '<>4__this' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass1_0'::.ctor + + .method assembly hidebysig instance void + 'b__0'() cil managed + { + // Code size 20 (0x14) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0'::'<>4__this' + IL_0007: ldarg.0 + IL_0008: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0'::a + IL_000d: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThisAndParameter(int32) + IL_0012: pop + IL_0013: ret + } // end of method '<>c__DisplayClass1_0'::'b__0' + + } // end of class '<>c__DisplayClass1_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass2_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 item + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1' 'CS$<>8__locals1' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass2_0'::.ctor + + .method assembly hidebysig instance void + 'b__0'() cil managed + { + // Code size 37 (0x25) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::'CS$<>8__locals1' + IL_0007: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1'::'<>4__this' + IL_000c: ldarg.0 + IL_000d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::item + IL_0012: ldarg.0 + IL_0013: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::'CS$<>8__locals1' + IL_0018: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1'::a + IL_001d: add + IL_001e: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThisAndParameter(int32) + IL_0023: pop + IL_0024: ret + } // end of method '<>c__DisplayClass2_0'::'b__0' + + } // end of class '<>c__DisplayClass2_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass2_1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 a + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests '<>4__this' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass2_1'::.ctor + + } // end of class '<>c__DisplayClass2_1' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass3_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 item + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1' 'CS$<>8__locals1' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass3_0'::.ctor + + } // end of class '<>c__DisplayClass3_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass3_1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 a + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests '<>4__this' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass3_1'::.ctor + + } // end of class '<>c__DisplayClass3_1' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass3_2' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 copyOfItem + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' 'CS$<>8__locals2' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass3_2'::.ctor + + .method assembly hidebysig instance void + 'b__0'() cil managed + { + // Code size 59 (0x3b) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'CS$<>8__locals2' + IL_0007: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::'CS$<>8__locals1' + IL_000c: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1'::'<>4__this' + IL_0011: ldarg.0 + IL_0012: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'CS$<>8__locals2' + IL_0017: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::item + IL_001c: ldarg.0 + IL_001d: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'CS$<>8__locals2' + IL_0022: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::'CS$<>8__locals1' + IL_0027: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1'::a + IL_002c: add + IL_002d: ldarg.0 + IL_002e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::copyOfItem + IL_0033: add + IL_0034: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThisAndParameter(int32) + IL_0039: pop + IL_003a: ret + } // end of method '<>c__DisplayClass3_2'::'b__0' + + } // end of class '<>c__DisplayClass3_2' + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThis() cil managed + { + // Code size 18 (0x12) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::'b__0_0'() + IL_0008: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: br.s IL_0010 + + IL_0010: ldloc.0 + IL_0011: ret + } // end of method InstanceTests::CaptureOfThis + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThisAndParameter(int32 a) cil managed + { + // Code size 38 (0x26) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0' V_0, + class [mscorlib]System.Action V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0'::'<>4__this' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0'::a + IL_0014: nop + IL_0015: ldloc.0 + IL_0016: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass1_0'::'b__0'() + IL_001c: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0021: stloc.1 + IL_0022: br.s IL_0024 + + IL_0024: ldloc.1 + IL_0025: ret + } // end of method InstanceTests::CaptureOfThisAndParameter + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThisAndParameterInForEach(int32 a) cil managed + { + // Code size 121 (0x79) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1' V_0, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0' V_2, + bool V_3, + class [mscorlib]System.Action V_4) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1'::'<>4__this' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1'::a + IL_0014: nop + IL_0015: nop + IL_0016: call class [mscorlib]System.Collections.Generic.IEnumerable`1 [System.Core]System.Linq.Enumerable::Empty() + IL_001b: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0020: stloc.1 + .try + { + IL_0021: br.s IL_005c + + IL_0023: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::.ctor() + IL_0028: stloc.2 + IL_0029: ldloc.2 + IL_002a: ldloc.0 + IL_002b: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::'CS$<>8__locals1' + IL_0030: ldloc.2 + IL_0031: ldloc.1 + IL_0032: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0037: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::item + IL_003c: nop + IL_003d: ldloc.2 + IL_003e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::item + IL_0043: ldc.i4.0 + IL_0044: cgt + IL_0046: stloc.3 + IL_0047: ldloc.3 + IL_0048: brfalse.s IL_005b + + IL_004a: nop + IL_004b: ldloc.2 + IL_004c: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass2_0'::'b__0'() + IL_0052: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0057: stloc.s V_4 + IL_0059: leave.s IL_0076 + + IL_005b: nop + IL_005c: ldloc.1 + IL_005d: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() + IL_0062: brtrue.s IL_0023 + + IL_0064: leave.s IL_0071 + + } // end .try + finally + { + IL_0066: ldloc.1 + IL_0067: brfalse.s IL_0070 + + IL_0069: ldloc.1 + IL_006a: callvirt instance void [mscorlib]System.IDisposable::Dispose() + IL_006f: nop + IL_0070: endfinally + } // end handler + IL_0071: ldnull + IL_0072: stloc.s V_4 + IL_0074: br.s IL_0076 + + IL_0076: ldloc.s V_4 + IL_0078: ret + } // end of method InstanceTests::CaptureOfThisAndParameterInForEach + + .method public hidebysig instance class [mscorlib]System.Action + CaptureOfThisAndParameterInForEachWithItemCopy(int32 a) cil managed + { + // Code size 158 (0x9e) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1' V_0, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' V_2, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2' V_3, + bool V_4, + class [mscorlib]System.Action V_5) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1'::'<>4__this' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1'::a + IL_0014: nop + IL_0015: nop + IL_0016: call class [mscorlib]System.Collections.Generic.IEnumerable`1 [System.Core]System.Linq.Enumerable::Empty() + IL_001b: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0020: stloc.1 + .try + { + IL_0021: br.s IL_0081 + + IL_0023: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::.ctor() + IL_0028: stloc.2 + IL_0029: ldloc.2 + IL_002a: ldloc.0 + IL_002b: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::'CS$<>8__locals1' + IL_0030: ldloc.2 + IL_0031: ldloc.1 + IL_0032: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0037: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::item + IL_003c: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::.ctor() + IL_0041: stloc.3 + IL_0042: ldloc.3 + IL_0043: ldloc.2 + IL_0044: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'CS$<>8__locals2' + IL_0049: nop + IL_004a: ldloc.3 + IL_004b: ldloc.3 + IL_004c: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'CS$<>8__locals2' + IL_0051: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::item + IL_0056: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::copyOfItem + IL_005b: ldloc.3 + IL_005c: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'CS$<>8__locals2' + IL_0061: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_0'::item + IL_0066: ldc.i4.0 + IL_0067: cgt + IL_0069: stloc.s V_4 + IL_006b: ldloc.s V_4 + IL_006d: brfalse.s IL_0080 + + IL_006f: nop + IL_0070: ldloc.3 + IL_0071: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests/'<>c__DisplayClass3_2'::'b__0'() + IL_0077: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_007c: stloc.s V_5 + IL_007e: leave.s IL_009b + + IL_0080: nop + IL_0081: ldloc.1 + IL_0082: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() + IL_0087: brtrue.s IL_0023 + + IL_0089: leave.s IL_0096 + + } // end .try + finally + { + IL_008b: ldloc.1 + IL_008c: brfalse.s IL_0095 + + IL_008e: ldloc.1 + IL_008f: callvirt instance void [mscorlib]System.IDisposable::Dispose() + IL_0094: nop + IL_0095: endfinally + } // end handler + IL_0096: ldnull + IL_0097: stloc.s V_5 + IL_0099: br.s IL_009b + + IL_009b: ldloc.s V_5 + IL_009d: ret + } // end of method InstanceTests::CaptureOfThisAndParameterInForEachWithItemCopy + + .method public hidebysig instance void + LambdaInForLoop() cil managed + { + // Code size 43 (0x2b) + .maxstack 3 + .locals init (int32 V_0, + bool V_1) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: stloc.0 + IL_0003: br.s IL_001e + + IL_0005: nop + IL_0006: ldarg.0 + IL_0007: ldarg.0 + IL_0008: ldftn instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::'b__4_0'() + IL_000e: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_0013: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::Bar(class [mscorlib]System.Func`1) + IL_0018: nop + IL_0019: nop + IL_001a: ldloc.0 + IL_001b: ldc.i4.1 + IL_001c: add + IL_001d: stloc.0 + IL_001e: ldloc.0 + IL_001f: ldc.i4 0x186a0 + IL_0024: clt + IL_0026: stloc.1 + IL_0027: ldloc.1 + IL_0028: brtrue.s IL_0005 + + IL_002a: ret + } // end of method InstanceTests::LambdaInForLoop + + .method public hidebysig instance int32 + Foo() cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (int32 V_0) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method InstanceTests::Foo + + .method public hidebysig instance void + Bar(class [mscorlib]System.Func`1 f) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method InstanceTests::Bar + + .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 InstanceTests::.ctor + + .method private hidebysig instance void + 'b__0_0'() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call instance class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::CaptureOfThis() + IL_0007: pop + IL_0008: ret + } // end of method InstanceTests::'b__0_0' + + .method private hidebysig instance int32 + 'b__4_0'() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/InstanceTests::Foo() + IL_0006: ret + } // end of method InstanceTests::'b__4_0' + + } // end of class InstanceTests + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass8_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 counter + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass8_0'::.ctor + + .method assembly hidebysig instance void + 'b__0'(int32 x) cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass8_0'::counter + IL_0008: ret + } // end of method '<>c__DisplayClass8_0'::'b__0' + + } // end of class '<>c__DisplayClass8_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass9_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 counter + .field public class [mscorlib]System.Action`1 '<>9__0' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass9_0'::.ctor + + .method assembly hidebysig instance void + 'b__0'(int32 x) cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass9_0'::counter + IL_0008: ret + } // end of method '<>c__DisplayClass9_0'::'b__0' + + } // end of class '<>c__DisplayClass9_0' + + .class auto ansi serializable sealed nested private beforefieldinit '<>c' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public static initonly class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c' '<>9' + .field public static class [mscorlib]System.Action '<>9__10_0' + .field public static class [mscorlib]System.Action`1 '<>9__12_0' + .field public static class [mscorlib]System.Action`1 '<>9__13_0' + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 11 (0xb) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::.ctor() + IL_0005: stsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9' + IL_000a: ret + } // end of method '<>c'::.cctor + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::.ctor + + .method assembly hidebysig instance void + 'b__10_0'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void [mscorlib]System.Console::WriteLine() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'b__10_0' + + .method assembly hidebysig instance void + 'b__12_0'(int32 i) cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: call void [mscorlib]System.Console::WriteLine(int32) + IL_0007: nop + IL_0008: ret + } // end of method '<>c'::'b__12_0' + + .method assembly hidebysig instance void + 'b__13_0'(int32 j) cil managed + { + // Code size 27 (0x1b) + .maxstack 2 + .locals init (int32 V_0, + bool V_1) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: stloc.0 + IL_0003: br.s IL_0012 + + IL_0005: nop + IL_0006: ldloc.0 + IL_0007: call void [mscorlib]System.Console::WriteLine(int32) + IL_000c: nop + IL_000d: nop + IL_000e: ldloc.0 + IL_000f: ldc.i4.1 + IL_0010: add + IL_0011: stloc.0 + IL_0012: ldloc.0 + IL_0013: ldarg.1 + IL_0014: clt + IL_0016: stloc.1 + IL_0017: ldloc.1 + IL_0018: brtrue.s IL_0005 + + IL_001a: ret + } // end of method '<>c'::'b__13_0' + + } // end of class '<>c' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass11_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 i + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass11_0'::.ctor + + .method assembly hidebysig instance void + 'b__0'(int32 j) cil managed + { + // Code size 31 (0x1f) + .maxstack 2 + .locals init (int32 V_0, + bool V_1) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: stloc.0 + IL_0003: br.s IL_0011 + + IL_0005: nop + IL_0006: call void [mscorlib]System.Console::WriteLine() + IL_000b: nop + IL_000c: nop + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: add + IL_0010: stloc.0 + IL_0011: ldloc.0 + IL_0012: ldarg.0 + IL_0013: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::i + IL_0018: clt + IL_001a: stloc.1 + IL_001b: ldloc.1 + IL_001c: brtrue.s IL_0005 + + IL_001e: ret + } // end of method '<>c__DisplayClass11_0'::'b__0' + + } // end of class '<>c__DisplayClass11_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass14_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass14_0'::.ctor + + .method assembly hidebysig instance class [mscorlib]System.Func`2 + 'b__0'(int32 b) cil managed + { + // Code size 33 (0x21) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1' V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1'::'CS$<>8__locals1' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1'::b + IL_0014: ldloc.0 + IL_0015: ldftn instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1'::'b__1'(int32) + IL_001b: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_0020: ret + } // end of method '<>c__DisplayClass14_0'::'b__0' + + } // end of class '<>c__DisplayClass14_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass14_1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 b + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0' 'CS$<>8__locals1' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass14_1'::.ctor + + .method assembly hidebysig instance int32 + 'b__1'(int32 c) cil managed + { + // Code size 21 (0x15) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1'::'CS$<>8__locals1' + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0'::a + IL_000b: ldarg.0 + IL_000c: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_1'::b + IL_0011: add + IL_0012: ldarg.1 + IL_0013: add + IL_0014: ret + } // end of method '<>c__DisplayClass14_1'::'b__1' + + } // end of class '<>c__DisplayClass14_1' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass15_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass15_0'::.ctor + + .method assembly hidebysig instance class [mscorlib]System.Func`2> + 'b__0'(int32 b) cil managed + { + // Code size 33 (0x21) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1' V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1'::'CS$<>8__locals1' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1'::b + IL_0014: ldloc.0 + IL_0015: ldftn instance class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1'::'b__1'(int32) + IL_001b: newobj instance void class [mscorlib]System.Func`2>::.ctor(object, + native int) + IL_0020: ret + } // end of method '<>c__DisplayClass15_0'::'b__0' + + } // end of class '<>c__DisplayClass15_0' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass15_1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 b + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0' 'CS$<>8__locals1' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass15_1'::.ctor + + .method assembly hidebysig instance class [mscorlib]System.Func`2 + 'b__1'(int32 c) cil managed + { + // Code size 33 (0x21) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2' V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::'CS$<>8__locals2' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::c + IL_0014: ldloc.0 + IL_0015: ldftn instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::'b__2'(int32) + IL_001b: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_0020: ret + } // end of method '<>c__DisplayClass15_1'::'b__1' + + } // end of class '<>c__DisplayClass15_1' + + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass15_2' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 c + .field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1' 'CS$<>8__locals2' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass15_2'::.ctor + + .method assembly hidebysig instance int32 + 'b__2'(int32 d) cil managed + { + // Code size 38 (0x26) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::'CS$<>8__locals2' + IL_0006: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1'::'CS$<>8__locals1' + IL_000b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0'::a + IL_0010: ldarg.0 + IL_0011: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::'CS$<>8__locals2' + IL_0016: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_1'::b + IL_001b: add + IL_001c: ldarg.0 + IL_001d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_2'::c + IL_0022: add + IL_0023: ldarg.1 + IL_0024: add + IL_0025: ret + } // end of method '<>c__DisplayClass15_2'::'b__2' + + } // end of class '<>c__DisplayClass15_2' + + .method public hidebysig static void Test(string a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method DelegateConstruction::Test + + .method public hidebysig static class [mscorlib]System.Action`1 + ExtensionMethodUnbound() cil managed + { + // Code size 18 (0x12) + .maxstack 2 + .locals init (class [mscorlib]System.Action`1 V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::Test(string) + IL_0008: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: br.s IL_0010 + + IL_0010: ldloc.0 + IL_0011: ret + } // end of method DelegateConstruction::ExtensionMethodUnbound + + .method public hidebysig static class [mscorlib]System.Action + ExtensionMethodBound() cil managed + { + // Code size 22 (0x16) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0) + IL_0000: nop + IL_0001: ldstr "abc" + IL_0006: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::Test(string) + IL_000c: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0011: stloc.0 + IL_0012: br.s IL_0014 + + IL_0014: ldloc.0 + IL_0015: ret + } // end of method DelegateConstruction::ExtensionMethodBound + + .method public hidebysig static class [mscorlib]System.Action + ExtensionMethodBoundOnNull() cil managed + { + // Code size 18 (0x12) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::Test(string) + IL_0008: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: br.s IL_0010 + + IL_0010: ldloc.0 + IL_0011: ret + } // end of method DelegateConstruction::ExtensionMethodBoundOnNull + + .method public hidebysig static object + StaticMethod() cil managed + { + // Code size 18 (0x12) + .maxstack 2 + .locals init (object V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: ldftn class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction::ExtensionMethodBound() + IL_0008: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: br.s IL_0010 + + IL_0010: ldloc.0 + IL_0011: ret + } // end of method DelegateConstruction::StaticMethod + + .method public hidebysig static object + InstanceMethod() cil managed + { + // Code size 22 (0x16) + .maxstack 2 + .locals init (object V_0) + IL_0000: nop + IL_0001: ldstr "hello" + IL_0006: ldftn instance string [mscorlib]System.String::ToUpper() + IL_000c: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_0011: stloc.0 + IL_0012: br.s IL_0014 + + IL_0014: ldloc.0 + IL_0015: ret + } // end of method DelegateConstruction::InstanceMethod + + .method public hidebysig static object + InstanceMethodOnNull() cil managed + { + // Code size 18 (0x12) + .maxstack 2 + .locals init (object V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: ldftn instance string [mscorlib]System.String::ToUpper() + IL_0008: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: br.s IL_0010 + + IL_0010: ldloc.0 + IL_0011: ret + } // end of method DelegateConstruction::InstanceMethodOnNull + + .method public hidebysig static class [mscorlib]System.Collections.Generic.List`1> + AnonymousMethodStoreWithinLoop() cil managed + { + // Code size 59 (0x3b) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass8_0' V_2, + bool V_3, + class [mscorlib]System.Collections.Generic.List`1> V_4) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: stloc.1 + IL_0009: br.s IL_002a + + IL_000b: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass8_0'::.ctor() + IL_0010: stloc.2 + IL_0011: nop + IL_0012: ldloc.0 + IL_0013: ldloc.2 + IL_0014: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass8_0'::'b__0'(int32) + IL_001a: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_001f: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_0024: nop + IL_0025: nop + IL_0026: ldloc.1 + IL_0027: ldc.i4.1 + IL_0028: add + IL_0029: stloc.1 + IL_002a: ldloc.1 + IL_002b: ldc.i4.s 10 + IL_002d: clt + IL_002f: stloc.3 + IL_0030: ldloc.3 + IL_0031: brtrue.s IL_000b + + IL_0033: ldloc.0 + IL_0034: stloc.s V_4 + IL_0036: br.s IL_0038 + + IL_0038: ldloc.s V_4 + IL_003a: ret + } // end of method DelegateConstruction::AnonymousMethodStoreWithinLoop + + .method public hidebysig static class [mscorlib]System.Collections.Generic.List`1> + AnonymousMethodStoreOutsideLoop() cil managed + { + // Code size 80 (0x50) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass9_0' V_0, + class [mscorlib]System.Collections.Generic.List`1> V_1, + int32 V_2, + class [mscorlib]System.Action`1 V_3, + bool V_4, + class [mscorlib]System.Collections.Generic.List`1> V_5) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass9_0'::.ctor() + IL_0005: stloc.0 + IL_0006: nop + IL_0007: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_000c: stloc.1 + IL_000d: ldc.i4.0 + IL_000e: stloc.2 + IL_000f: br.s IL_003d + + IL_0011: nop + IL_0012: ldloc.1 + IL_0013: ldloc.0 + IL_0014: ldfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass9_0'::'<>9__0' + IL_0019: dup + IL_001a: brtrue.s IL_0032 + + IL_001c: pop + IL_001d: ldloc.0 + IL_001e: ldloc.0 + IL_001f: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass9_0'::'b__0'(int32) + IL_0025: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_002a: dup + IL_002b: stloc.3 + IL_002c: stfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass9_0'::'<>9__0' + IL_0031: ldloc.3 + IL_0032: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_0037: nop + IL_0038: nop + IL_0039: ldloc.2 + IL_003a: ldc.i4.1 + IL_003b: add + IL_003c: stloc.2 + IL_003d: ldloc.2 + IL_003e: ldc.i4.s 10 + IL_0040: clt + IL_0042: stloc.s V_4 + IL_0044: ldloc.s V_4 + IL_0046: brtrue.s IL_0011 + + IL_0048: ldloc.1 + IL_0049: stloc.s V_5 + IL_004b: br.s IL_004d + + IL_004d: ldloc.s V_5 + IL_004f: ret + } // end of method DelegateConstruction::AnonymousMethodStoreOutsideLoop + + .method public hidebysig static class [mscorlib]System.Action + StaticAnonymousMethodNoClosure() cil managed + { + // Code size 37 (0x25) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0) + IL_0000: nop + IL_0001: ldsfld class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9__10_0' + IL_0006: dup + IL_0007: brtrue.s IL_0020 + + IL_0009: pop + IL_000a: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9' + IL_000f: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'b__10_0'() + IL_0015: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_001a: dup + IL_001b: stsfld class [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9__10_0' + IL_0020: stloc.0 + IL_0021: br.s IL_0023 + + IL_0023: ldloc.0 + IL_0024: ret + } // end of method DelegateConstruction::StaticAnonymousMethodNoClosure + + .method public hidebysig static void NameConflict() cil managed + { + // Code size 97 (0x61) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0' V_2, + int32 V_3, + bool V_4, + bool V_5) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: stloc.1 + IL_0009: br.s IL_0055 + + IL_000b: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::.ctor() + IL_0010: stloc.2 + IL_0011: nop + IL_0012: ldloc.2 + IL_0013: ldc.i4.0 + IL_0014: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::i + IL_0019: br.s IL_0040 + + IL_001b: nop + IL_001c: ldloc.0 + IL_001d: ldloc.2 + IL_001e: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::'b__0'(int32) + IL_0024: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_0029: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_002e: nop + IL_002f: nop + IL_0030: ldloc.2 + IL_0031: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::i + IL_0036: stloc.3 + IL_0037: ldloc.2 + IL_0038: ldloc.3 + IL_0039: ldc.i4.1 + IL_003a: add + IL_003b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::i + IL_0040: ldloc.2 + IL_0041: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass11_0'::i + IL_0046: ldc.i4.s 10 + IL_0048: clt + IL_004a: stloc.s V_4 + IL_004c: ldloc.s V_4 + IL_004e: brtrue.s IL_001b + + IL_0050: nop + IL_0051: ldloc.1 + IL_0052: ldc.i4.1 + IL_0053: add + IL_0054: stloc.1 + IL_0055: ldloc.1 + IL_0056: ldc.i4.s 10 + IL_0058: clt + IL_005a: stloc.s V_5 + IL_005c: ldloc.s V_5 + IL_005e: brtrue.s IL_000b + + IL_0060: ret + } // end of method DelegateConstruction::NameConflict + + .method public hidebysig static void NameConflict2(int32 j) cil managed + { + // Code size 65 (0x41) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1> V_0, + int32 V_1, + bool V_2) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1>::.ctor() + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: stloc.1 + IL_0009: br.s IL_0037 + + IL_000b: nop + IL_000c: ldloc.0 + IL_000d: ldsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9__12_0' + IL_0012: dup + IL_0013: brtrue.s IL_002c + + IL_0015: pop + IL_0016: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9' + IL_001b: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'b__12_0'(int32) + IL_0021: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_0026: dup + IL_0027: stsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9__12_0' + IL_002c: callvirt instance void class [mscorlib]System.Collections.Generic.List`1>::Add(!0) + IL_0031: nop + IL_0032: nop + IL_0033: ldloc.1 + IL_0034: ldc.i4.1 + IL_0035: add + IL_0036: stloc.1 + IL_0037: ldloc.1 + IL_0038: ldc.i4.s 10 + IL_003a: clt + IL_003c: stloc.2 + IL_003d: ldloc.2 + IL_003e: brtrue.s IL_000b + + IL_0040: ret + } // end of method DelegateConstruction::NameConflict2 + + .method public hidebysig static class [mscorlib]System.Action`1 + NameConflict3(int32 i) cil managed + { + // Code size 37 (0x25) + .maxstack 2 + .locals init (class [mscorlib]System.Action`1 V_0) + IL_0000: nop + IL_0001: ldsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9__13_0' + IL_0006: dup + IL_0007: brtrue.s IL_0020 + + IL_0009: pop + IL_000a: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9' + IL_000f: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'b__13_0'(int32) + IL_0015: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_001a: dup + IL_001b: stsfld class [mscorlib]System.Action`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c'::'<>9__13_0' + IL_0020: stloc.0 + IL_0021: br.s IL_0023 + + IL_0023: ldloc.0 + IL_0024: ret + } // end of method DelegateConstruction::NameConflict3 + + .method public hidebysig static class [mscorlib]System.Func`2> + CurriedAddition(int32 a) cil managed + { + // Code size 31 (0x1f) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0' V_0, + class [mscorlib]System.Func`2> V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0'::a + IL_000d: nop + IL_000e: ldloc.0 + IL_000f: ldftn instance class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass14_0'::'b__0'(int32) + IL_0015: newobj instance void class [mscorlib]System.Func`2>::.ctor(object, + native int) + IL_001a: stloc.1 + IL_001b: br.s IL_001d + + IL_001d: ldloc.1 + IL_001e: ret + } // end of method DelegateConstruction::CurriedAddition + + .method public hidebysig static class [mscorlib]System.Func`2>> + CurriedAddition2(int32 a) cil managed + { + // Code size 31 (0x1f) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0' V_0, + class [mscorlib]System.Func`2>> V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0'::a + IL_000d: nop + IL_000e: ldloc.0 + IL_000f: ldftn instance class [mscorlib]System.Func`2> ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction/'<>c__DisplayClass15_0'::'b__0'(int32) + IL_0015: newobj instance void class [mscorlib]System.Func`2>>::.ctor(object, + native int) + IL_001a: stloc.1 + IL_001b: br.s IL_001d + + IL_001d: ldloc.1 + IL_001e: ret + } // end of method DelegateConstruction::CurriedAddition2 + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.DelegateConstruction + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.cs index 0ca459f92..ff1d34741 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.cs @@ -97,6 +97,17 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty } return false; } + + public void CatchWhenWithConditionWithoutExceptionVar() + { + int num = 0; + try { + throw new Exception(); + } catch (Exception) when (num == 0) { + Console.WriteLine("jo"); + } + } + #endif public bool SimpleTryFinally() @@ -144,7 +155,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty Console.WriteLine("Try"); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); - } catch (Exception ex2) { + } catch (SystemException ex2) { Console.WriteLine(ex2.Message); } catch { Console.WriteLine("other"); @@ -176,5 +187,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty } } } + + } -} +} \ No newline at end of file diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.il index 3b306dbfc..a2159701a 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.il @@ -1,5 +1,5 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17929 +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 // Copyright (c) Microsoft Corporation. All rights reserved. @@ -10,7 +10,7 @@ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 4:0:0:0 } -.assembly lxxrs5dq +.assembly vicbdq3v { .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 @@ -20,15 +20,15 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 } -.module lxxrs5dq.dll -// MVID: {82D6FFAF-FF9D-4E8C-AC93-080CC89EB80E} +.module vicbdq3v.dll +// MVID: {5E2AA050-D333-4323-8C5A-29B86C8D98BB} .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: 0x02E30000 +// Image base: 0x01160000 // =============== CLASS MEMBERS DECLARATION =================== @@ -323,7 +323,7 @@ // Code size 68 (0x44) .maxstack 1 .locals init (class [mscorlib]System.InvalidOperationException V_0, - class [mscorlib]System.Exception V_1) + class [mscorlib]System.SystemException V_1) IL_0000: nop .try { @@ -347,7 +347,7 @@ IL_001f: leave.s IL_0042 } // end handler - catch [mscorlib]System.Exception + catch [mscorlib]System.SystemException { IL_0021: stloc.1 IL_0022: nop diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.opt.il index 6845c7f24..19e1de7c6 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.opt.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.opt.il @@ -1,5 +1,5 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17929 +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 // Copyright (c) Microsoft Corporation. All rights reserved. @@ -10,7 +10,7 @@ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 4:0:0:0 } -.assembly mydv32cl +.assembly uidw4n1e { .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 @@ -20,15 +20,15 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 } -.module mydv32cl.dll -// MVID: {6B95C83E-B82F-493E-BD92-AF0A5E82F1B4} +.module uidw4n1e.dll +// MVID: {A6A100AA-2C72-4B40-9C9F-50DA438D4727} .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: 0x014A0000 +// Image base: 0x00380000 // =============== CLASS MEMBERS DECLARATION =================== @@ -258,7 +258,7 @@ // Code size 54 (0x36) .maxstack 1 .locals init (class [mscorlib]System.InvalidOperationException V_0, - class [mscorlib]System.Exception V_1) + class [mscorlib]System.SystemException V_1) .try { IL_0000: ldstr "Try" @@ -275,7 +275,7 @@ IL_0018: leave.s IL_0035 } // end handler - catch [mscorlib]System.Exception + catch [mscorlib]System.SystemException { IL_001a: stloc.1 IL_001b: ldloc.1 diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.opt.roslyn.il index 3d18c07ed..ab43a0e40 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.opt.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.opt.roslyn.il @@ -1,5 +1,5 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17929 +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 // Copyright (c) Microsoft Corporation. All rights reserved. @@ -25,14 +25,14 @@ .ver 0:0:0:0 } .module ExceptionHandling.dll -// MVID: {07FDA375-CD7B-478B-922A-E82E4CA881CF} +// MVID: {A4875794-8C32-4802-A38C-B190A38BD06B} .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: 0x02CE0000 +// Image base: 0x029B0000 // =============== CLASS MEMBERS DECLARATION =================== @@ -53,135 +53,136 @@ instance void MoveNext() cil managed { .override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext - // Code size 242 (0xf2) + // Code size 240 (0xf0) .maxstack 3 .locals init (int32 V_0, - bool V_1, - valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 V_2, - class [mscorlib]System.Exception V_3, - class [mscorlib]System.Exception V_4) + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling V_1, + bool V_2, + valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 V_3, + class [mscorlib]System.Exception V_4, + class [mscorlib]System.Exception V_5) IL_0000: ldarg.0 IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' IL_0006: stloc.0 + IL_0007: ldarg.0 + IL_0008: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>4__this' + IL_000d: stloc.1 .try { - IL_0007: ldloc.0 - IL_0008: pop - IL_0009: nop + IL_000e: ldloc.0 + IL_000f: pop + IL_0010: nop .try { - IL_000a: ldloc.0 - IL_000b: brfalse.s IL_0054 - - IL_000d: ldstr "Try" - IL_0012: call void [mscorlib]System.Console::WriteLine(string) - IL_0017: ldarg.0 - IL_0018: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>4__this' - IL_001d: callvirt instance class [mscorlib]System.Threading.Tasks.Task`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling::T() - IL_0022: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 class [mscorlib]System.Threading.Tasks.Task`1::GetAwaiter() - IL_0027: stloc.2 - IL_0028: ldloca.s V_2 - IL_002a: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::get_IsCompleted() - IL_002f: brtrue.s IL_0070 - - IL_0031: ldarg.0 - IL_0032: ldc.i4.0 - IL_0033: dup - IL_0034: stloc.0 - IL_0035: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' - IL_003a: ldarg.0 - IL_003b: ldloc.2 - IL_003c: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>u__1' - IL_0041: ldarg.0 - IL_0042: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>t__builder' - IL_0047: ldloca.s V_2 - IL_0049: ldarg.0 - IL_004a: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::AwaitUnsafeOnCompleted,valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'>(!!0&, + IL_0011: ldloc.0 + IL_0012: brfalse.s IL_0056 + + IL_0014: ldstr "Try" + IL_0019: call void [mscorlib]System.Console::WriteLine(string) + IL_001e: ldloc.1 + IL_001f: callvirt instance class [mscorlib]System.Threading.Tasks.Task`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling::T() + IL_0024: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 class [mscorlib]System.Threading.Tasks.Task`1::GetAwaiter() + IL_0029: stloc.3 + IL_002a: ldloca.s V_3 + IL_002c: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::get_IsCompleted() + IL_0031: brtrue.s IL_0072 + + IL_0033: ldarg.0 + IL_0034: ldc.i4.0 + IL_0035: dup + IL_0036: stloc.0 + IL_0037: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' + IL_003c: ldarg.0 + IL_003d: ldloc.3 + IL_003e: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>u__1' + IL_0043: ldarg.0 + IL_0044: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>t__builder' + IL_0049: ldloca.s V_3 + IL_004b: ldarg.0 + IL_004c: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::AwaitUnsafeOnCompleted,valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'>(!!0&, !!1&) - IL_004f: leave IL_00f1 - - IL_0054: ldarg.0 - IL_0055: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>u__1' - IL_005a: stloc.2 - IL_005b: ldarg.0 - IL_005c: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>u__1' - IL_0061: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 - IL_0067: ldarg.0 - IL_0068: ldc.i4.m1 - IL_0069: dup - IL_006a: stloc.0 - IL_006b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' - IL_0070: ldloca.s V_2 - IL_0072: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::GetResult() - IL_0077: ldloca.s V_2 - IL_0079: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 - IL_007f: stloc.1 - IL_0080: leave.s IL_00dd + IL_0051: leave IL_00ef + + IL_0056: ldarg.0 + IL_0057: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>u__1' + IL_005c: stloc.3 + IL_005d: ldarg.0 + IL_005e: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>u__1' + IL_0063: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 + IL_0069: ldarg.0 + IL_006a: ldc.i4.m1 + IL_006b: dup + IL_006c: stloc.0 + IL_006d: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' + IL_0072: ldloca.s V_3 + IL_0074: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::GetResult() + IL_0079: stloc.2 + IL_007a: leave.s IL_00db } // end .try filter { - IL_0082: isinst [mscorlib]System.Exception - IL_0087: dup - IL_0088: brtrue.s IL_008e - - IL_008a: pop - IL_008b: ldc.i4.0 - IL_008c: br.s IL_00a6 - - IL_008e: stloc.3 - IL_008f: ldloc.3 - IL_0090: isinst [mscorlib]System.ArgumentException - IL_0095: brtrue.s IL_00a2 - - IL_0097: ldloc.3 - IL_0098: isinst [mscorlib]System.IO.IOException - IL_009d: ldnull - IL_009e: cgt.un - IL_00a0: br.s IL_00a3 - - IL_00a2: ldc.i4.1 - IL_00a3: ldc.i4.0 - IL_00a4: cgt.un - IL_00a6: endfilter + IL_007c: isinst [mscorlib]System.Exception + IL_0081: dup + IL_0082: brtrue.s IL_0088 + + IL_0084: pop + IL_0085: ldc.i4.0 + IL_0086: br.s IL_00a3 + + IL_0088: stloc.s V_4 + IL_008a: ldloc.s V_4 + IL_008c: isinst [mscorlib]System.ArgumentException + IL_0091: brtrue.s IL_009f + + IL_0093: ldloc.s V_4 + IL_0095: isinst [mscorlib]System.IO.IOException + IL_009a: ldnull + IL_009b: cgt.un + IL_009d: br.s IL_00a0 + + IL_009f: ldc.i4.1 + IL_00a0: ldc.i4.0 + IL_00a1: cgt.un + IL_00a3: endfilter } // end filter { // handler - IL_00a8: pop - IL_00a9: ldstr "CatchException ex: " - IL_00ae: ldloc.3 - IL_00af: callvirt instance string [mscorlib]System.Object::ToString() - IL_00b4: call string [mscorlib]System.String::Concat(string, + IL_00a5: pop + IL_00a6: ldstr "CatchException ex: " + IL_00ab: ldloc.s V_4 + IL_00ad: callvirt instance string [mscorlib]System.Object::ToString() + IL_00b2: call string [mscorlib]System.String::Concat(string, string) - IL_00b9: call void [mscorlib]System.Console::WriteLine(string) - IL_00be: leave.s IL_00c0 + IL_00b7: call void [mscorlib]System.Console::WriteLine(string) + IL_00bc: leave.s IL_00be } // end handler - IL_00c0: ldc.i4.0 - IL_00c1: stloc.1 - IL_00c2: leave.s IL_00dd + IL_00be: ldc.i4.0 + IL_00bf: stloc.2 + IL_00c0: leave.s IL_00db } // end .try catch [mscorlib]System.Exception { - IL_00c4: stloc.s V_4 - IL_00c6: ldarg.0 - IL_00c7: ldc.i4.s -2 - IL_00c9: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' - IL_00ce: ldarg.0 - IL_00cf: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>t__builder' - IL_00d4: ldloc.s V_4 - IL_00d6: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetException(class [mscorlib]System.Exception) - IL_00db: leave.s IL_00f1 + IL_00c2: stloc.s V_5 + IL_00c4: ldarg.0 + IL_00c5: ldc.i4.s -2 + IL_00c7: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' + IL_00cc: ldarg.0 + IL_00cd: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>t__builder' + IL_00d2: ldloc.s V_5 + IL_00d4: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetException(class [mscorlib]System.Exception) + IL_00d9: leave.s IL_00ef } // end handler - IL_00dd: ldarg.0 - IL_00de: ldc.i4.s -2 - IL_00e0: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' - IL_00e5: ldarg.0 - IL_00e6: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>t__builder' - IL_00eb: ldloc.1 - IL_00ec: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetResult(!0) - IL_00f1: ret + IL_00db: ldarg.0 + IL_00dc: ldc.i4.s -2 + IL_00de: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' + IL_00e3: ldarg.0 + IL_00e4: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>t__builder' + IL_00e9: ldloc.2 + IL_00ea: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetResult(!0) + IL_00ef: ret } // end of method 'd__8'::MoveNext .method private hidebysig newslot virtual final @@ -478,6 +479,48 @@ IL_0038: ret } // end of method ExceptionHandling::SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr + .method public hidebysig instance void + CatchWhenWithConditionWithoutExceptionVar() cil managed + { + // Code size 44 (0x2c) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldc.i4.0 + IL_0001: stloc.0 + .try + { + IL_0002: newobj instance void [mscorlib]System.Exception::.ctor() + IL_0007: throw + + } // end .try + filter + { + IL_0008: isinst [mscorlib]System.Exception + IL_000d: dup + IL_000e: brtrue.s IL_0014 + + IL_0010: pop + IL_0011: ldc.i4.0 + IL_0012: br.s IL_001c + + IL_0014: pop + IL_0015: ldloc.0 + IL_0016: ldc.i4.0 + IL_0017: ceq + IL_0019: ldc.i4.0 + IL_001a: cgt.un + IL_001c: endfilter + } // end filter + { // handler + IL_001e: pop + IL_001f: ldstr "jo" + IL_0024: call void [mscorlib]System.Console::WriteLine(string) + IL_0029: leave.s IL_002b + + } // end handler + IL_002b: ret + } // end of method ExceptionHandling::CatchWhenWithConditionWithoutExceptionVar + .method public hidebysig instance bool SimpleTryFinally() cil managed { @@ -586,7 +629,7 @@ IL_0016: leave.s IL_0031 } // end handler - catch [mscorlib]System.Exception + catch [mscorlib]System.SystemException { IL_0018: callvirt instance string [mscorlib]System.Exception::get_Message() IL_001d: call void [mscorlib]System.Console::WriteLine(string) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.roslyn.il index a2b3cfc11..6270c48d0 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.roslyn.il @@ -1,5 +1,5 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17929 +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 // Copyright (c) Microsoft Corporation. All rights reserved. @@ -25,14 +25,14 @@ .ver 0:0:0:0 } .module ExceptionHandling.dll -// MVID: {07B52948-317B-4C30-A2A5-A7482568AD67} +// MVID: {9413A96F-08C3-4F13-A800-C6BE70786A44} .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: 0x00ED0000 +// Image base: 0x00370000 // =============== CLASS MEMBERS DECLARATION =================== @@ -66,15 +66,14 @@ instance void MoveNext() cil managed { .override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext - // Code size 306 (0x132) + // Code size 295 (0x127) .maxstack 3 .locals init (int32 V_0, bool V_1, valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 V_2, - bool V_3, - class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8' V_4, - class [mscorlib]System.Exception V_5, - bool V_6) + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8' V_3, + class [mscorlib]System.Exception V_4, + bool V_5) IL_0000: ldarg.0 IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' IL_0006: stloc.0 @@ -96,7 +95,7 @@ IL_0013: br.s IL_0017 - IL_0015: br.s IL_0065 + IL_0015: br.s IL_0064 IL_0017: nop IL_0018: ldstr "Try" @@ -109,7 +108,7 @@ IL_0033: stloc.2 IL_0034: ldloca.s V_2 IL_0036: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::get_IsCompleted() - IL_003b: brtrue.s IL_0081 + IL_003b: brtrue.s IL_0080 IL_003d: ldarg.0 IL_003e: ldc.i4.0 @@ -120,117 +119,113 @@ IL_0047: ldloc.2 IL_0048: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>u__1' IL_004d: ldarg.0 - IL_004e: stloc.s V_4 - IL_0050: ldarg.0 - IL_0051: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>t__builder' - IL_0056: ldloca.s V_2 - IL_0058: ldloca.s V_4 - IL_005a: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::AwaitUnsafeOnCompleted,class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'>(!!0&, + IL_004e: stloc.3 + IL_004f: ldarg.0 + IL_0050: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>t__builder' + IL_0055: ldloca.s V_2 + IL_0057: ldloca.s V_3 + IL_0059: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::AwaitUnsafeOnCompleted,class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'>(!!0&, !!1&) - IL_005f: nop - IL_0060: leave IL_0131 - - IL_0065: ldarg.0 - IL_0066: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>u__1' - IL_006b: stloc.2 - IL_006c: ldarg.0 - IL_006d: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>u__1' - IL_0072: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 - IL_0078: ldarg.0 - IL_0079: ldc.i4.m1 - IL_007a: dup - IL_007b: stloc.0 - IL_007c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' + IL_005e: nop + IL_005f: leave IL_0126 + + IL_0064: ldarg.0 + IL_0065: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>u__1' + IL_006a: stloc.2 + IL_006b: ldarg.0 + IL_006c: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>u__1' + IL_0071: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 + IL_0077: ldarg.0 + IL_0078: ldc.i4.m1 + IL_0079: dup + IL_007a: stloc.0 + IL_007b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' + IL_0080: ldarg.0 IL_0081: ldloca.s V_2 IL_0083: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::GetResult() - IL_0088: stloc.3 - IL_0089: ldloca.s V_2 - IL_008b: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 - IL_0091: ldarg.0 - IL_0092: ldloc.3 - IL_0093: stfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>s__1' - IL_0098: ldarg.0 - IL_0099: ldfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>s__1' - IL_009e: stloc.1 - IL_009f: leave.s IL_011c + IL_0088: stfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>s__1' + IL_008d: ldarg.0 + IL_008e: ldfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>s__1' + IL_0093: stloc.1 + IL_0094: leave.s IL_0111 } // end .try filter { - IL_00a1: isinst [mscorlib]System.Exception - IL_00a6: dup - IL_00a7: brtrue.s IL_00ad - - IL_00a9: pop - IL_00aa: ldc.i4.0 - IL_00ab: br.s IL_00dc - - IL_00ad: stloc.s V_5 - IL_00af: ldarg.0 - IL_00b0: ldloc.s V_5 - IL_00b2: stfld class [mscorlib]System.Exception ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'5__2' - IL_00b7: ldarg.0 - IL_00b8: ldfld class [mscorlib]System.Exception ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'5__2' - IL_00bd: isinst [mscorlib]System.ArgumentException - IL_00c2: brtrue.s IL_00d4 - - IL_00c4: ldarg.0 - IL_00c5: ldfld class [mscorlib]System.Exception ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'5__2' - IL_00ca: isinst [mscorlib]System.IO.IOException - IL_00cf: ldnull - IL_00d0: cgt.un - IL_00d2: br.s IL_00d5 - - IL_00d4: ldc.i4.1 - IL_00d5: stloc.s V_6 - IL_00d7: ldloc.s V_6 - IL_00d9: ldc.i4.0 - IL_00da: cgt.un - IL_00dc: endfilter + IL_0096: isinst [mscorlib]System.Exception + IL_009b: dup + IL_009c: brtrue.s IL_00a2 + + IL_009e: pop + IL_009f: ldc.i4.0 + IL_00a0: br.s IL_00d1 + + IL_00a2: stloc.s V_4 + IL_00a4: ldarg.0 + IL_00a5: ldloc.s V_4 + IL_00a7: stfld class [mscorlib]System.Exception ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'5__2' + IL_00ac: ldarg.0 + IL_00ad: ldfld class [mscorlib]System.Exception ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'5__2' + IL_00b2: isinst [mscorlib]System.ArgumentException + IL_00b7: brtrue.s IL_00c9 + + IL_00b9: ldarg.0 + IL_00ba: ldfld class [mscorlib]System.Exception ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'5__2' + IL_00bf: isinst [mscorlib]System.IO.IOException + IL_00c4: ldnull + IL_00c5: cgt.un + IL_00c7: br.s IL_00ca + + IL_00c9: ldc.i4.1 + IL_00ca: stloc.s V_5 + IL_00cc: ldloc.s V_5 + IL_00ce: ldc.i4.0 + IL_00cf: cgt.un + IL_00d1: endfilter } // end filter { // handler - IL_00de: pop - IL_00df: nop - IL_00e0: ldstr "CatchException ex: " - IL_00e5: ldarg.0 - IL_00e6: ldfld class [mscorlib]System.Exception ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'5__2' - IL_00eb: callvirt instance string [mscorlib]System.Object::ToString() - IL_00f0: call string [mscorlib]System.String::Concat(string, + IL_00d3: pop + IL_00d4: nop + IL_00d5: ldstr "CatchException ex: " + IL_00da: ldarg.0 + IL_00db: ldfld class [mscorlib]System.Exception ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'5__2' + IL_00e0: callvirt instance string [mscorlib]System.Object::ToString() + IL_00e5: call string [mscorlib]System.String::Concat(string, string) - IL_00f5: call void [mscorlib]System.Console::WriteLine(string) - IL_00fa: nop - IL_00fb: nop - IL_00fc: leave.s IL_00fe + IL_00ea: call void [mscorlib]System.Console::WriteLine(string) + IL_00ef: nop + IL_00f0: nop + IL_00f1: leave.s IL_00f3 } // end handler - IL_00fe: ldc.i4.0 - IL_00ff: stloc.1 - IL_0100: leave.s IL_011c + IL_00f3: ldc.i4.0 + IL_00f4: stloc.1 + IL_00f5: leave.s IL_0111 } // end .try catch [mscorlib]System.Exception { - IL_0102: stloc.s V_5 - IL_0104: ldarg.0 - IL_0105: ldc.i4.s -2 - IL_0107: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' - IL_010c: ldarg.0 - IL_010d: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>t__builder' - IL_0112: ldloc.s V_5 - IL_0114: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetException(class [mscorlib]System.Exception) - IL_0119: nop - IL_011a: leave.s IL_0131 + IL_00f7: stloc.s V_4 + IL_00f9: ldarg.0 + IL_00fa: ldc.i4.s -2 + IL_00fc: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' + IL_0101: ldarg.0 + IL_0102: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>t__builder' + IL_0107: ldloc.s V_4 + IL_0109: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetException(class [mscorlib]System.Exception) + IL_010e: nop + IL_010f: leave.s IL_0126 } // end handler - IL_011c: ldarg.0 - IL_011d: ldc.i4.s -2 - IL_011f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' - IL_0124: ldarg.0 - IL_0125: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>t__builder' - IL_012a: ldloc.1 - IL_012b: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetResult(!0) - IL_0130: nop - IL_0131: ret + IL_0111: ldarg.0 + IL_0112: ldc.i4.s -2 + IL_0114: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>1__state' + IL_0119: ldarg.0 + IL_011a: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'d__8'::'<>t__builder' + IL_011f: ldloc.1 + IL_0120: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetResult(!0) + IL_0125: nop + IL_0126: ret } // end of method 'd__8'::MoveNext .method private hidebysig newslot virtual final @@ -570,6 +565,56 @@ IL_003a: ret } // end of method ExceptionHandling::SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr + .method public hidebysig instance void + CatchWhenWithConditionWithoutExceptionVar() cil managed + { + // Code size 51 (0x33) + .maxstack 2 + .locals init (int32 V_0, + bool V_1) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: stloc.0 + .try + { + IL_0003: nop + IL_0004: newobj instance void [mscorlib]System.Exception::.ctor() + IL_0009: throw + + } // end .try + filter + { + IL_000a: isinst [mscorlib]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0016 + + IL_0012: pop + IL_0013: ldc.i4.0 + IL_0014: br.s IL_0020 + + IL_0016: pop + IL_0017: ldloc.0 + IL_0018: ldc.i4.0 + IL_0019: ceq + IL_001b: stloc.1 + IL_001c: ldloc.1 + IL_001d: ldc.i4.0 + IL_001e: cgt.un + IL_0020: endfilter + } // end filter + { // handler + IL_0022: pop + IL_0023: nop + IL_0024: ldstr "jo" + IL_0029: call void [mscorlib]System.Console::WriteLine(string) + IL_002e: nop + IL_002f: nop + IL_0030: leave.s IL_0032 + + } // end handler + IL_0032: ret + } // end of method ExceptionHandling::CatchWhenWithConditionWithoutExceptionVar + .method public hidebysig instance bool SimpleTryFinally() cil managed { @@ -700,7 +745,7 @@ // Code size 67 (0x43) .maxstack 1 .locals init (class [mscorlib]System.InvalidOperationException V_0, - class [mscorlib]System.Exception V_1) + class [mscorlib]System.SystemException V_1) IL_0000: nop .try { @@ -724,7 +769,7 @@ IL_001f: leave.s IL_0042 } // end handler - catch [mscorlib]System.Exception + catch [mscorlib]System.SystemException { IL_0021: stloc.1 IL_0022: nop diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.cs new file mode 100644 index 000000000..35a6e5740 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace ICSharpCode.Decompiler.Tests.TestCases.ILPretty +{ + internal class A + { + protected internal virtual Task Test(string test) + { + return Task.Run(() => test.ToUpper()); + } + } + + internal class B : A + { + protected internal override async Task Test(string test) + { + return await base.Test(test); + } + } + + internal class C + { + protected internal virtual string Test(string test) + { + return string.Join(test, "fsdf"); + } + } + + internal class D : C + { + protected internal IEnumerable Test2(string test) + { + yield return base.Test(test); + } + } + + internal class E + { + protected internal virtual string Test(string test) + { + return string.Join(test, "fsdf"); + } + } + + internal class F : E + { + protected internal override string Test(string test) + { + Func func = (string a) => base.Test(a); + test = string.Join(test, "aa"); + return func(test); + } + } + + internal class G + { + protected internal virtual void Test(string test) + { + string.Join(test, "fsdf"); + } + } + + internal class H : G + { + protected internal override void Test(string test) + { + Action action = delegate(string a) { + base.Test(a); + }; + if (test.Equals(1)) { + throw new Exception("roslyn optimize is inlining the assignment which lets the test fail"); + } + action(test); + } + } + + internal class I + { + protected internal virtual void Test(int a) + { + + } + } + + internal class J : I + { + protected internal override void Test(int a) + { + Action action = delegate { + base.Test(a); + }; + if (a.Equals(1)) { + throw new Exception("roslyn optimize is inlining the assignment which lets the test fail"); + } + action(); + + } + } + + internal class K + { + protected internal virtual IEnumerable Test(int p) + { + yield return p + 1; + yield return p + 2; + } + } + + internal class L : K + { + protected internal override IEnumerable Test(int p) + { + yield return base.Test(base.Test(0).GetEnumerator().Current).GetEnumerator().Current; + } + } +} \ No newline at end of file diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.il new file mode 100644 index 000000000..69f149030 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.il @@ -0,0 +1,1579 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly kjibydgt +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module kjibydgt.dll +// MVID: {7F7E319E-D28C-421B-B3A6-A5F71C1BC3A5} +.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: 0x02700000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A + extends [mscorlib]System.Object +{ + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public string test + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1'::.ctor + + .method public hidebysig instance string + 'b__0'() cil managed + { + // Code size 16 (0x10) + .maxstack 1 + .locals init (string V_0) + IL_0000: ldarg.0 + IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass1'::test + IL_0006: callvirt instance string [mscorlib]System.String::ToUpper() + IL_000b: stloc.0 + IL_000c: br.s IL_000e + + IL_000e: ldloc.0 + IL_000f: ret + } // end of method '<>c__DisplayClass1'::'b__0' + + } // end of class '<>c__DisplayClass1' + + .method famorassem hidebysig newslot virtual + instance class [mscorlib]System.Threading.Tasks.Task`1 + Test(string test) cil managed + { + // Code size 36 (0x24) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass1' V_0, + class [mscorlib]System.Threading.Tasks.Task`1 V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass1'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.1 + IL_0008: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass1'::test + IL_000d: nop + IL_000e: ldloc.0 + IL_000f: ldftn instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass1'::'b__0'() + IL_0015: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_001a: call class [mscorlib]System.Threading.Tasks.Task`1 [mscorlib]System.Threading.Tasks.Task::Run(class [mscorlib]System.Func`1) + IL_001f: stloc.1 + IL_0020: br.s IL_0022 + + IL_0022: ldloc.1 + IL_0023: ret + } // end of method A::Test + + .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 A::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.ValueType + implements [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 '<>1__state' + .field public valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 '<>t__builder' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B '<>4__this' + .field public string test + .field private valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 '<>u__$awaiter1' + .field private object '<>t__stack' + .method private hidebysig newslot virtual final + instance void MoveNext() cil managed + { + .override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext + // Code size 184 (0xb8) + .maxstack 3 + .locals init (bool V_0, + string V_1, + class [mscorlib]System.Exception V_2, + int32 V_3, + valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 V_4, + valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 V_5) + .try + { + IL_0000: ldc.i4.1 + IL_0001: stloc.0 + IL_0002: ldarg.0 + IL_0003: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0008: stloc.3 + IL_0009: ldloc.3 + IL_000a: ldc.i4.0 + IL_000b: beq.s IL_000f + + IL_000d: br.s IL_0011 + + IL_000f: br.s IL_0057 + + IL_0011: br.s IL_0013 + + IL_0013: nop + IL_0014: ldarg.0 + IL_0015: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>4__this' + IL_001a: ldarg.0 + IL_001b: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::test + IL_0020: call instance class [mscorlib]System.Threading.Tasks.Task`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B::'<>n__FabricatedMethod2'(string) + IL_0025: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 class [mscorlib]System.Threading.Tasks.Task`1::GetAwaiter() + IL_002a: stloc.s V_4 + IL_002c: ldloca.s V_4 + IL_002e: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::get_IsCompleted() + IL_0033: brtrue.s IL_0076 + + IL_0035: ldarg.0 + IL_0036: ldc.i4.0 + IL_0037: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_003c: ldarg.0 + IL_003d: ldloc.s V_4 + IL_003f: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>u__$awaiter1' + IL_0044: ldarg.0 + IL_0045: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_004a: ldloca.s V_4 + IL_004c: ldarg.0 + IL_004d: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::AwaitUnsafeOnCompleted,valuetype ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'>(!!0&, + !!1&) + IL_0052: nop + IL_0053: ldc.i4.0 + IL_0054: stloc.0 + IL_0055: leave.s IL_00b6 + + IL_0057: ldarg.0 + IL_0058: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>u__$awaiter1' + IL_005d: stloc.s V_4 + IL_005f: ldarg.0 + IL_0060: ldloca.s V_5 + IL_0062: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 + IL_0068: ldloc.s V_5 + IL_006a: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>u__$awaiter1' + IL_006f: ldarg.0 + IL_0070: ldc.i4.m1 + IL_0071: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0076: ldloca.s V_4 + IL_0078: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::GetResult() + IL_007d: ldloca.s V_4 + IL_007f: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 + IL_0085: stloc.1 + IL_0086: leave.s IL_00a0 + + } // end .try + catch [mscorlib]System.Exception + { + IL_0088: stloc.2 + IL_0089: ldarg.0 + IL_008a: ldc.i4.s -2 + IL_008c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0091: ldarg.0 + IL_0092: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_0097: ldloc.2 + IL_0098: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetException(class [mscorlib]System.Exception) + IL_009d: nop + IL_009e: leave.s IL_00b6 + + } // end handler + IL_00a0: nop + IL_00a1: ldarg.0 + IL_00a2: ldc.i4.s -2 + IL_00a4: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_00a9: ldarg.0 + IL_00aa: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_00af: ldloc.1 + IL_00b0: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetResult(!0) + IL_00b5: nop + IL_00b6: nop + IL_00b7: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot virtual final + instance void SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine param0) cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::SetStateMachine + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_0006: ldarg.1 + IL_0007: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine) + IL_000c: ret + } // end of method 'd__0'::SetStateMachine + + } // end of class 'd__0' + + .method famorassem hidebysig virtual instance class [mscorlib]System.Threading.Tasks.Task`1 + Test(string test) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.AsyncStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 3C 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..d__0. + 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerStepThroughAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 70 (0x46) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0' V_0, + class [mscorlib]System.Threading.Tasks.Task`1 V_1, + valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 V_2) + IL_0000: ldloca.s V_0 + IL_0002: ldarg.0 + IL_0003: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>4__this' + IL_0008: ldloca.s V_0 + IL_000a: ldarg.1 + IL_000b: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::test + IL_0010: ldloca.s V_0 + IL_0012: call valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::Create() + IL_0017: stfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_001c: ldloca.s V_0 + IL_001e: ldc.i4.m1 + IL_001f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0024: ldloca.s V_0 + IL_0026: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_002b: stloc.2 + IL_002c: ldloca.s V_2 + IL_002e: ldloca.s V_0 + IL_0030: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::Startd__0'>(!!0&) + IL_0035: ldloca.s V_0 + IL_0037: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_003c: call instance class [mscorlib]System.Threading.Tasks.Task`1 valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::get_Task() + IL_0041: stloc.1 + IL_0042: br.s IL_0044 + + IL_0044: ldloc.1 + IL_0045: ret + } // end of method B::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A::.ctor() + IL_0006: ret + } // end of method B::.ctor + + .method private hidebysig instance class [mscorlib]System.Threading.Tasks.Task`1 + '<>n__FabricatedMethod2'(string A_1) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 12 (0xc) + .maxstack 2 + .locals init (class [mscorlib]System.Threading.Tasks.Task`1 V_0) + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance class [mscorlib]System.Threading.Tasks.Task`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A::Test(string) + IL_0007: stloc.0 + IL_0008: br.s IL_000a + + IL_000a: ldloc.0 + IL_000b: ret + } // end of method B::'<>n__FabricatedMethod2' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance string Test(string test) cil managed + { + // Code size 28 (0x1c) + .maxstack 4 + .locals init (string V_0, + string[] V_1) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldc.i4.1 + IL_0003: newarr [mscorlib]System.String + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: ldc.i4.0 + IL_000b: ldstr "fsdf" + IL_0010: stelem.ref + IL_0011: ldloc.1 + IL_0012: call string [mscorlib]System.String::Join(string, + string[]) + IL_0017: stloc.0 + IL_0018: br.s IL_001a + + IL_001a: ldloc.0 + IL_001b: ret + } // end of method C::Test + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method C::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements class [mscorlib]System.Collections.Generic.IEnumerable`1, + [mscorlib]System.Collections.IEnumerable, + class [mscorlib]System.Collections.Generic.IEnumerator`1, + [mscorlib]System.Collections.IEnumerator, + [mscorlib]System.IDisposable + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private string '<>2__current' + .field private int32 '<>1__state' + .field private int32 '<>l__initialThreadId' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D '<>4__this' + .field public string test + .field public string '<>3__test' + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.Generic.IEnumerator`1 + 'System.Collections.Generic.IEnumerable.GetEnumerator'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + // Code size 82 (0x52) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0' V_0, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_1, + bool V_2) + IL_0000: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0005: ldarg.0 + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>l__initialThreadId' + IL_000b: bne.un.s IL_001c + + IL_000d: ldarg.0 + IL_000e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0013: ldc.i4.s -2 + IL_0015: ceq + IL_0017: ldc.i4.0 + IL_0018: ceq + IL_001a: br.s IL_001d + + IL_001c: ldc.i4.1 + IL_001d: nop + IL_001e: stloc.2 + IL_001f: ldloc.2 + IL_0020: brtrue.s IL_002d + + IL_0022: ldarg.0 + IL_0023: ldc.i4.0 + IL_0024: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0029: ldarg.0 + IL_002a: stloc.0 + IL_002b: br.s IL_0040 + + IL_002d: ldc.i4.0 + IL_002e: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::.ctor(int32) + IL_0033: stloc.0 + IL_0034: ldloc.0 + IL_0035: ldarg.0 + IL_0036: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_003b: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_0040: ldloc.0 + IL_0041: ldarg.0 + IL_0042: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>3__test' + IL_0047: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::test + IL_004c: ldloc.0 + IL_004d: stloc.1 + IL_004e: br.s IL_0050 + + IL_0050: ldloc.1 + IL_0051: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerable.GetEnumerator' + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.IEnumerator + System.Collections.IEnumerable.GetEnumerator() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerable::GetEnumerator + // Code size 11 (0xb) + .maxstack 1 + .locals init (class [mscorlib]System.Collections.IEnumerator V_0) + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'System.Collections.Generic.IEnumerable.GetEnumerator'() + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method 'd__0'::System.Collections.IEnumerable.GetEnumerator + + .method private hidebysig newslot virtual final + instance bool MoveNext() cil managed + { + .override [mscorlib]System.Collections.IEnumerator::MoveNext + // Code size 85 (0x55) + .maxstack 3 + .locals init (bool V_0, + int32 V_1) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0006: stloc.1 + IL_0007: ldloc.1 + IL_0008: switch ( + IL_0019, + IL_0017) + IL_0015: br.s IL_001b + + IL_0017: br.s IL_0047 + + IL_0019: br.s IL_001d + + IL_001b: br.s IL_004f + + IL_001d: ldarg.0 + IL_001e: ldc.i4.m1 + IL_001f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0024: nop + IL_0025: ldarg.0 + IL_0026: ldarg.0 + IL_0027: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_002c: ldarg.0 + IL_002d: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::test + IL_0032: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D::'<>n__FabricatedMethod1'(string) + IL_0037: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>2__current' + IL_003c: ldarg.0 + IL_003d: ldc.i4.1 + IL_003e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0043: ldc.i4.1 + IL_0044: stloc.0 + IL_0045: br.s IL_0053 + + IL_0047: ldarg.0 + IL_0048: ldc.i4.m1 + IL_0049: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_004e: nop + IL_004f: ldc.i4.0 + IL_0050: stloc.0 + IL_0051: br.s IL_0053 + + IL_0053: ldloc.0 + IL_0054: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot specialname virtual final + instance string 'System.Collections.Generic.IEnumerator.get_Current'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + // Code size 11 (0xb) + .maxstack 1 + .locals init (string V_0) + IL_0000: ldarg.0 + IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>2__current' + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerator.get_Current' + + .method private hidebysig newslot virtual final + instance void System.Collections.IEnumerator.Reset() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::Reset + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0005: throw + } // end of method 'd__0'::System.Collections.IEnumerator.Reset + + .method private hidebysig newslot virtual final + instance void System.IDisposable.Dispose() cil managed + { + .override [mscorlib]System.IDisposable::Dispose + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method 'd__0'::System.IDisposable.Dispose + + .method private hidebysig newslot specialname virtual final + instance object System.Collections.IEnumerator.get_Current() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::get_Current + // Code size 11 (0xb) + .maxstack 1 + .locals init (object V_0) + IL_0000: ldarg.0 + IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>2__current' + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method 'd__0'::System.Collections.IEnumerator.get_Current + + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 '<>1__state') cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 25 (0x19) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_000d: ldarg.0 + IL_000e: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0013: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>l__initialThreadId' + IL_0018: ret + } // end of method 'd__0'::.ctor + + .property instance string 'System.Collections.Generic.IEnumerator.Current'() + { + .get instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'System.Collections.Generic.IEnumerator.get_Current'() + } // end of property 'd__0'::'System.Collections.Generic.IEnumerator.Current' + .property instance object System.Collections.IEnumerator.Current() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::System.Collections.IEnumerator.get_Current() + } // end of property 'd__0'::System.Collections.IEnumerator.Current + } // end of class 'd__0' + + .method famorassem hidebysig instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + Test2(string test) cil managed + { + // Code size 28 (0x1c) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0' V_0, + class [mscorlib]System.Collections.Generic.IEnumerable`1 V_1) + IL_0000: ldc.i4.s -2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::.ctor(int32) + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldarg.0 + IL_000a: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_000f: ldloc.0 + IL_0010: ldarg.1 + IL_0011: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>3__test' + IL_0016: ldloc.0 + IL_0017: stloc.1 + IL_0018: br.s IL_001a + + IL_001a: ldloc.1 + IL_001b: ret + } // end of method D::Test2 + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C::.ctor() + IL_0006: ret + } // end of method D::.ctor + + .method private hidebysig instance string + '<>n__FabricatedMethod1'(string A_1) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 12 (0xc) + .maxstack 2 + .locals init (string V_0) + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C::Test(string) + IL_0007: stloc.0 + IL_0008: br.s IL_000a + + IL_000a: ldloc.0 + IL_000b: ret + } // end of method D::'<>n__FabricatedMethod1' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance string Test(string test) cil managed + { + // Code size 28 (0x1c) + .maxstack 4 + .locals init (string V_0, + string[] V_1) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldc.i4.1 + IL_0003: newarr [mscorlib]System.String + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: ldc.i4.0 + IL_000b: ldstr "fsdf" + IL_0010: stelem.ref + IL_0011: ldloc.1 + IL_0012: call string [mscorlib]System.String::Join(string, + string[]) + IL_0017: stloc.0 + IL_0018: br.s IL_001a + + IL_001a: ldloc.0 + IL_001b: ret + } // end of method E::Test + + .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 E::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E +{ + .method famorassem hidebysig virtual instance string + Test(string test) cil managed + { + // Code size 50 (0x32) + .maxstack 4 + .locals init (class [mscorlib]System.Func`2 V_0, + string V_1, + string[] V_2) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldftn instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F::'b__0'(string) + IL_0008: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: ldarg.1 + IL_000f: ldc.i4.1 + IL_0010: newarr [mscorlib]System.String + IL_0015: stloc.2 + IL_0016: ldloc.2 + IL_0017: ldc.i4.0 + IL_0018: ldstr "aa" + IL_001d: stelem.ref + IL_001e: ldloc.2 + IL_001f: call string [mscorlib]System.String::Join(string, + string[]) + IL_0024: starg.s test + IL_0026: ldloc.0 + IL_0027: ldarg.1 + IL_0028: callvirt instance !1 class [mscorlib]System.Func`2::Invoke(!0) + IL_002d: stloc.1 + IL_002e: br.s IL_0030 + + IL_0030: ldloc.1 + IL_0031: ret + } // end of method F::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E::.ctor() + IL_0006: ret + } // end of method F::.ctor + + .method private hidebysig instance string + '<>n__FabricatedMethod1'(string A_1) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 12 (0xc) + .maxstack 2 + .locals init (string V_0) + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E::Test(string) + IL_0007: stloc.0 + IL_0008: br.s IL_000a + + IL_000a: ldloc.0 + IL_000b: ret + } // end of method F::'<>n__FabricatedMethod1' + + .method private hidebysig instance string + 'b__0'(string a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 12 (0xc) + .maxstack 2 + .locals init (string V_0) + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F::'<>n__FabricatedMethod1'(string) + IL_0007: stloc.0 + IL_0008: br.s IL_000a + + IL_000a: ldloc.0 + IL_000b: ret + } // end of method F::'b__0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance void Test(string test) cil managed + { + // Code size 25 (0x19) + .maxstack 4 + .locals init (string[] V_0) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldc.i4.1 + IL_0003: newarr [mscorlib]System.String + IL_0008: stloc.0 + IL_0009: ldloc.0 + IL_000a: ldc.i4.0 + IL_000b: ldstr "fsdf" + IL_0010: stelem.ref + IL_0011: ldloc.0 + IL_0012: call string [mscorlib]System.String::Join(string, + string[]) + IL_0017: pop + IL_0018: ret + } // end of method G::Test + + .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 G::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G +{ + .method famorassem hidebysig virtual instance void + Test(string test) cil managed + { + // Code size 54 (0x36) + .maxstack 2 + .locals init (class [mscorlib]System.Action`1 V_0, + bool V_1) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H::'b__0'(string) + IL_0008: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: ldarg.1 + IL_000f: ldc.i4.1 + IL_0010: box [mscorlib]System.Int32 + IL_0015: callvirt instance bool [mscorlib]System.Object::Equals(object) + IL_001a: ldc.i4.0 + IL_001b: ceq + IL_001d: stloc.1 + IL_001e: ldloc.1 + IL_001f: brtrue.s IL_002d + + IL_0021: nop + IL_0022: ldstr "roslyn optimize is inlining the assignment which l" + + "ets the test fail" + IL_0027: newobj instance void [mscorlib]System.Exception::.ctor(string) + IL_002c: throw + + IL_002d: ldloc.0 + IL_002e: ldarg.1 + IL_002f: callvirt instance void class [mscorlib]System.Action`1::Invoke(!0) + IL_0034: nop + IL_0035: ret + } // end of method H::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G::.ctor() + IL_0006: ret + } // end of method H::.ctor + + .method private hidebysig instance void + '<>n__FabricatedMethod1'(string A_1) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G::Test(string) + IL_0007: ret + } // end of method H::'<>n__FabricatedMethod1' + + .method private hidebysig instance void + 'b__0'(string a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 10 (0xa) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H::'<>n__FabricatedMethod1'(string) + IL_0008: nop + IL_0009: ret + } // end of method H::'b__0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance void Test(int32 a) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method I::Test + + .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 I::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I +{ + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J '<>4__this' + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1'::.ctor + + .method public hidebysig instance void + 'b__0'() cil managed + { + // Code size 20 (0x14) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::'<>4__this' + IL_0007: ldarg.0 + IL_0008: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::a + IL_000d: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J::'<>n__FabricatedMethod3'(int32) + IL_0012: nop + IL_0013: ret + } // end of method '<>c__DisplayClass1'::'b__0' + + } // end of class '<>c__DisplayClass1' + + .method famorassem hidebysig virtual instance void + Test(int32 a) cil managed + { + // Code size 74 (0x4a) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0, + class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1' V_1, + bool V_2) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::.ctor() + IL_0005: stloc.1 + IL_0006: ldloc.1 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::a + IL_000d: ldloc.1 + IL_000e: ldarg.0 + IL_000f: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::'<>4__this' + IL_0014: nop + IL_0015: ldloc.1 + IL_0016: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::'b__0'() + IL_001c: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0021: stloc.0 + IL_0022: ldloc.1 + IL_0023: ldflda int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::a + IL_0028: ldc.i4.1 + IL_0029: call instance bool [mscorlib]System.Int32::Equals(int32) + IL_002e: ldc.i4.0 + IL_002f: ceq + IL_0031: stloc.2 + IL_0032: ldloc.2 + IL_0033: brtrue.s IL_0041 + + IL_0035: nop + IL_0036: ldstr "roslyn optimize is inlining the assignment which l" + + "ets the test fail" + IL_003b: newobj instance void [mscorlib]System.Exception::.ctor(string) + IL_0040: throw + + IL_0041: ldloc.0 + IL_0042: callvirt instance void [mscorlib]System.Action::Invoke() + IL_0047: nop + IL_0048: nop + IL_0049: ret + } // end of method J::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I::.ctor() + IL_0006: ret + } // end of method J::.ctor + + .method private hidebysig instance void + '<>n__FabricatedMethod3'(int32 A_1) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I::Test(int32) + IL_0007: ret + } // end of method J::'<>n__FabricatedMethod3' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K + extends [mscorlib]System.Object +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements class [mscorlib]System.Collections.Generic.IEnumerable`1, + [mscorlib]System.Collections.IEnumerable, + class [mscorlib]System.Collections.Generic.IEnumerator`1, + [mscorlib]System.Collections.IEnumerator, + [mscorlib]System.IDisposable + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private int32 '<>2__current' + .field private int32 '<>1__state' + .field private int32 '<>l__initialThreadId' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K '<>4__this' + .field public int32 p + .field public int32 '<>3__p' + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.Generic.IEnumerator`1 + 'System.Collections.Generic.IEnumerable.GetEnumerator'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + // Code size 82 (0x52) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0' V_0, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_1, + bool V_2) + IL_0000: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0005: ldarg.0 + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>l__initialThreadId' + IL_000b: bne.un.s IL_001c + + IL_000d: ldarg.0 + IL_000e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0013: ldc.i4.s -2 + IL_0015: ceq + IL_0017: ldc.i4.0 + IL_0018: ceq + IL_001a: br.s IL_001d + + IL_001c: ldc.i4.1 + IL_001d: nop + IL_001e: stloc.2 + IL_001f: ldloc.2 + IL_0020: brtrue.s IL_002d + + IL_0022: ldarg.0 + IL_0023: ldc.i4.0 + IL_0024: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0029: ldarg.0 + IL_002a: stloc.0 + IL_002b: br.s IL_0040 + + IL_002d: ldc.i4.0 + IL_002e: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::.ctor(int32) + IL_0033: stloc.0 + IL_0034: ldloc.0 + IL_0035: ldarg.0 + IL_0036: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>4__this' + IL_003b: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>4__this' + IL_0040: ldloc.0 + IL_0041: ldarg.0 + IL_0042: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>3__p' + IL_0047: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::p + IL_004c: ldloc.0 + IL_004d: stloc.1 + IL_004e: br.s IL_0050 + + IL_0050: ldloc.1 + IL_0051: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerable.GetEnumerator' + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.IEnumerator + System.Collections.IEnumerable.GetEnumerator() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerable::GetEnumerator + // Code size 11 (0xb) + .maxstack 1 + .locals init (class [mscorlib]System.Collections.IEnumerator V_0) + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'System.Collections.Generic.IEnumerable.GetEnumerator'() + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method 'd__0'::System.Collections.IEnumerable.GetEnumerator + + .method private hidebysig newslot virtual final + instance bool MoveNext() cil managed + { + .override [mscorlib]System.Collections.IEnumerator::MoveNext + // Code size 114 (0x72) + .maxstack 3 + .locals init (bool V_0, + int32 V_1) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0006: stloc.1 + IL_0007: ldloc.1 + IL_0008: switch ( + IL_001f, + IL_001b, + IL_001d) + IL_0019: br.s IL_0021 + + IL_001b: br.s IL_0044 + + IL_001d: br.s IL_0064 + + IL_001f: br.s IL_0023 + + IL_0021: br.s IL_006c + + IL_0023: ldarg.0 + IL_0024: ldc.i4.m1 + IL_0025: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_002a: nop + IL_002b: ldarg.0 + IL_002c: ldarg.0 + IL_002d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::p + IL_0032: ldc.i4.1 + IL_0033: add + IL_0034: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0039: ldarg.0 + IL_003a: ldc.i4.1 + IL_003b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0040: ldc.i4.1 + IL_0041: stloc.0 + IL_0042: br.s IL_0070 + + IL_0044: ldarg.0 + IL_0045: ldc.i4.m1 + IL_0046: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_004b: ldarg.0 + IL_004c: ldarg.0 + IL_004d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::p + IL_0052: ldc.i4.2 + IL_0053: add + IL_0054: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0059: ldarg.0 + IL_005a: ldc.i4.2 + IL_005b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0060: ldc.i4.1 + IL_0061: stloc.0 + IL_0062: br.s IL_0070 + + IL_0064: ldarg.0 + IL_0065: ldc.i4.m1 + IL_0066: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_006b: nop + IL_006c: ldc.i4.0 + IL_006d: stloc.0 + IL_006e: br.s IL_0070 + + IL_0070: ldloc.0 + IL_0071: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot specialname virtual final + instance int32 'System.Collections.Generic.IEnumerator.get_Current'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + // Code size 11 (0xb) + .maxstack 1 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerator.get_Current' + + .method private hidebysig newslot virtual final + instance void System.Collections.IEnumerator.Reset() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::Reset + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0005: throw + } // end of method 'd__0'::System.Collections.IEnumerator.Reset + + .method private hidebysig newslot virtual final + instance void System.IDisposable.Dispose() cil managed + { + .override [mscorlib]System.IDisposable::Dispose + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method 'd__0'::System.IDisposable.Dispose + + .method private hidebysig newslot specialname virtual final + instance object System.Collections.IEnumerator.get_Current() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::get_Current + // Code size 16 (0x10) + .maxstack 1 + .locals init (object V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0006: box [mscorlib]System.Int32 + IL_000b: stloc.0 + IL_000c: br.s IL_000e + + IL_000e: ldloc.0 + IL_000f: ret + } // end of method 'd__0'::System.Collections.IEnumerator.get_Current + + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 '<>1__state') cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 25 (0x19) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_000d: ldarg.0 + IL_000e: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0013: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>l__initialThreadId' + IL_0018: ret + } // end of method 'd__0'::.ctor + + .property instance int32 'System.Collections.Generic.IEnumerator.Current'() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'System.Collections.Generic.IEnumerator.get_Current'() + } // end of property 'd__0'::'System.Collections.Generic.IEnumerator.Current' + .property instance object System.Collections.IEnumerator.Current() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::System.Collections.IEnumerator.get_Current() + } // end of property 'd__0'::System.Collections.IEnumerator.Current + } // end of class 'd__0' + + .method famorassem hidebysig newslot virtual + instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + Test(int32 p) cil managed + { + // Code size 28 (0x1c) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0' V_0, + class [mscorlib]System.Collections.Generic.IEnumerable`1 V_1) + IL_0000: ldc.i4.s -2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::.ctor(int32) + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldarg.0 + IL_000a: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>4__this' + IL_000f: ldloc.0 + IL_0010: ldarg.1 + IL_0011: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>3__p' + IL_0016: ldloc.0 + IL_0017: stloc.1 + IL_0018: br.s IL_001a + + IL_001a: ldloc.1 + IL_001b: ret + } // end of method K::Test + + .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 K::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements class [mscorlib]System.Collections.Generic.IEnumerable`1, + [mscorlib]System.Collections.IEnumerable, + class [mscorlib]System.Collections.Generic.IEnumerator`1, + [mscorlib]System.Collections.IEnumerator, + [mscorlib]System.IDisposable + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private int32 '<>2__current' + .field private int32 '<>1__state' + .field private int32 '<>l__initialThreadId' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L '<>4__this' + .field public int32 p + .field public int32 '<>3__p' + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.Generic.IEnumerator`1 + 'System.Collections.Generic.IEnumerable.GetEnumerator'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + // Code size 82 (0x52) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0' V_0, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_1, + bool V_2) + IL_0000: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0005: ldarg.0 + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>l__initialThreadId' + IL_000b: bne.un.s IL_001c + + IL_000d: ldarg.0 + IL_000e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0013: ldc.i4.s -2 + IL_0015: ceq + IL_0017: ldc.i4.0 + IL_0018: ceq + IL_001a: br.s IL_001d + + IL_001c: ldc.i4.1 + IL_001d: nop + IL_001e: stloc.2 + IL_001f: ldloc.2 + IL_0020: brtrue.s IL_002d + + IL_0022: ldarg.0 + IL_0023: ldc.i4.0 + IL_0024: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0029: ldarg.0 + IL_002a: stloc.0 + IL_002b: br.s IL_0040 + + IL_002d: ldc.i4.0 + IL_002e: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::.ctor(int32) + IL_0033: stloc.0 + IL_0034: ldloc.0 + IL_0035: ldarg.0 + IL_0036: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_003b: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_0040: ldloc.0 + IL_0041: ldarg.0 + IL_0042: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>3__p' + IL_0047: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::p + IL_004c: ldloc.0 + IL_004d: stloc.1 + IL_004e: br.s IL_0050 + + IL_0050: ldloc.1 + IL_0051: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerable.GetEnumerator' + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.IEnumerator + System.Collections.IEnumerable.GetEnumerator() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerable::GetEnumerator + // Code size 11 (0xb) + .maxstack 1 + .locals init (class [mscorlib]System.Collections.IEnumerator V_0) + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'System.Collections.Generic.IEnumerable.GetEnumerator'() + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method 'd__0'::System.Collections.IEnumerable.GetEnumerator + + .method private hidebysig newslot virtual final + instance bool MoveNext() cil managed + { + .override [mscorlib]System.Collections.IEnumerator::MoveNext + // Code size 111 (0x6f) + .maxstack 4 + .locals init (bool V_0, + int32 V_1) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0006: stloc.1 + IL_0007: ldloc.1 + IL_0008: switch ( + IL_0019, + IL_0017) + IL_0015: br.s IL_001b + + IL_0017: br.s IL_0061 + + IL_0019: br.s IL_001d + + IL_001b: br.s IL_0069 + + IL_001d: ldarg.0 + IL_001e: ldc.i4.m1 + IL_001f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0024: nop + IL_0025: ldarg.0 + IL_0026: ldarg.0 + IL_0027: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_002c: ldarg.0 + IL_002d: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_0032: ldc.i4.0 + IL_0033: call instance class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L::'<>n__FabricatedMethod1'(int32) + IL_0038: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_003d: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0042: call instance class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L::'<>n__FabricatedMethod1'(int32) + IL_0047: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_004c: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0051: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>2__current' + IL_0056: ldarg.0 + IL_0057: ldc.i4.1 + IL_0058: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_005d: ldc.i4.1 + IL_005e: stloc.0 + IL_005f: br.s IL_006d + + IL_0061: ldarg.0 + IL_0062: ldc.i4.m1 + IL_0063: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0068: nop + IL_0069: ldc.i4.0 + IL_006a: stloc.0 + IL_006b: br.s IL_006d + + IL_006d: ldloc.0 + IL_006e: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot specialname virtual final + instance int32 'System.Collections.Generic.IEnumerator.get_Current'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + // Code size 11 (0xb) + .maxstack 1 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>2__current' + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerator.get_Current' + + .method private hidebysig newslot virtual final + instance void System.Collections.IEnumerator.Reset() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::Reset + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0005: throw + } // end of method 'd__0'::System.Collections.IEnumerator.Reset + + .method private hidebysig newslot virtual final + instance void System.IDisposable.Dispose() cil managed + { + .override [mscorlib]System.IDisposable::Dispose + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method 'd__0'::System.IDisposable.Dispose + + .method private hidebysig newslot specialname virtual final + instance object System.Collections.IEnumerator.get_Current() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::get_Current + // Code size 16 (0x10) + .maxstack 1 + .locals init (object V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>2__current' + IL_0006: box [mscorlib]System.Int32 + IL_000b: stloc.0 + IL_000c: br.s IL_000e + + IL_000e: ldloc.0 + IL_000f: ret + } // end of method 'd__0'::System.Collections.IEnumerator.get_Current + + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 '<>1__state') cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 25 (0x19) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_000d: ldarg.0 + IL_000e: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0013: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>l__initialThreadId' + IL_0018: ret + } // end of method 'd__0'::.ctor + + .property instance int32 'System.Collections.Generic.IEnumerator.Current'() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'System.Collections.Generic.IEnumerator.get_Current'() + } // end of property 'd__0'::'System.Collections.Generic.IEnumerator.Current' + .property instance object System.Collections.IEnumerator.Current() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::System.Collections.IEnumerator.get_Current() + } // end of property 'd__0'::System.Collections.IEnumerator.Current + } // end of class 'd__0' + + .method famorassem hidebysig virtual instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + Test(int32 p) cil managed + { + // Code size 28 (0x1c) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0' V_0, + class [mscorlib]System.Collections.Generic.IEnumerable`1 V_1) + IL_0000: ldc.i4.s -2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::.ctor(int32) + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldarg.0 + IL_000a: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_000f: ldloc.0 + IL_0010: ldarg.1 + IL_0011: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>3__p' + IL_0016: ldloc.0 + IL_0017: stloc.1 + IL_0018: br.s IL_001a + + IL_001a: ldloc.1 + IL_001b: ret + } // end of method L::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K::.ctor() + IL_0006: ret + } // end of method L::.ctor + + .method private hidebysig instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + '<>n__FabricatedMethod1'(int32 A_1) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 12 (0xc) + .maxstack 2 + .locals init (class [mscorlib]System.Collections.Generic.IEnumerable`1 V_0) + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K::Test(int32) + IL_0007: stloc.0 + IL_0008: br.s IL_000a + + IL_000a: ldloc.0 + IL_000b: ret + } // end of method L::'<>n__FabricatedMethod1' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** +// Warnung: Win32-Ressourcendatei "../../../TestCases/Pretty\FixProxyCalls.res" wurde erstellt. diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.opt.il new file mode 100644 index 000000000..b26753120 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.opt.il @@ -0,0 +1,1323 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly b0rqcnnq +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module b0rqcnnq.dll +// MVID: {D8989CD1-06F3-4E8C-8C4C-7F7B95ACB488} +.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: 0x00810000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A + extends [mscorlib]System.Object +{ + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public string test + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1'::.ctor + + .method public hidebysig instance string + 'b__0'() cil managed + { + // Code size 12 (0xc) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass1'::test + IL_0006: callvirt instance string [mscorlib]System.String::ToUpper() + IL_000b: ret + } // end of method '<>c__DisplayClass1'::'b__0' + + } // end of class '<>c__DisplayClass1' + + .method famorassem hidebysig newslot virtual + instance class [mscorlib]System.Threading.Tasks.Task`1 + Test(string test) cil managed + { + // Code size 31 (0x1f) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass1' V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass1'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.1 + IL_0008: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass1'::test + IL_000d: ldloc.0 + IL_000e: ldftn instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass1'::'b__0'() + IL_0014: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_0019: call class [mscorlib]System.Threading.Tasks.Task`1 [mscorlib]System.Threading.Tasks.Task::Run(class [mscorlib]System.Func`1) + IL_001e: ret + } // end of method A::Test + + .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 A::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.ValueType + implements [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 '<>1__state' + .field public valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 '<>t__builder' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B '<>4__this' + .field public string test + .field private valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 '<>u__$awaiter1' + .field private object '<>t__stack' + .method private hidebysig newslot virtual final + instance void MoveNext() cil managed + { + .override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext + // Code size 172 (0xac) + .maxstack 3 + .locals init (bool V_0, + string V_1, + class [mscorlib]System.Exception V_2, + int32 V_3, + valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 V_4, + valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 V_5) + .try + { + IL_0000: ldc.i4.1 + IL_0001: stloc.0 + IL_0002: ldarg.0 + IL_0003: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0008: stloc.3 + IL_0009: ldloc.3 + IL_000a: ldc.i4.0 + IL_000b: beq.s IL_004f + + IL_000d: ldarg.0 + IL_000e: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>4__this' + IL_0013: ldarg.0 + IL_0014: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::test + IL_0019: call instance class [mscorlib]System.Threading.Tasks.Task`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B::'<>n__FabricatedMethod2'(string) + IL_001e: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 class [mscorlib]System.Threading.Tasks.Task`1::GetAwaiter() + IL_0023: stloc.s V_4 + IL_0025: ldloca.s V_4 + IL_0027: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::get_IsCompleted() + IL_002c: brtrue.s IL_006e + + IL_002e: ldarg.0 + IL_002f: ldc.i4.0 + IL_0030: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0035: ldarg.0 + IL_0036: ldloc.s V_4 + IL_0038: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>u__$awaiter1' + IL_003d: ldarg.0 + IL_003e: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_0043: ldloca.s V_4 + IL_0045: ldarg.0 + IL_0046: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::AwaitUnsafeOnCompleted,valuetype ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'>(!!0&, + !!1&) + IL_004b: ldc.i4.0 + IL_004c: stloc.0 + IL_004d: leave.s IL_00ab + + IL_004f: ldarg.0 + IL_0050: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>u__$awaiter1' + IL_0055: stloc.s V_4 + IL_0057: ldarg.0 + IL_0058: ldloca.s V_5 + IL_005a: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 + IL_0060: ldloc.s V_5 + IL_0062: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>u__$awaiter1' + IL_0067: ldarg.0 + IL_0068: ldc.i4.m1 + IL_0069: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_006e: ldloca.s V_4 + IL_0070: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::GetResult() + IL_0075: ldloca.s V_4 + IL_0077: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 + IL_007d: stloc.1 + IL_007e: leave.s IL_0097 + + } // end .try + catch [mscorlib]System.Exception + { + IL_0080: stloc.2 + IL_0081: ldarg.0 + IL_0082: ldc.i4.s -2 + IL_0084: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0089: ldarg.0 + IL_008a: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_008f: ldloc.2 + IL_0090: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetException(class [mscorlib]System.Exception) + IL_0095: leave.s IL_00ab + + } // end handler + IL_0097: ldarg.0 + IL_0098: ldc.i4.s -2 + IL_009a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_009f: ldarg.0 + IL_00a0: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_00a5: ldloc.1 + IL_00a6: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetResult(!0) + IL_00ab: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot virtual final + instance void SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine param0) cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::SetStateMachine + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_0006: ldarg.1 + IL_0007: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine) + IL_000c: ret + } // end of method 'd__0'::SetStateMachine + + } // end of class 'd__0' + + .method famorassem hidebysig virtual instance class [mscorlib]System.Threading.Tasks.Task`1 + Test(string test) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.AsyncStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 3C 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..d__0. + 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerStepThroughAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 66 (0x42) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0' V_0, + valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 V_1) + IL_0000: ldloca.s V_0 + IL_0002: ldarg.0 + IL_0003: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>4__this' + IL_0008: ldloca.s V_0 + IL_000a: ldarg.1 + IL_000b: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::test + IL_0010: ldloca.s V_0 + IL_0012: call valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::Create() + IL_0017: stfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_001c: ldloca.s V_0 + IL_001e: ldc.i4.m1 + IL_001f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0024: ldloca.s V_0 + IL_0026: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_002b: stloc.1 + IL_002c: ldloca.s V_1 + IL_002e: ldloca.s V_0 + IL_0030: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::Startd__0'>(!!0&) + IL_0035: ldloca.s V_0 + IL_0037: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_003c: call instance class [mscorlib]System.Threading.Tasks.Task`1 valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::get_Task() + IL_0041: ret + } // end of method B::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A::.ctor() + IL_0006: ret + } // end of method B::.ctor + + .method private hidebysig instance class [mscorlib]System.Threading.Tasks.Task`1 + '<>n__FabricatedMethod2'(string A_1) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance class [mscorlib]System.Threading.Tasks.Task`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A::Test(string) + IL_0007: ret + } // end of method B::'<>n__FabricatedMethod2' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance string Test(string test) cil managed + { + // Code size 23 (0x17) + .maxstack 4 + .locals init (string[] V_0) + IL_0000: ldarg.1 + IL_0001: ldc.i4.1 + IL_0002: newarr [mscorlib]System.String + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldc.i4.0 + IL_000a: ldstr "fsdf" + IL_000f: stelem.ref + IL_0010: ldloc.0 + IL_0011: call string [mscorlib]System.String::Join(string, + string[]) + IL_0016: ret + } // end of method C::Test + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method C::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements class [mscorlib]System.Collections.Generic.IEnumerable`1, + [mscorlib]System.Collections.IEnumerable, + class [mscorlib]System.Collections.Generic.IEnumerator`1, + [mscorlib]System.Collections.IEnumerator, + [mscorlib]System.IDisposable + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private string '<>2__current' + .field private int32 '<>1__state' + .field private int32 '<>l__initialThreadId' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D '<>4__this' + .field public string test + .field public string '<>3__test' + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.Generic.IEnumerator`1 + 'System.Collections.Generic.IEnumerable.GetEnumerator'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + // Code size 67 (0x43) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0' V_0) + IL_0000: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0005: ldarg.0 + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>l__initialThreadId' + IL_000b: bne.un.s IL_0022 + + IL_000d: ldarg.0 + IL_000e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0013: ldc.i4.s -2 + IL_0015: bne.un.s IL_0022 + + IL_0017: ldarg.0 + IL_0018: ldc.i4.0 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: stloc.0 + IL_0020: br.s IL_0035 + + IL_0022: ldc.i4.0 + IL_0023: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::.ctor(int32) + IL_0028: stloc.0 + IL_0029: ldloc.0 + IL_002a: ldarg.0 + IL_002b: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_0030: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_0035: ldloc.0 + IL_0036: ldarg.0 + IL_0037: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>3__test' + IL_003c: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::test + IL_0041: ldloc.0 + IL_0042: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerable.GetEnumerator' + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.IEnumerator + System.Collections.IEnumerable.GetEnumerator() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerable::GetEnumerator + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'System.Collections.Generic.IEnumerable.GetEnumerator'() + IL_0006: ret + } // end of method 'd__0'::System.Collections.IEnumerable.GetEnumerator + + .method private hidebysig newslot virtual final + instance bool MoveNext() cil managed + { + .override [mscorlib]System.Collections.IEnumerator::MoveNext + // Code size 71 (0x47) + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: switch ( + IL_0017, + IL_003e) + IL_0015: br.s IL_0045 + + IL_0017: ldarg.0 + IL_0018: ldc.i4.m1 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: ldarg.0 + IL_0020: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_0025: ldarg.0 + IL_0026: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::test + IL_002b: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D::'<>n__FabricatedMethod1'(string) + IL_0030: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>2__current' + IL_0035: ldarg.0 + IL_0036: ldc.i4.1 + IL_0037: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_003c: ldc.i4.1 + IL_003d: ret + + IL_003e: ldarg.0 + IL_003f: ldc.i4.m1 + IL_0040: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0045: ldc.i4.0 + IL_0046: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot specialname virtual final + instance string 'System.Collections.Generic.IEnumerator.get_Current'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>2__current' + IL_0006: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerator.get_Current' + + .method private hidebysig newslot virtual final + instance void System.Collections.IEnumerator.Reset() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::Reset + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0005: throw + } // end of method 'd__0'::System.Collections.IEnumerator.Reset + + .method private hidebysig newslot virtual final + instance void System.IDisposable.Dispose() cil managed + { + .override [mscorlib]System.IDisposable::Dispose + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method 'd__0'::System.IDisposable.Dispose + + .method private hidebysig newslot specialname virtual final + instance object System.Collections.IEnumerator.get_Current() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::get_Current + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>2__current' + IL_0006: ret + } // end of method 'd__0'::System.Collections.IEnumerator.get_Current + + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 '<>1__state') cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 25 (0x19) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_000d: ldarg.0 + IL_000e: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0013: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>l__initialThreadId' + IL_0018: ret + } // end of method 'd__0'::.ctor + + .property instance string 'System.Collections.Generic.IEnumerator.Current'() + { + .get instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'System.Collections.Generic.IEnumerator.get_Current'() + } // end of property 'd__0'::'System.Collections.Generic.IEnumerator.Current' + .property instance object System.Collections.IEnumerator.Current() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::System.Collections.IEnumerator.get_Current() + } // end of property 'd__0'::System.Collections.IEnumerator.Current + } // end of class 'd__0' + + .method famorassem hidebysig instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + Test2(string test) cil managed + { + // Code size 24 (0x18) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0' V_0) + IL_0000: ldc.i4.s -2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::.ctor(int32) + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldarg.0 + IL_000a: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_000f: ldloc.0 + IL_0010: ldarg.1 + IL_0011: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>3__test' + IL_0016: ldloc.0 + IL_0017: ret + } // end of method D::Test2 + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C::.ctor() + IL_0006: ret + } // end of method D::.ctor + + .method private hidebysig instance string + '<>n__FabricatedMethod1'(string A_1) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C::Test(string) + IL_0007: ret + } // end of method D::'<>n__FabricatedMethod1' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance string Test(string test) cil managed + { + // Code size 23 (0x17) + .maxstack 4 + .locals init (string[] V_0) + IL_0000: ldarg.1 + IL_0001: ldc.i4.1 + IL_0002: newarr [mscorlib]System.String + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldc.i4.0 + IL_000a: ldstr "fsdf" + IL_000f: stelem.ref + IL_0010: ldloc.0 + IL_0011: call string [mscorlib]System.String::Join(string, + string[]) + IL_0016: ret + } // end of method E::Test + + .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 E::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E +{ + .method famorassem hidebysig virtual instance string + Test(string test) cil managed + { + // Code size 45 (0x2d) + .maxstack 4 + .locals init (class [mscorlib]System.Func`2 V_0, + string[] V_1) + IL_0000: ldarg.0 + IL_0001: ldftn instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F::'b__0'(string) + IL_0007: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_000c: stloc.0 + IL_000d: ldarg.1 + IL_000e: ldc.i4.1 + IL_000f: newarr [mscorlib]System.String + IL_0014: stloc.1 + IL_0015: ldloc.1 + IL_0016: ldc.i4.0 + IL_0017: ldstr "aa" + IL_001c: stelem.ref + IL_001d: ldloc.1 + IL_001e: call string [mscorlib]System.String::Join(string, + string[]) + IL_0023: starg.s test + IL_0025: ldloc.0 + IL_0026: ldarg.1 + IL_0027: callvirt instance !1 class [mscorlib]System.Func`2::Invoke(!0) + IL_002c: ret + } // end of method F::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E::.ctor() + IL_0006: ret + } // end of method F::.ctor + + .method private hidebysig instance string + '<>n__FabricatedMethod1'(string A_1) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E::Test(string) + IL_0007: ret + } // end of method F::'<>n__FabricatedMethod1' + + .method private hidebysig instance string + 'b__0'(string a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F::'<>n__FabricatedMethod1'(string) + IL_0007: ret + } // end of method F::'b__0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance void Test(string test) cil managed + { + // Code size 24 (0x18) + .maxstack 4 + .locals init (string[] V_0) + IL_0000: ldarg.1 + IL_0001: ldc.i4.1 + IL_0002: newarr [mscorlib]System.String + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldc.i4.0 + IL_000a: ldstr "fsdf" + IL_000f: stelem.ref + IL_0010: ldloc.0 + IL_0011: call string [mscorlib]System.String::Join(string, + string[]) + IL_0016: pop + IL_0017: ret + } // end of method G::Test + + .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 G::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G +{ + .method famorassem hidebysig virtual instance void + Test(string test) cil managed + { + // Code size 46 (0x2e) + .maxstack 2 + .locals init (class [mscorlib]System.Action`1 V_0) + IL_0000: ldarg.0 + IL_0001: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H::'b__0'(string) + IL_0007: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_000c: stloc.0 + IL_000d: ldarg.1 + IL_000e: ldc.i4.1 + IL_000f: box [mscorlib]System.Int32 + IL_0014: callvirt instance bool [mscorlib]System.Object::Equals(object) + IL_0019: brfalse.s IL_0026 + + IL_001b: ldstr "roslyn optimize is inlining the assignment which l" + + "ets the test fail" + IL_0020: newobj instance void [mscorlib]System.Exception::.ctor(string) + IL_0025: throw + + IL_0026: ldloc.0 + IL_0027: ldarg.1 + IL_0028: callvirt instance void class [mscorlib]System.Action`1::Invoke(!0) + IL_002d: ret + } // end of method H::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G::.ctor() + IL_0006: ret + } // end of method H::.ctor + + .method private hidebysig instance void + '<>n__FabricatedMethod1'(string A_1) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G::Test(string) + IL_0007: ret + } // end of method H::'<>n__FabricatedMethod1' + + .method private hidebysig instance void + 'b__0'(string a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H::'<>n__FabricatedMethod1'(string) + IL_0007: ret + } // end of method H::'b__0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance void Test(int32 a) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method I::Test + + .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 I::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I +{ + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J '<>4__this' + .field public int32 a + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass1'::.ctor + + .method public hidebysig instance void + 'b__0'() cil managed + { + // Code size 18 (0x12) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::'<>4__this' + IL_0006: ldarg.0 + IL_0007: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::a + IL_000c: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J::'<>n__FabricatedMethod3'(int32) + IL_0011: ret + } // end of method '<>c__DisplayClass1'::'b__0' + + } // end of class '<>c__DisplayClass1' + + .method famorassem hidebysig virtual instance void + Test(int32 a) cil managed + { + // Code size 65 (0x41) + .maxstack 2 + .locals init (class [mscorlib]System.Action V_0, + class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1' V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::.ctor() + IL_0005: stloc.1 + IL_0006: ldloc.1 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::a + IL_000d: ldloc.1 + IL_000e: ldarg.0 + IL_000f: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::'<>4__this' + IL_0014: ldloc.1 + IL_0015: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::'b__0'() + IL_001b: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0020: stloc.0 + IL_0021: ldloc.1 + IL_0022: ldflda int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass1'::a + IL_0027: ldc.i4.1 + IL_0028: call instance bool [mscorlib]System.Int32::Equals(int32) + IL_002d: brfalse.s IL_003a + + IL_002f: ldstr "roslyn optimize is inlining the assignment which l" + + "ets the test fail" + IL_0034: newobj instance void [mscorlib]System.Exception::.ctor(string) + IL_0039: throw + + IL_003a: ldloc.0 + IL_003b: callvirt instance void [mscorlib]System.Action::Invoke() + IL_0040: ret + } // end of method J::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I::.ctor() + IL_0006: ret + } // end of method J::.ctor + + .method private hidebysig instance void + '<>n__FabricatedMethod3'(int32 A_1) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I::Test(int32) + IL_0007: ret + } // end of method J::'<>n__FabricatedMethod3' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K + extends [mscorlib]System.Object +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements class [mscorlib]System.Collections.Generic.IEnumerable`1, + [mscorlib]System.Collections.IEnumerable, + class [mscorlib]System.Collections.Generic.IEnumerator`1, + [mscorlib]System.Collections.IEnumerator, + [mscorlib]System.IDisposable + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private int32 '<>2__current' + .field private int32 '<>1__state' + .field private int32 '<>l__initialThreadId' + .field public int32 p + .field public int32 '<>3__p' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K '<>4__this' + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.Generic.IEnumerator`1 + 'System.Collections.Generic.IEnumerable.GetEnumerator'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + // Code size 67 (0x43) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0' V_0) + IL_0000: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0005: ldarg.0 + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>l__initialThreadId' + IL_000b: bne.un.s IL_0022 + + IL_000d: ldarg.0 + IL_000e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0013: ldc.i4.s -2 + IL_0015: bne.un.s IL_0022 + + IL_0017: ldarg.0 + IL_0018: ldc.i4.0 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: stloc.0 + IL_0020: br.s IL_0035 + + IL_0022: ldc.i4.0 + IL_0023: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::.ctor(int32) + IL_0028: stloc.0 + IL_0029: ldloc.0 + IL_002a: ldarg.0 + IL_002b: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>4__this' + IL_0030: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>4__this' + IL_0035: ldloc.0 + IL_0036: ldarg.0 + IL_0037: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>3__p' + IL_003c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::p + IL_0041: ldloc.0 + IL_0042: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerable.GetEnumerator' + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.IEnumerator + System.Collections.IEnumerable.GetEnumerator() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerable::GetEnumerator + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'System.Collections.Generic.IEnumerable.GetEnumerator'() + IL_0006: ret + } // end of method 'd__0'::System.Collections.IEnumerable.GetEnumerator + + .method private hidebysig newslot virtual final + instance bool MoveNext() cil managed + { + .override [mscorlib]System.Collections.IEnumerator::MoveNext + // Code size 96 (0x60) + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: switch ( + IL_001b, + IL_0039, + IL_0057) + IL_0019: br.s IL_005e + + IL_001b: ldarg.0 + IL_001c: ldc.i4.m1 + IL_001d: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0022: ldarg.0 + IL_0023: ldarg.0 + IL_0024: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::p + IL_0029: ldc.i4.1 + IL_002a: add + IL_002b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0030: ldarg.0 + IL_0031: ldc.i4.1 + IL_0032: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0037: ldc.i4.1 + IL_0038: ret + + IL_0039: ldarg.0 + IL_003a: ldc.i4.m1 + IL_003b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0040: ldarg.0 + IL_0041: ldarg.0 + IL_0042: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::p + IL_0047: ldc.i4.2 + IL_0048: add + IL_0049: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_004e: ldarg.0 + IL_004f: ldc.i4.2 + IL_0050: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0055: ldc.i4.1 + IL_0056: ret + + IL_0057: ldarg.0 + IL_0058: ldc.i4.m1 + IL_0059: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_005e: ldc.i4.0 + IL_005f: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot specialname virtual final + instance int32 'System.Collections.Generic.IEnumerator.get_Current'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0006: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerator.get_Current' + + .method private hidebysig newslot virtual final + instance void System.Collections.IEnumerator.Reset() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::Reset + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0005: throw + } // end of method 'd__0'::System.Collections.IEnumerator.Reset + + .method private hidebysig newslot virtual final + instance void System.IDisposable.Dispose() cil managed + { + .override [mscorlib]System.IDisposable::Dispose + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method 'd__0'::System.IDisposable.Dispose + + .method private hidebysig newslot specialname virtual final + instance object System.Collections.IEnumerator.get_Current() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::get_Current + // Code size 12 (0xc) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0006: box [mscorlib]System.Int32 + IL_000b: ret + } // end of method 'd__0'::System.Collections.IEnumerator.get_Current + + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 '<>1__state') cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 25 (0x19) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_000d: ldarg.0 + IL_000e: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0013: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>l__initialThreadId' + IL_0018: ret + } // end of method 'd__0'::.ctor + + .property instance int32 'System.Collections.Generic.IEnumerator.Current'() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'System.Collections.Generic.IEnumerator.get_Current'() + } // end of property 'd__0'::'System.Collections.Generic.IEnumerator.Current' + .property instance object System.Collections.IEnumerator.Current() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::System.Collections.IEnumerator.get_Current() + } // end of property 'd__0'::System.Collections.IEnumerator.Current + } // end of class 'd__0' + + .method famorassem hidebysig newslot virtual + instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + Test(int32 p) cil managed + { + // Code size 24 (0x18) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0' V_0) + IL_0000: ldc.i4.s -2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::.ctor(int32) + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldarg.0 + IL_000a: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>4__this' + IL_000f: ldloc.0 + IL_0010: ldarg.1 + IL_0011: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>3__p' + IL_0016: ldloc.0 + IL_0017: ret + } // end of method K::Test + + .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 K::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements class [mscorlib]System.Collections.Generic.IEnumerable`1, + [mscorlib]System.Collections.IEnumerable, + class [mscorlib]System.Collections.Generic.IEnumerator`1, + [mscorlib]System.Collections.IEnumerator, + [mscorlib]System.IDisposable + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private int32 '<>2__current' + .field private int32 '<>1__state' + .field private int32 '<>l__initialThreadId' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L '<>4__this' + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.Generic.IEnumerator`1 + 'System.Collections.Generic.IEnumerable.GetEnumerator'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + // Code size 55 (0x37) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0' V_0) + IL_0000: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0005: ldarg.0 + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>l__initialThreadId' + IL_000b: bne.un.s IL_0022 + + IL_000d: ldarg.0 + IL_000e: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0013: ldc.i4.s -2 + IL_0015: bne.un.s IL_0022 + + IL_0017: ldarg.0 + IL_0018: ldc.i4.0 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: stloc.0 + IL_0020: br.s IL_0035 + + IL_0022: ldc.i4.0 + IL_0023: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::.ctor(int32) + IL_0028: stloc.0 + IL_0029: ldloc.0 + IL_002a: ldarg.0 + IL_002b: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_0030: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_0035: ldloc.0 + IL_0036: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerable.GetEnumerator' + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.IEnumerator + System.Collections.IEnumerable.GetEnumerator() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerable::GetEnumerator + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'System.Collections.Generic.IEnumerable.GetEnumerator'() + IL_0006: ret + } // end of method 'd__0'::System.Collections.IEnumerable.GetEnumerator + + .method private hidebysig newslot virtual final + instance bool MoveNext() cil managed + { + .override [mscorlib]System.Collections.IEnumerator::MoveNext + // Code size 97 (0x61) + .maxstack 4 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: switch ( + IL_0017, + IL_0058) + IL_0015: br.s IL_005f + + IL_0017: ldarg.0 + IL_0018: ldc.i4.m1 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: ldarg.0 + IL_0020: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_0025: ldarg.0 + IL_0026: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_002b: ldc.i4.0 + IL_002c: call instance class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L::'<>n__FabricatedMethod1'(int32) + IL_0031: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0036: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_003b: call instance class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L::'<>n__FabricatedMethod1'(int32) + IL_0040: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0045: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_004a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>2__current' + IL_004f: ldarg.0 + IL_0050: ldc.i4.1 + IL_0051: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0056: ldc.i4.1 + IL_0057: ret + + IL_0058: ldarg.0 + IL_0059: ldc.i4.m1 + IL_005a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_005f: ldc.i4.0 + IL_0060: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot specialname virtual final + instance int32 'System.Collections.Generic.IEnumerator.get_Current'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>2__current' + IL_0006: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerator.get_Current' + + .method private hidebysig newslot virtual final + instance void System.Collections.IEnumerator.Reset() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::Reset + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0005: throw + } // end of method 'd__0'::System.Collections.IEnumerator.Reset + + .method private hidebysig newslot virtual final + instance void System.IDisposable.Dispose() cil managed + { + .override [mscorlib]System.IDisposable::Dispose + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method 'd__0'::System.IDisposable.Dispose + + .method private hidebysig newslot specialname virtual final + instance object System.Collections.IEnumerator.get_Current() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::get_Current + // Code size 12 (0xc) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>2__current' + IL_0006: box [mscorlib]System.Int32 + IL_000b: ret + } // end of method 'd__0'::System.Collections.IEnumerator.get_Current + + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 '<>1__state') cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 25 (0x19) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_000d: ldarg.0 + IL_000e: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0013: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>l__initialThreadId' + IL_0018: ret + } // end of method 'd__0'::.ctor + + .property instance int32 'System.Collections.Generic.IEnumerator.Current'() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'System.Collections.Generic.IEnumerator.get_Current'() + } // end of property 'd__0'::'System.Collections.Generic.IEnumerator.Current' + .property instance object System.Collections.IEnumerator.Current() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::System.Collections.IEnumerator.get_Current() + } // end of property 'd__0'::System.Collections.IEnumerator.Current + } // end of class 'd__0' + + .method famorassem hidebysig virtual instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + Test(int32 p) cil managed + { + // Code size 17 (0x11) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0' V_0) + IL_0000: ldc.i4.s -2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::.ctor(int32) + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldarg.0 + IL_000a: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_000f: ldloc.0 + IL_0010: ret + } // end of method L::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K::.ctor() + IL_0006: ret + } // end of method L::.ctor + + .method private hidebysig instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + '<>n__FabricatedMethod1'(int32 A_1) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K::Test(int32) + IL_0007: ret + } // end of method L::'<>n__FabricatedMethod1' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** +// Warnung: Win32-Ressourcendatei "../../../TestCases/Pretty\FixProxyCalls.opt.res" wurde erstellt. diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.opt.roslyn.il new file mode 100644 index 000000000..d4c7d8f22 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.opt.roslyn.il @@ -0,0 +1,1294 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly FixProxyCalls +{ + .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 FixProxyCalls.dll +// MVID: {68453617-6425-4063-8DF9-B48E31C1B6A2} +.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: 0x00D00000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A + extends [mscorlib]System.Object +{ + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass0_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public string test + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass0_0'::.ctor + + .method assembly hidebysig instance string + 'b__0'() cil managed + { + // Code size 12 (0xc) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass0_0'::test + IL_0006: callvirt instance string [mscorlib]System.String::ToUpper() + IL_000b: ret + } // end of method '<>c__DisplayClass0_0'::'b__0' + + } // end of class '<>c__DisplayClass0_0' + + .method famorassem hidebysig newslot virtual + instance class [mscorlib]System.Threading.Tasks.Task`1 + Test(string test) cil managed + { + // Code size 29 (0x1d) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass0_0'::.ctor() + IL_0005: dup + IL_0006: ldarg.1 + IL_0007: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass0_0'::test + IL_000c: ldftn instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass0_0'::'b__0'() + IL_0012: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_0017: call class [mscorlib]System.Threading.Tasks.Task`1 [mscorlib]System.Threading.Tasks.Task::Run(class [mscorlib]System.Func`1) + IL_001c: ret + } // end of method A::Test + + .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 A::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.ValueType + implements [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 '<>1__state' + .field public valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 '<>t__builder' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B '<>4__this' + .field public string test + .field private valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 '<>u__1' + .method private hidebysig newslot virtual final + instance void MoveNext() cil managed + { + .override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext + // Code size 160 (0xa0) + .maxstack 3 + .locals init (int32 V_0, + class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B V_1, + string V_2, + valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 V_3, + class [mscorlib]System.Exception V_4) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0006: stloc.0 + IL_0007: ldarg.0 + IL_0008: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>4__this' + IL_000d: stloc.1 + .try + { + IL_000e: ldloc.0 + IL_000f: brfalse.s IL_004c + + IL_0011: ldloc.1 + IL_0012: ldarg.0 + IL_0013: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::test + IL_0018: call instance class [mscorlib]System.Threading.Tasks.Task`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B::'<>n__0'(string) + IL_001d: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 class [mscorlib]System.Threading.Tasks.Task`1::GetAwaiter() + IL_0022: stloc.3 + IL_0023: ldloca.s V_3 + IL_0025: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::get_IsCompleted() + IL_002a: brtrue.s IL_0068 + + IL_002c: ldarg.0 + IL_002d: ldc.i4.0 + IL_002e: dup + IL_002f: stloc.0 + IL_0030: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0035: ldarg.0 + IL_0036: ldloc.3 + IL_0037: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>u__1' + IL_003c: ldarg.0 + IL_003d: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_0042: ldloca.s V_3 + IL_0044: ldarg.0 + IL_0045: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::AwaitUnsafeOnCompleted,valuetype ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'>(!!0&, + !!1&) + IL_004a: leave.s IL_009f + + IL_004c: ldarg.0 + IL_004d: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>u__1' + IL_0052: stloc.3 + IL_0053: ldarg.0 + IL_0054: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>u__1' + IL_0059: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 + IL_005f: ldarg.0 + IL_0060: ldc.i4.m1 + IL_0061: dup + IL_0062: stloc.0 + IL_0063: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0068: ldloca.s V_3 + IL_006a: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::GetResult() + IL_006f: stloc.2 + IL_0070: leave.s IL_008b + + } // end .try + catch [mscorlib]System.Exception + { + IL_0072: stloc.s V_4 + IL_0074: ldarg.0 + IL_0075: ldc.i4.s -2 + IL_0077: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_007c: ldarg.0 + IL_007d: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_0082: ldloc.s V_4 + IL_0084: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetException(class [mscorlib]System.Exception) + IL_0089: leave.s IL_009f + + } // end handler + IL_008b: ldarg.0 + IL_008c: ldc.i4.s -2 + IL_008e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0093: ldarg.0 + IL_0094: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_0099: ldloc.2 + IL_009a: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetResult(!0) + IL_009f: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot virtual final + instance void SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine stateMachine) cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::SetStateMachine + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_0006: ldarg.1 + IL_0007: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine) + IL_000c: ret + } // end of method 'd__0'::SetStateMachine + + } // end of class 'd__0' + + .method famorassem hidebysig virtual instance class [mscorlib]System.Threading.Tasks.Task`1 + Test(string test) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.AsyncStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 3C 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..d__0. + 00 ) + // Code size 65 (0x41) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0' V_0, + valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 V_1) + IL_0000: ldloca.s V_0 + IL_0002: ldarg.0 + IL_0003: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>4__this' + IL_0008: ldloca.s V_0 + IL_000a: ldarg.1 + IL_000b: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::test + IL_0010: ldloca.s V_0 + IL_0012: call valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::Create() + IL_0017: stfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_001c: ldloca.s V_0 + IL_001e: ldc.i4.m1 + IL_001f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0024: ldloc.0 + IL_0025: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_002a: stloc.1 + IL_002b: ldloca.s V_1 + IL_002d: ldloca.s V_0 + IL_002f: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::Startd__0'>(!!0&) + IL_0034: ldloca.s V_0 + IL_0036: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_003b: call instance class [mscorlib]System.Threading.Tasks.Task`1 valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::get_Task() + IL_0040: ret + } // end of method B::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A::.ctor() + IL_0006: ret + } // end of method B::.ctor + + .method private hidebysig instance class [mscorlib]System.Threading.Tasks.Task`1 + '<>n__0'(string test) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance class [mscorlib]System.Threading.Tasks.Task`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A::Test(string) + IL_0007: ret + } // end of method B::'<>n__0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance string Test(string test) cil managed + { + // Code size 21 (0x15) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldc.i4.1 + IL_0002: newarr [mscorlib]System.String + IL_0007: dup + IL_0008: ldc.i4.0 + IL_0009: ldstr "fsdf" + IL_000e: stelem.ref + IL_000f: call string [mscorlib]System.String::Join(string, + string[]) + IL_0014: ret + } // end of method C::Test + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method C::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements class [mscorlib]System.Collections.Generic.IEnumerable`1, + [mscorlib]System.Collections.IEnumerable, + class [mscorlib]System.Collections.Generic.IEnumerator`1, + [mscorlib]System.IDisposable, + [mscorlib]System.Collections.IEnumerator + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private int32 '<>1__state' + .field private string '<>2__current' + .field private int32 '<>l__initialThreadId' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D '<>4__this' + .field private string test + .field public string '<>3__test' + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 '<>1__state') cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 25 (0x19) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_000d: ldarg.0 + IL_000e: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0013: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>l__initialThreadId' + IL_0018: ret + } // end of method 'd__0'::.ctor + + .method private hidebysig newslot virtual final + instance void System.IDisposable.Dispose() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.IDisposable::Dispose + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method 'd__0'::System.IDisposable.Dispose + + .method private hidebysig newslot virtual final + instance bool MoveNext() cil managed + { + .override [mscorlib]System.Collections.IEnumerator::MoveNext + // Code size 66 (0x42) + .maxstack 3 + .locals init (int32 V_0, + class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D V_1) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0006: stloc.0 + IL_0007: ldarg.0 + IL_0008: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_000d: stloc.1 + IL_000e: ldloc.0 + IL_000f: brfalse.s IL_0017 + + IL_0011: ldloc.0 + IL_0012: ldc.i4.1 + IL_0013: beq.s IL_0039 + + IL_0015: ldc.i4.0 + IL_0016: ret + + IL_0017: ldarg.0 + IL_0018: ldc.i4.m1 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: ldloc.1 + IL_0020: ldarg.0 + IL_0021: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::test + IL_0026: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D::'<>n__0'(string) + IL_002b: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>2__current' + IL_0030: ldarg.0 + IL_0031: ldc.i4.1 + IL_0032: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0037: ldc.i4.1 + IL_0038: ret + + IL_0039: ldarg.0 + IL_003a: ldc.i4.m1 + IL_003b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0040: ldc.i4.0 + IL_0041: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot specialname virtual final + instance string 'System.Collections.Generic.IEnumerator.get_Current'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>2__current' + IL_0006: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerator.get_Current' + + .method private hidebysig newslot virtual final + instance void System.Collections.IEnumerator.Reset() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::Reset + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0005: throw + } // end of method 'd__0'::System.Collections.IEnumerator.Reset + + .method private hidebysig newslot specialname virtual final + instance object System.Collections.IEnumerator.get_Current() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::get_Current + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>2__current' + IL_0006: ret + } // end of method 'd__0'::System.Collections.IEnumerator.get_Current + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.Generic.IEnumerator`1 + 'System.Collections.Generic.IEnumerable.GetEnumerator'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + // Code size 67 (0x43) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0' V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0006: ldc.i4.s -2 + IL_0008: bne.un.s IL_0022 + + IL_000a: ldarg.0 + IL_000b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>l__initialThreadId' + IL_0010: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0015: bne.un.s IL_0022 + + IL_0017: ldarg.0 + IL_0018: ldc.i4.0 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: stloc.0 + IL_0020: br.s IL_0035 + + IL_0022: ldc.i4.0 + IL_0023: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::.ctor(int32) + IL_0028: stloc.0 + IL_0029: ldloc.0 + IL_002a: ldarg.0 + IL_002b: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_0030: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_0035: ldloc.0 + IL_0036: ldarg.0 + IL_0037: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>3__test' + IL_003c: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::test + IL_0041: ldloc.0 + IL_0042: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerable.GetEnumerator' + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.IEnumerator + System.Collections.IEnumerable.GetEnumerator() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerable::GetEnumerator + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'System.Collections.Generic.IEnumerable.GetEnumerator'() + IL_0006: ret + } // end of method 'd__0'::System.Collections.IEnumerable.GetEnumerator + + .property instance string 'System.Collections.Generic.IEnumerator.Current'() + { + .get instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'System.Collections.Generic.IEnumerator.get_Current'() + } // end of property 'd__0'::'System.Collections.Generic.IEnumerator.Current' + .property instance object System.Collections.IEnumerator.Current() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::System.Collections.IEnumerator.get_Current() + } // end of property 'd__0'::System.Collections.IEnumerator.Current + } // end of class 'd__0' + + .method famorassem hidebysig instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + Test2(string test) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.IteratorStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 3D 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..=ICSharpCode.D + 65 63 6F 6D 70 69 6C 65 72 2E 54 65 73 74 73 2E // ecompiler.Tests. + 54 65 73 74 43 61 73 65 73 2E 49 4C 50 72 65 74 // TestCases.ILPret + 74 79 2E 44 2B 3C 54 65 73 74 32 3E 64 5F 5F 30 // ty.D+d__0 + 00 00 ) + // Code size 22 (0x16) + .maxstack 8 + IL_0000: ldc.i4.s -2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::.ctor(int32) + IL_0007: dup + IL_0008: ldarg.0 + IL_0009: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_000e: dup + IL_000f: ldarg.1 + IL_0010: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>3__test' + IL_0015: ret + } // end of method D::Test2 + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C::.ctor() + IL_0006: ret + } // end of method D::.ctor + + .method private hidebysig instance string + '<>n__0'(string test) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C::Test(string) + IL_0007: ret + } // end of method D::'<>n__0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance string Test(string test) cil managed + { + // Code size 21 (0x15) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldc.i4.1 + IL_0002: newarr [mscorlib]System.String + IL_0007: dup + IL_0008: ldc.i4.0 + IL_0009: ldstr "fsdf" + IL_000e: stelem.ref + IL_000f: call string [mscorlib]System.String::Join(string, + string[]) + IL_0014: ret + } // end of method E::Test + + .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 E::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E +{ + .method famorassem hidebysig virtual instance string + Test(string test) cil managed + { + // Code size 43 (0x2b) + .maxstack 5 + .locals init (class [mscorlib]System.Func`2 V_0) + IL_0000: ldarg.0 + IL_0001: ldftn instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F::'b__0_0'(string) + IL_0007: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_000c: stloc.0 + IL_000d: ldarg.1 + IL_000e: ldc.i4.1 + IL_000f: newarr [mscorlib]System.String + IL_0014: dup + IL_0015: ldc.i4.0 + IL_0016: ldstr "aa" + IL_001b: stelem.ref + IL_001c: call string [mscorlib]System.String::Join(string, + string[]) + IL_0021: starg.s test + IL_0023: ldloc.0 + IL_0024: ldarg.1 + IL_0025: callvirt instance !1 class [mscorlib]System.Func`2::Invoke(!0) + IL_002a: ret + } // end of method F::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E::.ctor() + IL_0006: ret + } // end of method F::.ctor + + .method private hidebysig instance string + 'b__0_0'(string a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E::Test(string) + IL_0007: ret + } // end of method F::'b__0_0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance void Test(string test) cil managed + { + // Code size 22 (0x16) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldc.i4.1 + IL_0002: newarr [mscorlib]System.String + IL_0007: dup + IL_0008: ldc.i4.0 + IL_0009: ldstr "fsdf" + IL_000e: stelem.ref + IL_000f: call string [mscorlib]System.String::Join(string, + string[]) + IL_0014: pop + IL_0015: ret + } // end of method G::Test + + .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 G::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G +{ + .method famorassem hidebysig virtual instance void + Test(string test) cil managed + { + // Code size 44 (0x2c) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H::'b__0_0'(string) + IL_0007: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_000c: ldarg.1 + IL_000d: ldc.i4.1 + IL_000e: box [mscorlib]System.Int32 + IL_0013: callvirt instance bool [mscorlib]System.Object::Equals(object) + IL_0018: brfalse.s IL_0025 + + IL_001a: ldstr "roslyn optimize is inlining the assignment which l" + + "ets the test fail" + IL_001f: newobj instance void [mscorlib]System.Exception::.ctor(string) + IL_0024: throw + + IL_0025: ldarg.1 + IL_0026: callvirt instance void class [mscorlib]System.Action`1::Invoke(!0) + IL_002b: ret + } // end of method H::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G::.ctor() + IL_0006: ret + } // end of method H::.ctor + + .method private hidebysig instance void + 'b__0_0'(string a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G::Test(string) + IL_0007: ret + } // end of method H::'b__0_0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance void Test(int32 a) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method I::Test + + .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 I::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I +{ + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass0_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 a + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J '<>4__this' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c__DisplayClass0_0'::.ctor + + .method assembly hidebysig instance void + 'b__0'() cil managed + { + // Code size 18 (0x12) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::'<>4__this' + IL_0006: ldarg.0 + IL_0007: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::a + IL_000c: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J::'<>n__0'(int32) + IL_0011: ret + } // end of method '<>c__DisplayClass0_0'::'b__0' + + } // end of class '<>c__DisplayClass0_0' + + .method famorassem hidebysig virtual instance void + Test(int32 a) cil managed + { + // Code size 63 (0x3f) + .maxstack 3 + .locals init (class [mscorlib]System.Action V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::.ctor() + IL_0005: dup + IL_0006: ldarg.0 + IL_0007: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::'<>4__this' + IL_000c: dup + IL_000d: ldarg.1 + IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::a + IL_0013: dup + IL_0014: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::'b__0'() + IL_001a: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_001f: stloc.0 + IL_0020: ldflda int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::a + IL_0025: ldc.i4.1 + IL_0026: call instance bool [mscorlib]System.Int32::Equals(int32) + IL_002b: brfalse.s IL_0038 + + IL_002d: ldstr "roslyn optimize is inlining the assignment which l" + + "ets the test fail" + IL_0032: newobj instance void [mscorlib]System.Exception::.ctor(string) + IL_0037: throw + + IL_0038: ldloc.0 + IL_0039: callvirt instance void [mscorlib]System.Action::Invoke() + IL_003e: ret + } // end of method J::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I::.ctor() + IL_0006: ret + } // end of method J::.ctor + + .method private hidebysig instance void + '<>n__0'(int32 a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I::Test(int32) + IL_0007: ret + } // end of method J::'<>n__0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K + extends [mscorlib]System.Object +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements class [mscorlib]System.Collections.Generic.IEnumerable`1, + [mscorlib]System.Collections.IEnumerable, + class [mscorlib]System.Collections.Generic.IEnumerator`1, + [mscorlib]System.IDisposable, + [mscorlib]System.Collections.IEnumerator + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private int32 '<>1__state' + .field private int32 '<>2__current' + .field private int32 '<>l__initialThreadId' + .field private int32 p + .field public int32 '<>3__p' + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 '<>1__state') cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 25 (0x19) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_000d: ldarg.0 + IL_000e: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0013: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>l__initialThreadId' + IL_0018: ret + } // end of method 'd__0'::.ctor + + .method private hidebysig newslot virtual final + instance void System.IDisposable.Dispose() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.IDisposable::Dispose + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method 'd__0'::System.IDisposable.Dispose + + .method private hidebysig newslot virtual final + instance bool MoveNext() cil managed + { + .override [mscorlib]System.Collections.IEnumerator::MoveNext + // Code size 96 (0x60) + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: switch ( + IL_001b, + IL_0039, + IL_0057) + IL_0019: ldc.i4.0 + IL_001a: ret + + IL_001b: ldarg.0 + IL_001c: ldc.i4.m1 + IL_001d: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0022: ldarg.0 + IL_0023: ldarg.0 + IL_0024: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::p + IL_0029: ldc.i4.1 + IL_002a: add + IL_002b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0030: ldarg.0 + IL_0031: ldc.i4.1 + IL_0032: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0037: ldc.i4.1 + IL_0038: ret + + IL_0039: ldarg.0 + IL_003a: ldc.i4.m1 + IL_003b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0040: ldarg.0 + IL_0041: ldarg.0 + IL_0042: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::p + IL_0047: ldc.i4.2 + IL_0048: add + IL_0049: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_004e: ldarg.0 + IL_004f: ldc.i4.2 + IL_0050: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0055: ldc.i4.1 + IL_0056: ret + + IL_0057: ldarg.0 + IL_0058: ldc.i4.m1 + IL_0059: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_005e: ldc.i4.0 + IL_005f: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot specialname virtual final + instance int32 'System.Collections.Generic.IEnumerator.get_Current'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0006: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerator.get_Current' + + .method private hidebysig newslot virtual final + instance void System.Collections.IEnumerator.Reset() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::Reset + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0005: throw + } // end of method 'd__0'::System.Collections.IEnumerator.Reset + + .method private hidebysig newslot specialname virtual final + instance object System.Collections.IEnumerator.get_Current() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::get_Current + // Code size 12 (0xc) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0006: box [mscorlib]System.Int32 + IL_000b: ret + } // end of method 'd__0'::System.Collections.IEnumerator.get_Current + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.Generic.IEnumerator`1 + 'System.Collections.Generic.IEnumerable.GetEnumerator'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + // Code size 55 (0x37) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0' V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0006: ldc.i4.s -2 + IL_0008: bne.un.s IL_0022 + + IL_000a: ldarg.0 + IL_000b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>l__initialThreadId' + IL_0010: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0015: bne.un.s IL_0022 + + IL_0017: ldarg.0 + IL_0018: ldc.i4.0 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: stloc.0 + IL_0020: br.s IL_0029 + + IL_0022: ldc.i4.0 + IL_0023: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::.ctor(int32) + IL_0028: stloc.0 + IL_0029: ldloc.0 + IL_002a: ldarg.0 + IL_002b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>3__p' + IL_0030: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::p + IL_0035: ldloc.0 + IL_0036: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerable.GetEnumerator' + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.IEnumerator + System.Collections.IEnumerable.GetEnumerator() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerable::GetEnumerator + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'System.Collections.Generic.IEnumerable.GetEnumerator'() + IL_0006: ret + } // end of method 'd__0'::System.Collections.IEnumerable.GetEnumerator + + .property instance int32 'System.Collections.Generic.IEnumerator.Current'() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'System.Collections.Generic.IEnumerator.get_Current'() + } // end of property 'd__0'::'System.Collections.Generic.IEnumerator.Current' + .property instance object System.Collections.IEnumerator.Current() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::System.Collections.IEnumerator.get_Current() + } // end of property 'd__0'::System.Collections.IEnumerator.Current + } // end of class 'd__0' + + .method famorassem hidebysig newslot virtual + instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + Test(int32 p) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.IteratorStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 3C 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..d__0. + 00 ) + // Code size 15 (0xf) + .maxstack 8 + IL_0000: ldc.i4.s -2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::.ctor(int32) + IL_0007: dup + IL_0008: ldarg.1 + IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>3__p' + IL_000e: ret + } // end of method K::Test + + .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 K::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements class [mscorlib]System.Collections.Generic.IEnumerable`1, + [mscorlib]System.Collections.IEnumerable, + class [mscorlib]System.Collections.Generic.IEnumerator`1, + [mscorlib]System.IDisposable, + [mscorlib]System.Collections.IEnumerator + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private int32 '<>1__state' + .field private int32 '<>2__current' + .field private int32 '<>l__initialThreadId' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L '<>4__this' + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 '<>1__state') cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 25 (0x19) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_000d: ldarg.0 + IL_000e: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0013: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>l__initialThreadId' + IL_0018: ret + } // end of method 'd__0'::.ctor + + .method private hidebysig newslot virtual final + instance void System.IDisposable.Dispose() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.IDisposable::Dispose + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method 'd__0'::System.IDisposable.Dispose + + .method private hidebysig newslot virtual final + instance bool MoveNext() cil managed + { + .override [mscorlib]System.Collections.IEnumerator::MoveNext + // Code size 87 (0x57) + .maxstack 4 + .locals init (int32 V_0, + class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L V_1) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0006: stloc.0 + IL_0007: ldarg.0 + IL_0008: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_000d: stloc.1 + IL_000e: ldloc.0 + IL_000f: brfalse.s IL_0017 + + IL_0011: ldloc.0 + IL_0012: ldc.i4.1 + IL_0013: beq.s IL_004e + + IL_0015: ldc.i4.0 + IL_0016: ret + + IL_0017: ldarg.0 + IL_0018: ldc.i4.m1 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: ldloc.1 + IL_0020: ldloc.1 + IL_0021: ldc.i4.0 + IL_0022: call instance class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L::'<>n__0'(int32) + IL_0027: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_002c: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0031: call instance class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L::'<>n__0'(int32) + IL_0036: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_003b: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0040: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>2__current' + IL_0045: ldarg.0 + IL_0046: ldc.i4.1 + IL_0047: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_004c: ldc.i4.1 + IL_004d: ret + + IL_004e: ldarg.0 + IL_004f: ldc.i4.m1 + IL_0050: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0055: ldc.i4.0 + IL_0056: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot specialname virtual final + instance int32 'System.Collections.Generic.IEnumerator.get_Current'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>2__current' + IL_0006: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerator.get_Current' + + .method private hidebysig newslot virtual final + instance void System.Collections.IEnumerator.Reset() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::Reset + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0005: throw + } // end of method 'd__0'::System.Collections.IEnumerator.Reset + + .method private hidebysig newslot specialname virtual final + instance object System.Collections.IEnumerator.get_Current() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::get_Current + // Code size 12 (0xc) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>2__current' + IL_0006: box [mscorlib]System.Int32 + IL_000b: ret + } // end of method 'd__0'::System.Collections.IEnumerator.get_Current + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.Generic.IEnumerator`1 + 'System.Collections.Generic.IEnumerable.GetEnumerator'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + // Code size 55 (0x37) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0' V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0006: ldc.i4.s -2 + IL_0008: bne.un.s IL_0022 + + IL_000a: ldarg.0 + IL_000b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>l__initialThreadId' + IL_0010: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0015: bne.un.s IL_0022 + + IL_0017: ldarg.0 + IL_0018: ldc.i4.0 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: stloc.0 + IL_0020: br.s IL_0035 + + IL_0022: ldc.i4.0 + IL_0023: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::.ctor(int32) + IL_0028: stloc.0 + IL_0029: ldloc.0 + IL_002a: ldarg.0 + IL_002b: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_0030: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_0035: ldloc.0 + IL_0036: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerable.GetEnumerator' + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.IEnumerator + System.Collections.IEnumerable.GetEnumerator() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerable::GetEnumerator + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'System.Collections.Generic.IEnumerable.GetEnumerator'() + IL_0006: ret + } // end of method 'd__0'::System.Collections.IEnumerable.GetEnumerator + + .property instance int32 'System.Collections.Generic.IEnumerator.Current'() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'System.Collections.Generic.IEnumerator.get_Current'() + } // end of property 'd__0'::'System.Collections.Generic.IEnumerator.Current' + .property instance object System.Collections.IEnumerator.Current() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::System.Collections.IEnumerator.get_Current() + } // end of property 'd__0'::System.Collections.IEnumerator.Current + } // end of class 'd__0' + + .method famorassem hidebysig virtual instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + Test(int32 p) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.IteratorStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 3C 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..d__0. + 00 ) + // Code size 15 (0xf) + .maxstack 8 + IL_0000: ldc.i4.s -2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::.ctor(int32) + IL_0007: dup + IL_0008: ldarg.0 + IL_0009: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_000e: ret + } // end of method L::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K::.ctor() + IL_0006: ret + } // end of method L::.ctor + + .method private hidebysig instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + '<>n__0'(int32 p) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K::Test(int32) + IL_0007: ret + } // end of method L::'<>n__0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.roslyn.il new file mode 100644 index 000000000..a902d0a07 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.roslyn.il @@ -0,0 +1,1424 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly FixProxyCalls +{ + .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 FixProxyCalls.dll +// MVID: {337B20CD-03F0-410E-9868-F4B4F95C9AEF} +.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: 0x00DC0000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A + extends [mscorlib]System.Object +{ + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass0_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public string test + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass0_0'::.ctor + + .method assembly hidebysig instance string + 'b__0'() cil managed + { + // Code size 12 (0xc) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass0_0'::test + IL_0006: callvirt instance string [mscorlib]System.String::ToUpper() + IL_000b: ret + } // end of method '<>c__DisplayClass0_0'::'b__0' + + } // end of class '<>c__DisplayClass0_0' + + .method famorassem hidebysig newslot virtual + instance class [mscorlib]System.Threading.Tasks.Task`1 + Test(string test) cil managed + { + // Code size 36 (0x24) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass0_0' V_0, + class [mscorlib]System.Threading.Tasks.Task`1 V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass0_0'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.1 + IL_0008: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass0_0'::test + IL_000d: nop + IL_000e: ldloc.0 + IL_000f: ldftn instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A/'<>c__DisplayClass0_0'::'b__0'() + IL_0015: newobj instance void class [mscorlib]System.Func`1::.ctor(object, + native int) + IL_001a: call class [mscorlib]System.Threading.Tasks.Task`1 [mscorlib]System.Threading.Tasks.Task::Run(class [mscorlib]System.Func`1) + IL_001f: stloc.1 + IL_0020: br.s IL_0022 + + IL_0022: ldloc.1 + IL_0023: ret + } // end of method A::Test + + .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 A::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 '<>1__state' + .field public valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 '<>t__builder' + .field public string test + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B '<>4__this' + .field private string '<>s__1' + .field private valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 '<>u__1' + .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 'd__0'::.ctor + + .method private hidebysig newslot virtual final + instance void MoveNext() cil managed + { + .override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext + // Code size 181 (0xb5) + .maxstack 3 + .locals init (int32 V_0, + string V_1, + valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 V_2, + class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0' V_3, + class [mscorlib]System.Exception V_4) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0006: stloc.0 + .try + { + IL_0007: ldloc.0 + IL_0008: brfalse.s IL_000c + + IL_000a: br.s IL_000e + + IL_000c: br.s IL_0053 + + IL_000e: nop + IL_000f: ldarg.0 + IL_0010: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>4__this' + IL_0015: ldarg.0 + IL_0016: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::test + IL_001b: call instance class [mscorlib]System.Threading.Tasks.Task`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B::'<>n__0'(string) + IL_0020: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 class [mscorlib]System.Threading.Tasks.Task`1::GetAwaiter() + IL_0025: stloc.2 + IL_0026: ldloca.s V_2 + IL_0028: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::get_IsCompleted() + IL_002d: brtrue.s IL_006f + + IL_002f: ldarg.0 + IL_0030: ldc.i4.0 + IL_0031: dup + IL_0032: stloc.0 + IL_0033: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0038: ldarg.0 + IL_0039: ldloc.2 + IL_003a: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>u__1' + IL_003f: ldarg.0 + IL_0040: stloc.3 + IL_0041: ldarg.0 + IL_0042: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_0047: ldloca.s V_2 + IL_0049: ldloca.s V_3 + IL_004b: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::AwaitUnsafeOnCompleted,class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'>(!!0&, + !!1&) + IL_0050: nop + IL_0051: leave.s IL_00b4 + + IL_0053: ldarg.0 + IL_0054: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>u__1' + IL_0059: stloc.2 + IL_005a: ldarg.0 + IL_005b: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>u__1' + IL_0060: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1 + IL_0066: ldarg.0 + IL_0067: ldc.i4.m1 + IL_0068: dup + IL_0069: stloc.0 + IL_006a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_006f: ldarg.0 + IL_0070: ldloca.s V_2 + IL_0072: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1::GetResult() + IL_0077: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>s__1' + IL_007c: ldarg.0 + IL_007d: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>s__1' + IL_0082: stloc.1 + IL_0083: leave.s IL_009f + + } // end .try + catch [mscorlib]System.Exception + { + IL_0085: stloc.s V_4 + IL_0087: ldarg.0 + IL_0088: ldc.i4.s -2 + IL_008a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_008f: ldarg.0 + IL_0090: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_0095: ldloc.s V_4 + IL_0097: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetException(class [mscorlib]System.Exception) + IL_009c: nop + IL_009d: leave.s IL_00b4 + + } // end handler + IL_009f: ldarg.0 + IL_00a0: ldc.i4.s -2 + IL_00a2: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_00a7: ldarg.0 + IL_00a8: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_00ad: ldloc.1 + IL_00ae: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetResult(!0) + IL_00b3: nop + IL_00b4: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot virtual final + instance void SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine stateMachine) cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::SetStateMachine + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method 'd__0'::SetStateMachine + + } // end of class 'd__0' + + .method famorassem hidebysig virtual instance class [mscorlib]System.Threading.Tasks.Task`1 + Test(string test) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.AsyncStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 3C 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..d__0. + 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerStepThroughAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 66 (0x42) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0' V_0, + valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 V_1) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>4__this' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::test + IL_0014: ldloc.0 + IL_0015: call valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::Create() + IL_001a: stfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_001f: ldloc.0 + IL_0020: ldc.i4.m1 + IL_0021: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>1__state' + IL_0026: ldloc.0 + IL_0027: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_002c: stloc.1 + IL_002d: ldloca.s V_1 + IL_002f: ldloca.s V_0 + IL_0031: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::Startd__0'>(!!0&) + IL_0036: ldloc.0 + IL_0037: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B/'d__0'::'<>t__builder' + IL_003c: call instance class [mscorlib]System.Threading.Tasks.Task`1 valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::get_Task() + IL_0041: ret + } // end of method B::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method B::.ctor + + .method private hidebysig instance class [mscorlib]System.Threading.Tasks.Task`1 + '<>n__0'(string test) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance class [mscorlib]System.Threading.Tasks.Task`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.A::Test(string) + IL_0007: ret + } // end of method B::'<>n__0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.B + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance string Test(string test) cil managed + { + // Code size 26 (0x1a) + .maxstack 5 + .locals init (string V_0) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldc.i4.1 + IL_0003: newarr [mscorlib]System.String + IL_0008: dup + IL_0009: ldc.i4.0 + IL_000a: ldstr "fsdf" + IL_000f: stelem.ref + IL_0010: call string [mscorlib]System.String::Join(string, + string[]) + IL_0015: stloc.0 + IL_0016: br.s IL_0018 + + IL_0018: ldloc.0 + IL_0019: ret + } // end of method C::Test + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method C::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements class [mscorlib]System.Collections.Generic.IEnumerable`1, + [mscorlib]System.Collections.IEnumerable, + class [mscorlib]System.Collections.Generic.IEnumerator`1, + [mscorlib]System.IDisposable, + [mscorlib]System.Collections.IEnumerator + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private int32 '<>1__state' + .field private string '<>2__current' + .field private int32 '<>l__initialThreadId' + .field private string test + .field public string '<>3__test' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D '<>4__this' + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 '<>1__state') cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 26 (0x1a) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ldarg.0 + IL_0008: ldarg.1 + IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_000e: ldarg.0 + IL_000f: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0014: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>l__initialThreadId' + IL_0019: ret + } // end of method 'd__0'::.ctor + + .method private hidebysig newslot virtual final + instance void System.IDisposable.Dispose() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.IDisposable::Dispose + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method 'd__0'::System.IDisposable.Dispose + + .method private hidebysig newslot virtual final + instance bool MoveNext() cil managed + { + .override [mscorlib]System.Collections.IEnumerator::MoveNext + // Code size 73 (0x49) + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: brfalse.s IL_0012 + + IL_000a: br.s IL_000c + + IL_000c: ldloc.0 + IL_000d: ldc.i4.1 + IL_000e: beq.s IL_0014 + + IL_0010: br.s IL_0016 + + IL_0012: br.s IL_0018 + + IL_0014: br.s IL_0040 + + IL_0016: ldc.i4.0 + IL_0017: ret + + IL_0018: ldarg.0 + IL_0019: ldc.i4.m1 + IL_001a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_001f: nop + IL_0020: ldarg.0 + IL_0021: ldarg.0 + IL_0022: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_0027: ldarg.0 + IL_0028: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::test + IL_002d: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D::'<>n__0'(string) + IL_0032: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>2__current' + IL_0037: ldarg.0 + IL_0038: ldc.i4.1 + IL_0039: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_003e: ldc.i4.1 + IL_003f: ret + + IL_0040: ldarg.0 + IL_0041: ldc.i4.m1 + IL_0042: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0047: ldc.i4.0 + IL_0048: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot specialname virtual final + instance string 'System.Collections.Generic.IEnumerator.get_Current'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>2__current' + IL_0006: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerator.get_Current' + + .method private hidebysig newslot virtual final + instance void System.Collections.IEnumerator.Reset() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::Reset + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0005: throw + } // end of method 'd__0'::System.Collections.IEnumerator.Reset + + .method private hidebysig newslot specialname virtual final + instance object System.Collections.IEnumerator.get_Current() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::get_Current + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>2__current' + IL_0006: ret + } // end of method 'd__0'::System.Collections.IEnumerator.get_Current + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.Generic.IEnumerator`1 + 'System.Collections.Generic.IEnumerable.GetEnumerator'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + // Code size 67 (0x43) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0' V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_0006: ldc.i4.s -2 + IL_0008: bne.un.s IL_0022 + + IL_000a: ldarg.0 + IL_000b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>l__initialThreadId' + IL_0010: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0015: bne.un.s IL_0022 + + IL_0017: ldarg.0 + IL_0018: ldc.i4.0 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: stloc.0 + IL_0020: br.s IL_0035 + + IL_0022: ldc.i4.0 + IL_0023: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::.ctor(int32) + IL_0028: stloc.0 + IL_0029: ldloc.0 + IL_002a: ldarg.0 + IL_002b: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_0030: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_0035: ldloc.0 + IL_0036: ldarg.0 + IL_0037: ldfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>3__test' + IL_003c: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::test + IL_0041: ldloc.0 + IL_0042: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerable.GetEnumerator' + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.IEnumerator + System.Collections.IEnumerable.GetEnumerator() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerable::GetEnumerator + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'System.Collections.Generic.IEnumerable.GetEnumerator'() + IL_0006: ret + } // end of method 'd__0'::System.Collections.IEnumerable.GetEnumerator + + .property instance string 'System.Collections.Generic.IEnumerator.Current'() + { + .get instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'System.Collections.Generic.IEnumerator.get_Current'() + } // end of property 'd__0'::'System.Collections.Generic.IEnumerator.Current' + .property instance object System.Collections.IEnumerator.Current() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::System.Collections.IEnumerator.get_Current() + } // end of property 'd__0'::System.Collections.IEnumerator.Current + } // end of class 'd__0' + + .method famorassem hidebysig instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + Test2(string test) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.IteratorStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 3D 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..=ICSharpCode.D + 65 63 6F 6D 70 69 6C 65 72 2E 54 65 73 74 73 2E // ecompiler.Tests. + 54 65 73 74 43 61 73 65 73 2E 49 4C 50 72 65 74 // TestCases.ILPret + 74 79 2E 44 2B 3C 54 65 73 74 32 3E 64 5F 5F 30 // ty.D+d__0 + 00 00 ) + // Code size 22 (0x16) + .maxstack 8 + IL_0000: ldc.i4.s -2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::.ctor(int32) + IL_0007: dup + IL_0008: ldarg.0 + IL_0009: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>4__this' + IL_000e: dup + IL_000f: ldarg.1 + IL_0010: stfld string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D/'d__0'::'<>3__test' + IL_0015: ret + } // end of method D::Test2 + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method D::.ctor + + .method private hidebysig instance string + '<>n__0'(string test) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.C::Test(string) + IL_0007: ret + } // end of method D::'<>n__0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.D + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance string Test(string test) cil managed + { + // Code size 26 (0x1a) + .maxstack 5 + .locals init (string V_0) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldc.i4.1 + IL_0003: newarr [mscorlib]System.String + IL_0008: dup + IL_0009: ldc.i4.0 + IL_000a: ldstr "fsdf" + IL_000f: stelem.ref + IL_0010: call string [mscorlib]System.String::Join(string, + string[]) + IL_0015: stloc.0 + IL_0016: br.s IL_0018 + + IL_0018: ldloc.0 + IL_0019: ret + } // end of method E::Test + + .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 E::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E +{ + .method famorassem hidebysig virtual instance string + Test(string test) cil managed + { + // Code size 48 (0x30) + .maxstack 5 + .locals init (class [mscorlib]System.Func`2 V_0, + string V_1) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldftn instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F::'b__0_0'(string) + IL_0008: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: ldarg.1 + IL_000f: ldc.i4.1 + IL_0010: newarr [mscorlib]System.String + IL_0015: dup + IL_0016: ldc.i4.0 + IL_0017: ldstr "aa" + IL_001c: stelem.ref + IL_001d: call string [mscorlib]System.String::Join(string, + string[]) + IL_0022: starg.s test + IL_0024: ldloc.0 + IL_0025: ldarg.1 + IL_0026: callvirt instance !1 class [mscorlib]System.Func`2::Invoke(!0) + IL_002b: stloc.1 + IL_002c: br.s IL_002e + + IL_002e: ldloc.1 + IL_002f: ret + } // end of method F::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method F::.ctor + + .method private hidebysig instance string + 'b__0_0'(string a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance string ICSharpCode.Decompiler.Tests.TestCases.ILPretty.E::Test(string) + IL_0007: ret + } // end of method F::'b__0_0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.F + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance void Test(string test) cil managed + { + // Code size 23 (0x17) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldc.i4.1 + IL_0003: newarr [mscorlib]System.String + IL_0008: dup + IL_0009: ldc.i4.0 + IL_000a: ldstr "fsdf" + IL_000f: stelem.ref + IL_0010: call string [mscorlib]System.String::Join(string, + string[]) + IL_0015: pop + IL_0016: ret + } // end of method G::Test + + .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 G::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G +{ + .method famorassem hidebysig virtual instance void + Test(string test) cil managed + { + // Code size 51 (0x33) + .maxstack 2 + .locals init (class [mscorlib]System.Action`1 V_0, + bool V_1) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H::'b__0_0'(string) + IL_0008: newobj instance void class [mscorlib]System.Action`1::.ctor(object, + native int) + IL_000d: stloc.0 + IL_000e: ldarg.1 + IL_000f: ldc.i4.1 + IL_0010: box [mscorlib]System.Int32 + IL_0015: callvirt instance bool [mscorlib]System.Object::Equals(object) + IL_001a: stloc.1 + IL_001b: ldloc.1 + IL_001c: brfalse.s IL_002a + + IL_001e: nop + IL_001f: ldstr "roslyn optimize is inlining the assignment which l" + + "ets the test fail" + IL_0024: newobj instance void [mscorlib]System.Exception::.ctor(string) + IL_0029: throw + + IL_002a: ldloc.0 + IL_002b: ldarg.1 + IL_002c: callvirt instance void class [mscorlib]System.Action`1::Invoke(!0) + IL_0031: nop + IL_0032: ret + } // end of method H::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method H::.ctor + + .method private hidebysig instance void + 'b__0_0'(string a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 10 (0xa) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.G::Test(string) + IL_0008: nop + IL_0009: ret + } // end of method H::'b__0_0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.H + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I + extends [mscorlib]System.Object +{ + .method famorassem hidebysig newslot virtual + instance void Test(int32 a) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method I::Test + + .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 I::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I +{ + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass0_0' + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 a + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J '<>4__this' + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c__DisplayClass0_0'::.ctor + + .method assembly hidebysig instance void + 'b__0'() cil managed + { + // Code size 20 (0x14) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::'<>4__this' + IL_0007: ldarg.0 + IL_0008: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::a + IL_000d: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J::'<>n__0'(int32) + IL_0012: nop + IL_0013: ret + } // end of method '<>c__DisplayClass0_0'::'b__0' + + } // end of class '<>c__DisplayClass0_0' + + .method famorassem hidebysig virtual instance void + Test(int32 a) cil managed + { + // Code size 70 (0x46) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0' V_0, + class [mscorlib]System.Action V_1, + bool V_2) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldarg.0 + IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::'<>4__this' + IL_000d: ldloc.0 + IL_000e: ldarg.1 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::a + IL_0014: nop + IL_0015: ldloc.0 + IL_0016: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::'b__0'() + IL_001c: newobj instance void [mscorlib]System.Action::.ctor(object, + native int) + IL_0021: stloc.1 + IL_0022: ldloc.0 + IL_0023: ldflda int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J/'<>c__DisplayClass0_0'::a + IL_0028: ldc.i4.1 + IL_0029: call instance bool [mscorlib]System.Int32::Equals(int32) + IL_002e: stloc.2 + IL_002f: ldloc.2 + IL_0030: brfalse.s IL_003e + + IL_0032: nop + IL_0033: ldstr "roslyn optimize is inlining the assignment which l" + + "ets the test fail" + IL_0038: newobj instance void [mscorlib]System.Exception::.ctor(string) + IL_003d: throw + + IL_003e: ldloc.1 + IL_003f: callvirt instance void [mscorlib]System.Action::Invoke() + IL_0044: nop + IL_0045: ret + } // end of method J::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method J::.ctor + + .method private hidebysig instance void + '<>n__0'(int32 a) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.I::Test(int32) + IL_0007: ret + } // end of method J::'<>n__0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.J + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K + extends [mscorlib]System.Object +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements class [mscorlib]System.Collections.Generic.IEnumerable`1, + [mscorlib]System.Collections.IEnumerable, + class [mscorlib]System.Collections.Generic.IEnumerator`1, + [mscorlib]System.IDisposable, + [mscorlib]System.Collections.IEnumerator + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private int32 '<>1__state' + .field private int32 '<>2__current' + .field private int32 '<>l__initialThreadId' + .field private int32 p + .field public int32 '<>3__p' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K '<>4__this' + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 '<>1__state') cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 26 (0x1a) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ldarg.0 + IL_0008: ldarg.1 + IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_000e: ldarg.0 + IL_000f: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0014: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>l__initialThreadId' + IL_0019: ret + } // end of method 'd__0'::.ctor + + .method private hidebysig newslot virtual final + instance void System.IDisposable.Dispose() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.IDisposable::Dispose + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method 'd__0'::System.IDisposable.Dispose + + .method private hidebysig newslot virtual final + instance bool MoveNext() cil managed + { + .override [mscorlib]System.Collections.IEnumerator::MoveNext + // Code size 105 (0x69) + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: switch ( + IL_001b, + IL_001d, + IL_001f) + IL_0019: br.s IL_0021 + + IL_001b: br.s IL_0023 + + IL_001d: br.s IL_0042 + + IL_001f: br.s IL_0060 + + IL_0021: ldc.i4.0 + IL_0022: ret + + IL_0023: ldarg.0 + IL_0024: ldc.i4.m1 + IL_0025: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_002a: nop + IL_002b: ldarg.0 + IL_002c: ldarg.0 + IL_002d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::p + IL_0032: ldc.i4.1 + IL_0033: add + IL_0034: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0039: ldarg.0 + IL_003a: ldc.i4.1 + IL_003b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0040: ldc.i4.1 + IL_0041: ret + + IL_0042: ldarg.0 + IL_0043: ldc.i4.m1 + IL_0044: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0049: ldarg.0 + IL_004a: ldarg.0 + IL_004b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::p + IL_0050: ldc.i4.2 + IL_0051: add + IL_0052: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0057: ldarg.0 + IL_0058: ldc.i4.2 + IL_0059: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_005e: ldc.i4.1 + IL_005f: ret + + IL_0060: ldarg.0 + IL_0061: ldc.i4.m1 + IL_0062: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0067: ldc.i4.0 + IL_0068: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot specialname virtual final + instance int32 'System.Collections.Generic.IEnumerator.get_Current'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0006: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerator.get_Current' + + .method private hidebysig newslot virtual final + instance void System.Collections.IEnumerator.Reset() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::Reset + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0005: throw + } // end of method 'd__0'::System.Collections.IEnumerator.Reset + + .method private hidebysig newslot specialname virtual final + instance object System.Collections.IEnumerator.get_Current() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::get_Current + // Code size 12 (0xc) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>2__current' + IL_0006: box [mscorlib]System.Int32 + IL_000b: ret + } // end of method 'd__0'::System.Collections.IEnumerator.get_Current + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.Generic.IEnumerator`1 + 'System.Collections.Generic.IEnumerable.GetEnumerator'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + // Code size 67 (0x43) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0' V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_0006: ldc.i4.s -2 + IL_0008: bne.un.s IL_0022 + + IL_000a: ldarg.0 + IL_000b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>l__initialThreadId' + IL_0010: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0015: bne.un.s IL_0022 + + IL_0017: ldarg.0 + IL_0018: ldc.i4.0 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: stloc.0 + IL_0020: br.s IL_0035 + + IL_0022: ldc.i4.0 + IL_0023: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::.ctor(int32) + IL_0028: stloc.0 + IL_0029: ldloc.0 + IL_002a: ldarg.0 + IL_002b: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>4__this' + IL_0030: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>4__this' + IL_0035: ldloc.0 + IL_0036: ldarg.0 + IL_0037: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>3__p' + IL_003c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::p + IL_0041: ldloc.0 + IL_0042: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerable.GetEnumerator' + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.IEnumerator + System.Collections.IEnumerable.GetEnumerator() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerable::GetEnumerator + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'System.Collections.Generic.IEnumerable.GetEnumerator'() + IL_0006: ret + } // end of method 'd__0'::System.Collections.IEnumerable.GetEnumerator + + .property instance int32 'System.Collections.Generic.IEnumerator.Current'() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'System.Collections.Generic.IEnumerator.get_Current'() + } // end of property 'd__0'::'System.Collections.Generic.IEnumerator.Current' + .property instance object System.Collections.IEnumerator.Current() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::System.Collections.IEnumerator.get_Current() + } // end of property 'd__0'::System.Collections.IEnumerator.Current + } // end of class 'd__0' + + .method famorassem hidebysig newslot virtual + instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + Test(int32 p) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.IteratorStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 3C 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..d__0. + 00 ) + // Code size 22 (0x16) + .maxstack 8 + IL_0000: ldc.i4.s -2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::.ctor(int32) + IL_0007: dup + IL_0008: ldarg.0 + IL_0009: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>4__this' + IL_000e: dup + IL_000f: ldarg.1 + IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K/'d__0'::'<>3__p' + IL_0015: ret + } // end of method K::Test + + .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 K::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K + +.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L + extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K +{ + .class auto ansi sealed nested private beforefieldinit 'd__0' + extends [mscorlib]System.Object + implements class [mscorlib]System.Collections.Generic.IEnumerable`1, + [mscorlib]System.Collections.IEnumerable, + class [mscorlib]System.Collections.Generic.IEnumerator`1, + [mscorlib]System.IDisposable, + [mscorlib]System.Collections.IEnumerator + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private int32 '<>1__state' + .field private int32 '<>2__current' + .field private int32 '<>l__initialThreadId' + .field private int32 p + .field public int32 '<>3__p' + .field public class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L '<>4__this' + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 '<>1__state') cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 26 (0x1a) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ldarg.0 + IL_0008: ldarg.1 + IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_000e: ldarg.0 + IL_000f: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0014: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>l__initialThreadId' + IL_0019: ret + } // end of method 'd__0'::.ctor + + .method private hidebysig newslot virtual final + instance void System.IDisposable.Dispose() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.IDisposable::Dispose + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method 'd__0'::System.IDisposable.Dispose + + .method private hidebysig newslot virtual final + instance bool MoveNext() cil managed + { + .override [mscorlib]System.Collections.IEnumerator::MoveNext + // Code size 99 (0x63) + .maxstack 4 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: brfalse.s IL_0012 + + IL_000a: br.s IL_000c + + IL_000c: ldloc.0 + IL_000d: ldc.i4.1 + IL_000e: beq.s IL_0014 + + IL_0010: br.s IL_0016 + + IL_0012: br.s IL_0018 + + IL_0014: br.s IL_005a + + IL_0016: ldc.i4.0 + IL_0017: ret + + IL_0018: ldarg.0 + IL_0019: ldc.i4.m1 + IL_001a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_001f: nop + IL_0020: ldarg.0 + IL_0021: ldarg.0 + IL_0022: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_0027: ldarg.0 + IL_0028: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_002d: ldc.i4.0 + IL_002e: call instance class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L::'<>n__0'(int32) + IL_0033: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0038: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_003d: call instance class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L::'<>n__0'(int32) + IL_0042: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0047: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_004c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>2__current' + IL_0051: ldarg.0 + IL_0052: ldc.i4.1 + IL_0053: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0058: ldc.i4.1 + IL_0059: ret + + IL_005a: ldarg.0 + IL_005b: ldc.i4.m1 + IL_005c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0061: ldc.i4.0 + IL_0062: ret + } // end of method 'd__0'::MoveNext + + .method private hidebysig newslot specialname virtual final + instance int32 'System.Collections.Generic.IEnumerator.get_Current'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>2__current' + IL_0006: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerator.get_Current' + + .method private hidebysig newslot virtual final + instance void System.Collections.IEnumerator.Reset() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::Reset + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0005: throw + } // end of method 'd__0'::System.Collections.IEnumerator.Reset + + .method private hidebysig newslot specialname virtual final + instance object System.Collections.IEnumerator.get_Current() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerator::get_Current + // Code size 12 (0xc) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>2__current' + IL_0006: box [mscorlib]System.Int32 + IL_000b: ret + } // end of method 'd__0'::System.Collections.IEnumerator.get_Current + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.Generic.IEnumerator`1 + 'System.Collections.Generic.IEnumerable.GetEnumerator'() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + // Code size 67 (0x43) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0' V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_0006: ldc.i4.s -2 + IL_0008: bne.un.s IL_0022 + + IL_000a: ldarg.0 + IL_000b: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>l__initialThreadId' + IL_0010: call int32 [mscorlib]System.Environment::get_CurrentManagedThreadId() + IL_0015: bne.un.s IL_0022 + + IL_0017: ldarg.0 + IL_0018: ldc.i4.0 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>1__state' + IL_001e: ldarg.0 + IL_001f: stloc.0 + IL_0020: br.s IL_0035 + + IL_0022: ldc.i4.0 + IL_0023: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::.ctor(int32) + IL_0028: stloc.0 + IL_0029: ldloc.0 + IL_002a: ldarg.0 + IL_002b: ldfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_0030: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_0035: ldloc.0 + IL_0036: ldarg.0 + IL_0037: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>3__p' + IL_003c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::p + IL_0041: ldloc.0 + IL_0042: ret + } // end of method 'd__0'::'System.Collections.Generic.IEnumerable.GetEnumerator' + + .method private hidebysig newslot virtual final + instance class [mscorlib]System.Collections.IEnumerator + System.Collections.IEnumerable.GetEnumerator() cil managed + { + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + .override [mscorlib]System.Collections.IEnumerable::GetEnumerator + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'System.Collections.Generic.IEnumerable.GetEnumerator'() + IL_0006: ret + } // end of method 'd__0'::System.Collections.IEnumerable.GetEnumerator + + .property instance int32 'System.Collections.Generic.IEnumerator.Current'() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'System.Collections.Generic.IEnumerator.get_Current'() + } // end of property 'd__0'::'System.Collections.Generic.IEnumerator.Current' + .property instance object System.Collections.IEnumerator.Current() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::System.Collections.IEnumerator.get_Current() + } // end of property 'd__0'::System.Collections.IEnumerator.Current + } // end of class 'd__0' + + .method famorassem hidebysig virtual instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + Test(int32 p) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.IteratorStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 3C 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..d__0. + 00 ) + // Code size 22 (0x16) + .maxstack 8 + IL_0000: ldc.i4.s -2 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::.ctor(int32) + IL_0007: dup + IL_0008: ldarg.0 + IL_0009: stfld class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>4__this' + IL_000e: dup + IL_000f: ldarg.1 + IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L/'d__0'::'<>3__p' + IL_0015: ret + } // end of method L::Test + + .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 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method L::.ctor + + .method private hidebysig instance class [mscorlib]System.Collections.Generic.IEnumerable`1 + '<>n__0'(int32 p) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.K::Test(int32) + IL_0007: ret + } // end of method L::'<>n__0' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.L + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs new file mode 100644 index 000000000..e272fcd9c --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs @@ -0,0 +1,484 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading; + +namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty +{ + public class InitializerTests + { + #region Types and helpers + public class C + { + public int Z; + public S Y; + public List L; + } + + public struct S + { + public int A; + public int B; + + public S(int a) + { + this.A = a; + this.B = 0; + } + } + + private enum MyEnum + { + a = 0, + b = 1 + } + + private enum MyEnum2 + { + c = 0, + d = 1 + } + + private class Data + { + public List FieldList = new List(); + public MyEnum a { + get; + set; + } + public MyEnum b { + get; + set; + } + public List PropertyList { + get; + set; + } + + public Data MoreData { + get; + set; + } + + public StructData NestedStruct { + get; + set; + } + + public Data this[int i] { + get { + return null; + } + set { + } + } + + public Data this[int i, string j] { + get { + return null; + } + set { + } + } + + public event EventHandler TestEvent; + } + + private struct StructData + { + public int Field; + public int Property { + get; + set; + } + + public Data MoreData { + get; + set; + } + + public StructData(int initialValue) + { + this = default(StructData); + this.Field = initialValue; + this.Property = initialValue; + } + } + + // Helper methods used to ensure initializers used within expressions work correctly + private static void X(object a, object b) + { + } + + private static object Y() + { + return null; + } + + public static void TestCall(int a, Thread thread) + { + + } + + public static C TestCall(int a, C c) + { + return c; + } + #endregion + + public C Test1() + { + C c = new C(); + c.L = new List(); + c.L.Add(new S(1)); + return c; + } + + public C Test1Alternative() + { + return InitializerTests.TestCall(1, new C { + L = new List { + new S(1) + } + }); + } + + public C Test2() + { + C c = new C(); + c.Z = 1; + c.Z = 2; + return c; + } + + public C Test3() + { + C c = new C(); + c.Y = new S(1); + c.Y.A = 2; + return c; + } + + public C Test3b() + { + return InitializerTests.TestCall(0, new C { + Z = 1, + Y = { + A = 2 + } + }); + } + + public C Test4() + { + C c = new C(); + c.Y.A = 1; + c.Z = 2; + c.Y.B = 3; + return c; + } + + + public static void CollectionInitializerList() + { + InitializerTests.X(InitializerTests.Y(), new List { + 1, + 2, + 3 + }); + } + + public static object RecursiveCollectionInitializer() + { + List list = new List(); + list.Add(list); + return list; + } + + public static void CollectionInitializerDictionary() + { + InitializerTests.X(InitializerTests.Y(), new Dictionary { + { + "First", + 1 + }, + { + "Second", + 2 + }, + { + "Third", + 3 + } + }); + } + + public static void CollectionInitializerDictionaryWithEnumTypes() + { + InitializerTests.X(InitializerTests.Y(), new Dictionary { + { + MyEnum.a, + MyEnum2.c + }, + { + MyEnum.b, + MyEnum2.d + } + }); + } + + public static void NotACollectionInitializer() + { + List list = new List(); + list.Add(1); + list.Add(2); + list.Add(3); + InitializerTests.X(InitializerTests.Y(), list); + } + + public static void ObjectInitializer() + { + InitializerTests.X(InitializerTests.Y(), new Data { + a = MyEnum.a + }); + } + + public static void NotAnObjectInitializer() + { + Data data = new Data(); + data.a = MyEnum.a; + InitializerTests.X(InitializerTests.Y(), data); + } + + public static void NotAnObjectInitializerWithEvent() + { + Data data = new Data(); + data.TestEvent += delegate(object sender, EventArgs e) { + Console.WriteLine(); + }; + InitializerTests.X(InitializerTests.Y(), data); + } + + public static void ObjectInitializerAssignCollectionToField() + { + InitializerTests.X(InitializerTests.Y(), new Data { + a = MyEnum.a, + FieldList = new List { + MyEnum2.c, + MyEnum2.d + } + }); + } + + public static void ObjectInitializerAddToCollectionInField() + { + InitializerTests.X(InitializerTests.Y(), new Data { + a = MyEnum.a, + FieldList = { + MyEnum2.c, + MyEnum2.d + } + }); + } + + public static void ObjectInitializerAssignCollectionToProperty() + { + InitializerTests.X(InitializerTests.Y(), new Data { + a = MyEnum.a, + PropertyList = new List { + MyEnum2.c, + MyEnum2.d + } + }); + } + + public static void ObjectInitializerAddToCollectionInProperty() + { + InitializerTests.X(InitializerTests.Y(), new Data { + a = MyEnum.a, + PropertyList = { + MyEnum2.c, + MyEnum2.d + } + }); + } + + public static void ObjectInitializerWithInitializationOfNestedObjects() + { + InitializerTests.X(InitializerTests.Y(), new Data { + MoreData = { + a = MyEnum.a, + MoreData = { + a = MyEnum.b + } + } + }); + } + + private static int GetInt() + { + return 1; + } + + private static string GetString() + { + return "Test"; + } + +#if !LEGACY_CSC + public static void SimpleDictInitializer() + { + InitializerTests.X(InitializerTests.Y(), new Data { + MoreData = { + a = MyEnum.a, + [2] = null + } + }); + } + + public static void MixedObjectAndDictInitializer() + { + InitializerTests.X(InitializerTests.Y(), new Data { + MoreData = { + a = MyEnum.a, + [InitializerTests.GetInt()] = { + a = MyEnum.b, + FieldList = { + MyEnum2.c + }, + [InitializerTests.GetInt(), InitializerTests.GetString()] = new Data(), + [2] = null + } + } + }); + } +#endif + + public static void ObjectInitializerWithInitializationOfDeeplyNestedObjects() + { + InitializerTests.X(InitializerTests.Y(), new Data { + a = MyEnum.b, + MoreData = { + a = MyEnum.a, + MoreData = { + MoreData = { + MoreData = { + MoreData = { + MoreData = { + MoreData = { + a = MyEnum.b + } + } + } + } + } + } + } + }); + } + + public static void CollectionInitializerInsideObjectInitializers() + { + InitializerTests.X(InitializerTests.Y(), new Data { + MoreData = new Data { + a = MyEnum.a, + b = MyEnum.b, + PropertyList = { + MyEnum2.c + } + } + }); + } + + public static void NotAStructInitializer_DefaultConstructor() + { + StructData structData = default(StructData); + structData.Field = 1; + structData.Property = 2; + InitializerTests.X(InitializerTests.Y(), structData); + } + + public static void StructInitializer_DefaultConstructor() + { + InitializerTests.X(InitializerTests.Y(), new StructData { + Field = 1, + Property = 2 + }); + } + + public static void NotAStructInitializer_ExplicitConstructor() + { + StructData structData = new StructData(0); + structData.Field = 1; + structData.Property = 2; + InitializerTests.X(InitializerTests.Y(), structData); + } + + public static void StructInitializer_ExplicitConstructor() + { + InitializerTests.X(InitializerTests.Y(), new StructData(0) { + Field = 1, + Property = 2 + }); + } + + public static void StructInitializerWithInitializationOfNestedObjects() + { + InitializerTests.X(InitializerTests.Y(), new StructData { + MoreData = { + a = MyEnum.a, + FieldList = { + MyEnum2.c, + MyEnum2.d + } + } + }); + } + + public static void StructInitializerWithinObjectInitializer() + { + InitializerTests.X(InitializerTests.Y(), new Data { + NestedStruct = new StructData(2) { + Field = 1, + Property = 2 + } + }); + } + + public static void Bug270_NestedInitialisers() + { + NumberFormatInfo[] source = null; + + InitializerTests.TestCall(0, new Thread(InitializerTests.Bug270_NestedInitialisers) { + Priority = ThreadPriority.BelowNormal, + CurrentCulture = new CultureInfo(0) { + DateTimeFormat = new DateTimeFormatInfo { + ShortDatePattern = "ddmmyy" + }, + NumberFormat = (from format in source + where format.CurrencySymbol == "$" + select format).First() + } + }); + } + } +} \ No newline at end of file diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il new file mode 100644 index 000000000..04af92cf4 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.il @@ -0,0 +1,1522 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly extern System.Core +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly n0iwoj0v +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module n0iwoj0v.dll +// MVID: {04AC1961-FA71-4E8B-A77B-45FF217A617C} +.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 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests + extends [mscorlib]System.Object +{ + .class auto ansi nested public beforefieldinit C + extends [mscorlib]System.Object + { + .field public int32 Z + .field public valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S Y + .field public class [mscorlib]System.Collections.Generic.List`1 L + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method C::.ctor + + } // end of class C + + .class sequential ansi sealed nested public beforefieldinit S + extends [mscorlib]System.ValueType + { + .field public int32 A + .field public int32 B + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 a) cil managed + { + // Code size 16 (0x10) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_0008: ldarg.0 + IL_0009: ldc.i4.0 + IL_000a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B + IL_000f: ret + } // end of method S::.ctor + + } // end of class S + + .class auto ansi sealed nested private MyEnum + extends [mscorlib]System.Enum + { + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum a = int32(0x00000000) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum b = int32(0x00000001) + } // end of class MyEnum + + .class auto ansi sealed nested private MyEnum2 + extends [mscorlib]System.Enum + { + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum2 c = int32(0x00000000) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum2 d = int32(0x00000001) + } // end of class MyEnum2 + + .class auto ansi nested private beforefieldinit Data + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Reflection.DefaultMemberAttribute::.ctor(string) = ( 01 00 04 49 74 65 6D 00 00 ) // ...Item.. + .field public class [mscorlib]System.Collections.Generic.List`1 FieldList + .field private class [mscorlib]System.EventHandler TestEvent + .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private class [mscorlib]System.Collections.Generic.List`1 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method public hidebysig specialname + instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + get_a() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 11 (0xb) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum V_0) + IL_0000: ldarg.0 + IL_0001: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method Data::get_a + + .method public hidebysig specialname + instance void set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_a + + .method public hidebysig specialname + instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + get_b() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 11 (0xb) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum V_0) + IL_0000: ldarg.0 + IL_0001: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method Data::get_b + + .method public hidebysig specialname + instance void set_b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_b + + .method public hidebysig specialname + instance class [mscorlib]System.Collections.Generic.List`1 + get_PropertyList() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 11 (0xb) + .maxstack 1 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method Data::get_PropertyList + + .method public hidebysig specialname + instance void set_PropertyList(class [mscorlib]System.Collections.Generic.List`1 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_PropertyList + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_MoreData() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 11 (0xb) + .maxstack 1 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method Data::get_MoreData + + .method public hidebysig specialname + instance void set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_MoreData + + .method public hidebysig specialname + instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + get_NestedStruct() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 11 (0xb) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: ldarg.0 + IL_0001: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method Data::get_NestedStruct + + .method public hidebysig specialname + instance void set_NestedStruct(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_NestedStruct + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_Item(int32 i) cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method Data::get_Item + + .method public hidebysig specialname + instance void set_Item(int32 i, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method Data::set_Item + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_Item(int32 i, + string j) cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method Data::get_Item + + .method public hidebysig specialname + instance void set_Item(int32 i, + string j, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method Data::set_Item + + .method public hidebysig specialname + instance void add_TestEvent(class [mscorlib]System.EventHandler 'value') cil managed + { + // Code size 48 (0x30) + .maxstack 3 + .locals init (class [mscorlib]System.EventHandler V_0, + class [mscorlib]System.EventHandler V_1, + class [mscorlib]System.EventHandler V_2, + bool V_3) + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: ldarg.1 + IL_000b: call class [mscorlib]System.Delegate [mscorlib]System.Delegate::Combine(class [mscorlib]System.Delegate, + class [mscorlib]System.Delegate) + IL_0010: castclass [mscorlib]System.EventHandler + IL_0015: stloc.2 + IL_0016: ldarg.0 + IL_0017: ldflda class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_001c: ldloc.2 + IL_001d: ldloc.1 + IL_001e: call !!0 [mscorlib]System.Threading.Interlocked::CompareExchange(!!0&, + !!0, + !!0) + IL_0023: stloc.0 + IL_0024: ldloc.0 + IL_0025: ldloc.1 + IL_0026: ceq + IL_0028: ldc.i4.0 + IL_0029: ceq + IL_002b: stloc.3 + IL_002c: ldloc.3 + IL_002d: brtrue.s IL_0007 + + IL_002f: ret + } // end of method Data::add_TestEvent + + .method public hidebysig specialname + instance void remove_TestEvent(class [mscorlib]System.EventHandler 'value') cil managed + { + // Code size 48 (0x30) + .maxstack 3 + .locals init (class [mscorlib]System.EventHandler V_0, + class [mscorlib]System.EventHandler V_1, + class [mscorlib]System.EventHandler V_2, + bool V_3) + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: ldarg.1 + IL_000b: call class [mscorlib]System.Delegate [mscorlib]System.Delegate::Remove(class [mscorlib]System.Delegate, + class [mscorlib]System.Delegate) + IL_0010: castclass [mscorlib]System.EventHandler + IL_0015: stloc.2 + IL_0016: ldarg.0 + IL_0017: ldflda class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_001c: ldloc.2 + IL_001d: ldloc.1 + IL_001e: call !!0 [mscorlib]System.Threading.Interlocked::CompareExchange(!!0&, + !!0, + !!0) + IL_0023: stloc.0 + IL_0024: ldloc.0 + IL_0025: ldloc.1 + IL_0026: ceq + IL_0028: ldc.i4.0 + IL_0029: ceq + IL_002b: stloc.3 + IL_002c: ldloc.3 + IL_002d: brtrue.s IL_0007 + + IL_002f: ret + } // end of method Data::remove_TestEvent + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 19 (0x13) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0006: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_000b: ldarg.0 + IL_000c: call instance void [mscorlib]System.Object::.ctor() + IL_0011: nop + IL_0012: ret + } // end of method Data::.ctor + + .event [mscorlib]System.EventHandler TestEvent + { + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::remove_TestEvent(class [mscorlib]System.EventHandler) + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::add_TestEvent(class [mscorlib]System.EventHandler) + } // end of event Data::TestEvent + .property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + a() + { + .get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_a() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + } // end of property Data::a + .property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + b() + { + .get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_b() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + } // end of property Data::b + .property instance class [mscorlib]System.Collections.Generic.List`1 + PropertyList() + { + .get instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_PropertyList(class [mscorlib]System.Collections.Generic.List`1) + } // end of property Data::PropertyList + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + MoreData() + { + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + } // end of property Data::MoreData + .property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + NestedStruct() + { + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_NestedStruct(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData) + .get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_NestedStruct() + } // end of property Data::NestedStruct + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + Item(int32) + { + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32) + } // end of property Data::Item + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + Item(int32, + string) + { + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + string, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32, + string) + } // end of property Data::Item + } // end of class Data + + .class sequential ansi sealed nested private beforefieldinit StructData + extends [mscorlib]System.ValueType + { + .field public int32 Field + .field private int32 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method public hidebysig specialname + instance int32 get_Property() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 11 (0xb) + .maxstack 1 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method StructData::get_Property + + .method public hidebysig specialname + instance void set_Property(int32 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0007: ret + } // end of method StructData::set_Property + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_MoreData() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 11 (0xb) + .maxstack 1 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method StructData::get_MoreData + + .method public hidebysig specialname + instance void set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0007: ret + } // end of method StructData::set_MoreData + + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 initialValue) cil managed + { + // Code size 24 (0x18) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_000f: ldarg.0 + IL_0010: ldarg.1 + IL_0011: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0016: nop + IL_0017: ret + } // end of method StructData::.ctor + + .property instance int32 Property() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_Property() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + } // end of property StructData::Property + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + MoreData() + { + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + } // end of property StructData::MoreData + } // end of class StructData + + .field private static class [mscorlib]System.EventHandler 'CS$<>9__CachedAnonymousMethodDelegate8' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private static class [mscorlib]System.Func`2 'CS$<>9__CachedAnonymousMethodDelegate1c' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method private hidebysig static void X(object a, + object b) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method InitializerTests::X + + .method private hidebysig static object + Y() cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (object V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method InitializerTests::Y + + .method public hidebysig static void TestCall(int32 a, + class [mscorlib]System.Threading.Thread thread) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method InitializerTests::TestCall + + .method public hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + TestCall(int32 a, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C c) cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method InitializerTests::TestCall + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test1() cil managed + { + // Code size 42 (0x2a) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1) + IL_0000: nop + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000d: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L + IL_0012: ldloc.0 + IL_0013: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L + IL_0018: ldc.i4.1 + IL_0019: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32) + IL_001e: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0023: nop + IL_0024: ldloc.0 + IL_0025: stloc.1 + IL_0026: br.s IL_0028 + + IL_0028: ldloc.1 + IL_0029: ret + } // end of method InitializerTests::Test1 + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test1Alternative() cil managed + { + // Code size 45 (0x2d) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0, + class [mscorlib]System.Collections.Generic.List`1 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_2) + IL_0000: nop + IL_0001: ldc.i4.1 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000e: stloc.1 + IL_000f: ldloc.1 + IL_0010: ldc.i4.1 + IL_0011: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32) + IL_0016: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001b: nop + IL_001c: ldloc.1 + IL_001d: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L + IL_0022: ldloc.0 + IL_0023: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C) + IL_0028: stloc.2 + IL_0029: br.s IL_002b + + IL_002b: ldloc.2 + IL_002c: ret + } // end of method InitializerTests::Test1Alternative + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test2() cil managed + { + // Code size 27 (0x1b) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1) + IL_0000: nop + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldc.i4.1 + IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_000e: ldloc.0 + IL_000f: ldc.i4.2 + IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_0015: ldloc.0 + IL_0016: stloc.1 + IL_0017: br.s IL_0019 + + IL_0019: ldloc.1 + IL_001a: ret + } // end of method InitializerTests::Test2 + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test3() cil managed + { + // Code size 37 (0x25) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1) + IL_0000: nop + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldc.i4.1 + IL_0009: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32) + IL_000e: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0013: ldloc.0 + IL_0014: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0019: ldc.i4.2 + IL_001a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_001f: ldloc.0 + IL_0020: stloc.1 + IL_0021: br.s IL_0023 + + IL_0023: ldloc.1 + IL_0024: ret + } // end of method InitializerTests::Test3 + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test3b() cil managed + { + // Code size 38 (0x26) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0007: stloc.0 + IL_0008: ldloc.0 + IL_0009: ldc.i4.1 + IL_000a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_000f: ldloc.0 + IL_0010: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0015: ldc.i4.2 + IL_0016: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_001b: ldloc.0 + IL_001c: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C) + IL_0021: stloc.1 + IL_0022: br.s IL_0024 + + IL_0024: ldloc.1 + IL_0025: ret + } // end of method InitializerTests::Test3b + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test4() cil managed + { + // Code size 44 (0x2c) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1) + IL_0000: nop + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_000d: ldc.i4.1 + IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_0013: ldloc.0 + IL_0014: ldc.i4.2 + IL_0015: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_001a: ldloc.0 + IL_001b: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0020: ldc.i4.3 + IL_0021: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B + IL_0026: ldloc.0 + IL_0027: stloc.1 + IL_0028: br.s IL_002a + + IL_002a: ldloc.1 + IL_002b: ret + } // end of method InitializerTests::Test4 + + .method public hidebysig static void CollectionInitializerList() cil managed + { + // Code size 44 (0x2c) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: ldc.i4.1 + IL_000e: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0013: nop + IL_0014: ldloc.0 + IL_0015: ldc.i4.2 + IL_0016: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001b: nop + IL_001c: ldloc.0 + IL_001d: ldc.i4.3 + IL_001e: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0023: nop + IL_0024: ldloc.0 + IL_0025: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002a: nop + IL_002b: ret + } // end of method InitializerTests::CollectionInitializerList + + .method public hidebysig static object + RecursiveCollectionInitializer() cil managed + { + // Code size 21 (0x15) + .maxstack 2 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0, + object V_1) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldloc.0 + IL_0009: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_000e: nop + IL_000f: ldloc.0 + IL_0010: stloc.1 + IL_0011: br.s IL_0013 + + IL_0013: ldloc.1 + IL_0014: ret + } // end of method InitializerTests::RecursiveCollectionInitializer + + .method public hidebysig static void CollectionInitializerDictionary() cil managed + { + // Code size 59 (0x3b) + .maxstack 4 + .locals init (class [mscorlib]System.Collections.Generic.Dictionary`2 V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor() + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: ldstr "First" + IL_0012: ldc.i4.1 + IL_0013: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0018: nop + IL_0019: ldloc.0 + IL_001a: ldstr "Second" + IL_001f: ldc.i4.2 + IL_0020: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0025: nop + IL_0026: ldloc.0 + IL_0027: ldstr "Third" + IL_002c: ldc.i4.3 + IL_002d: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0032: nop + IL_0033: ldloc.0 + IL_0034: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0039: nop + IL_003a: ret + } // end of method InitializerTests::CollectionInitializerDictionary + + .method public hidebysig static void CollectionInitializerDictionaryWithEnumTypes() cil managed + { + // Code size 38 (0x26) + .maxstack 4 + .locals init (class [mscorlib]System.Collections.Generic.Dictionary`2 V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor() + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: ldc.i4.0 + IL_000e: ldc.i4.0 + IL_000f: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0014: nop + IL_0015: ldloc.0 + IL_0016: ldc.i4.1 + IL_0017: ldc.i4.1 + IL_0018: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_001d: nop + IL_001e: ldloc.0 + IL_001f: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0024: nop + IL_0025: ret + } // end of method InitializerTests::CollectionInitializerDictionaryWithEnumTypes + + .method public hidebysig static void NotACollectionInitializer() cil managed + { + // Code size 44 (0x2c) + .maxstack 2 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldc.i4.1 + IL_0009: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_000e: nop + IL_000f: ldloc.0 + IL_0010: ldc.i4.2 + IL_0011: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0016: nop + IL_0017: ldloc.0 + IL_0018: ldc.i4.3 + IL_0019: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001e: nop + IL_001f: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0024: ldloc.0 + IL_0025: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002a: nop + IL_002b: ret + } // end of method InitializerTests::NotACollectionInitializer + + .method public hidebysig static void ObjectInitializer() cil managed + { + // Code size 28 (0x1c) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: ldc.i4.0 + IL_000e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0013: nop + IL_0014: ldloc.0 + IL_0015: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_001a: nop + IL_001b: ret + } // end of method InitializerTests::ObjectInitializer + + .method public hidebysig static void NotAnObjectInitializer() cil managed + { + // Code size 28 (0x1c) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldc.i4.0 + IL_0009: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_000e: nop + IL_000f: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0014: ldloc.0 + IL_0015: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_001a: nop + IL_001b: ret + } // end of method InitializerTests::NotAnObjectInitializer + + .method public hidebysig static void NotAnObjectInitializerWithEvent() cil managed + { + // Code size 58 (0x3a) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'CS$<>9__CachedAnonymousMethodDelegate8' + IL_000d: brtrue.s IL_0022 + + IL_000f: ldnull + IL_0010: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'b__7'(object, + class [mscorlib]System.EventArgs) + IL_0016: newobj instance void [mscorlib]System.EventHandler::.ctor(object, + native int) + IL_001b: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'CS$<>9__CachedAnonymousMethodDelegate8' + IL_0020: br.s IL_0022 + + IL_0022: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'CS$<>9__CachedAnonymousMethodDelegate8' + IL_0027: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::add_TestEvent(class [mscorlib]System.EventHandler) + IL_002c: nop + IL_002d: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0032: ldloc.0 + IL_0033: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0038: nop + IL_0039: ret + } // end of method InitializerTests::NotAnObjectInitializerWithEvent + + .method public hidebysig static void ObjectInitializerAssignCollectionToField() cil managed + { + // Code size 57 (0x39) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0, + class [mscorlib]System.Collections.Generic.List`1 V_1) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: ldc.i4.0 + IL_000e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0013: nop + IL_0014: ldloc.0 + IL_0015: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_001a: stloc.1 + IL_001b: ldloc.1 + IL_001c: ldc.i4.0 + IL_001d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0022: nop + IL_0023: ldloc.1 + IL_0024: ldc.i4.1 + IL_0025: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002a: nop + IL_002b: ldloc.1 + IL_002c: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0031: ldloc.0 + IL_0032: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0037: nop + IL_0038: ret + } // end of method InitializerTests::ObjectInitializerAssignCollectionToField + + .method public hidebysig static void ObjectInitializerAddToCollectionInField() cil managed + { + // Code size 54 (0x36) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: ldc.i4.0 + IL_000e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0013: nop + IL_0014: ldloc.0 + IL_0015: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_001a: ldc.i4.0 + IL_001b: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0020: nop + IL_0021: ldloc.0 + IL_0022: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0027: ldc.i4.1 + IL_0028: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002d: nop + IL_002e: ldloc.0 + IL_002f: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0034: nop + IL_0035: ret + } // end of method InitializerTests::ObjectInitializerAddToCollectionInField + + .method public hidebysig static void ObjectInitializerAssignCollectionToProperty() cil managed + { + // Code size 58 (0x3a) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0, + class [mscorlib]System.Collections.Generic.List`1 V_1) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: ldc.i4.0 + IL_000e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0013: nop + IL_0014: ldloc.0 + IL_0015: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_001a: stloc.1 + IL_001b: ldloc.1 + IL_001c: ldc.i4.0 + IL_001d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0022: nop + IL_0023: ldloc.1 + IL_0024: ldc.i4.1 + IL_0025: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002a: nop + IL_002b: ldloc.1 + IL_002c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_PropertyList(class [mscorlib]System.Collections.Generic.List`1) + IL_0031: nop + IL_0032: ldloc.0 + IL_0033: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0038: nop + IL_0039: ret + } // end of method InitializerTests::ObjectInitializerAssignCollectionToProperty + + .method public hidebysig static void ObjectInitializerAddToCollectionInProperty() cil managed + { + // Code size 54 (0x36) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: ldc.i4.0 + IL_000e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0013: nop + IL_0014: ldloc.0 + IL_0015: callvirt instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + IL_001a: ldc.i4.0 + IL_001b: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0020: nop + IL_0021: ldloc.0 + IL_0022: callvirt instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + IL_0027: ldc.i4.1 + IL_0028: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002d: nop + IL_002e: ldloc.0 + IL_002f: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0034: nop + IL_0035: ret + } // end of method InitializerTests::ObjectInitializerAddToCollectionInProperty + + .method public hidebysig static void ObjectInitializerWithInitializationOfNestedObjects() cil managed + { + // Code size 51 (0x33) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0012: ldc.i4.0 + IL_0013: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0018: nop + IL_0019: ldloc.0 + IL_001a: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_001f: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0024: ldc.i4.1 + IL_0025: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_002a: nop + IL_002b: ldloc.0 + IL_002c: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0031: nop + IL_0032: ret + } // end of method InitializerTests::ObjectInitializerWithInitializationOfNestedObjects + + .method private hidebysig static int32 + GetInt() cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (int32 V_0) + IL_0000: nop + IL_0001: ldc.i4.1 + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method InitializerTests::GetInt + + .method private hidebysig static string + GetString() cil managed + { + // Code size 11 (0xb) + .maxstack 1 + .locals init (string V_0) + IL_0000: nop + IL_0001: ldstr "Test" + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method InitializerTests::GetString + + .method public hidebysig static void ObjectInitializerWithInitializationOfDeeplyNestedObjects() cil managed + { + // Code size 84 (0x54) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: ldc.i4.1 + IL_000e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0013: nop + IL_0014: ldloc.0 + IL_0015: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_001a: ldc.i4.0 + IL_001b: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0020: nop + IL_0021: ldloc.0 + IL_0022: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0027: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_002c: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0031: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0036: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_003b: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0040: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0045: ldc.i4.1 + IL_0046: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_004b: nop + IL_004c: ldloc.0 + IL_004d: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0052: nop + IL_0053: ret + } // end of method InitializerTests::ObjectInitializerWithInitializationOfDeeplyNestedObjects + + .method public hidebysig static void CollectionInitializerInsideObjectInitializers() cil managed + { + // Code size 63 (0x3f) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_1) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0012: stloc.1 + IL_0013: ldloc.1 + IL_0014: ldc.i4.0 + IL_0015: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_001a: nop + IL_001b: ldloc.1 + IL_001c: ldc.i4.1 + IL_001d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0022: nop + IL_0023: ldloc.1 + IL_0024: callvirt instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + IL_0029: ldc.i4.0 + IL_002a: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002f: nop + IL_0030: ldloc.1 + IL_0031: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + IL_0036: nop + IL_0037: ldloc.0 + IL_0038: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_003d: nop + IL_003e: ret + } // end of method InitializerTests::CollectionInitializerInsideObjectInitializers + + .method public hidebysig static void NotAStructInitializer_DefaultConstructor() cil managed + { + // Code size 44 (0x2c) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: nop + IL_0001: ldloca.s V_0 + IL_0003: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0009: ldloca.s V_0 + IL_000b: ldc.i4.1 + IL_000c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0011: ldloca.s V_0 + IL_0013: ldc.i4.2 + IL_0014: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0019: nop + IL_001a: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_001f: ldloc.0 + IL_0020: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0025: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002a: nop + IL_002b: ret + } // end of method InitializerTests::NotAStructInitializer_DefaultConstructor + + .method public hidebysig static void StructInitializer_DefaultConstructor() cil managed + { + // Code size 44 (0x2c) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: ldloca.s V_0 + IL_0008: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_000e: ldloca.s V_0 + IL_0010: ldc.i4.1 + IL_0011: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0016: ldloca.s V_0 + IL_0018: ldc.i4.2 + IL_0019: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_001e: nop + IL_001f: ldloc.0 + IL_0020: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0025: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002a: nop + IL_002b: ret + } // end of method InitializerTests::StructInitializer_DefaultConstructor + + .method public hidebysig static void NotAStructInitializer_ExplicitConstructor() cil managed + { + // Code size 45 (0x2d) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: nop + IL_0001: ldloca.s V_0 + IL_0003: ldc.i4.0 + IL_0004: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::.ctor(int32) + IL_0009: nop + IL_000a: ldloca.s V_0 + IL_000c: ldc.i4.1 + IL_000d: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0012: ldloca.s V_0 + IL_0014: ldc.i4.2 + IL_0015: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_001a: nop + IL_001b: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0020: ldloc.0 + IL_0021: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0026: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002b: nop + IL_002c: ret + } // end of method InitializerTests::NotAStructInitializer_ExplicitConstructor + + .method public hidebysig static void StructInitializer_ExplicitConstructor() cil managed + { + // Code size 45 (0x2d) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: ldloca.s V_0 + IL_0008: ldc.i4.0 + IL_0009: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::.ctor(int32) + IL_000e: nop + IL_000f: ldloca.s V_0 + IL_0011: ldc.i4.1 + IL_0012: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0017: ldloca.s V_0 + IL_0019: ldc.i4.2 + IL_001a: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_001f: nop + IL_0020: ldloc.0 + IL_0021: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0026: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002b: nop + IL_002c: ret + } // end of method InitializerTests::StructInitializer_ExplicitConstructor + + .method public hidebysig static void StructInitializerWithInitializationOfNestedObjects() cil managed + { + // Code size 79 (0x4f) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: ldloca.s V_0 + IL_0008: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_000e: ldloca.s V_0 + IL_0010: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + IL_0015: ldc.i4.0 + IL_0016: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_001b: nop + IL_001c: ldloca.s V_0 + IL_001e: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + IL_0023: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0028: ldc.i4.0 + IL_0029: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002e: nop + IL_002f: ldloca.s V_0 + IL_0031: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + IL_0036: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_003b: ldc.i4.1 + IL_003c: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0041: nop + IL_0042: ldloc.0 + IL_0043: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0048: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_004d: nop + IL_004e: ret + } // end of method InitializerTests::StructInitializerWithInitializationOfNestedObjects + + .method public hidebysig static void StructInitializerWithinObjectInitializer() cil managed + { + // Code size 54 (0x36) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_1) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: ldloca.s V_1 + IL_000f: ldc.i4.2 + IL_0010: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::.ctor(int32) + IL_0015: nop + IL_0016: ldloca.s V_1 + IL_0018: ldc.i4.1 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_001e: ldloca.s V_1 + IL_0020: ldc.i4.2 + IL_0021: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0026: nop + IL_0027: ldloc.1 + IL_0028: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_NestedStruct(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData) + IL_002d: nop + IL_002e: ldloc.0 + IL_002f: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0034: nop + IL_0035: ret + } // end of method InitializerTests::StructInitializerWithinObjectInitializer + + .method public hidebysig static void Bug270_NestedInitialisers() cil managed + { + // Code size 128 (0x80) + .maxstack 6 + .locals init (class [mscorlib]System.Globalization.NumberFormatInfo[] V_0, + class [mscorlib]System.Threading.Thread V_1, + class [mscorlib]System.Globalization.CultureInfo V_2, + class [mscorlib]System.Globalization.DateTimeFormatInfo V_3) + IL_0000: nop + IL_0001: ldnull + IL_0002: stloc.0 + IL_0003: ldc.i4.0 + IL_0004: ldnull + IL_0005: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Bug270_NestedInitialisers() + IL_000b: newobj instance void [mscorlib]System.Threading.ThreadStart::.ctor(object, + native int) + IL_0010: newobj instance void [mscorlib]System.Threading.Thread::.ctor(class [mscorlib]System.Threading.ThreadStart) + IL_0015: stloc.1 + IL_0016: ldloc.1 + IL_0017: ldc.i4.1 + IL_0018: callvirt instance void [mscorlib]System.Threading.Thread::set_Priority(valuetype [mscorlib]System.Threading.ThreadPriority) + IL_001d: nop + IL_001e: ldloc.1 + IL_001f: ldc.i4.0 + IL_0020: newobj instance void [mscorlib]System.Globalization.CultureInfo::.ctor(int32) + IL_0025: stloc.2 + IL_0026: ldloc.2 + IL_0027: newobj instance void [mscorlib]System.Globalization.DateTimeFormatInfo::.ctor() + IL_002c: stloc.3 + IL_002d: ldloc.3 + IL_002e: ldstr "ddmmyy" + IL_0033: callvirt instance void [mscorlib]System.Globalization.DateTimeFormatInfo::set_ShortDatePattern(string) + IL_0038: nop + IL_0039: ldloc.3 + IL_003a: callvirt instance void [mscorlib]System.Globalization.CultureInfo::set_DateTimeFormat(class [mscorlib]System.Globalization.DateTimeFormatInfo) + IL_003f: nop + IL_0040: ldloc.2 + IL_0041: ldloc.0 + IL_0042: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'CS$<>9__CachedAnonymousMethodDelegate1c' + IL_0047: brtrue.s IL_005c + + IL_0049: ldnull + IL_004a: ldftn bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'b__1b'(class [mscorlib]System.Globalization.NumberFormatInfo) + IL_0050: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_0055: stsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'CS$<>9__CachedAnonymousMethodDelegate1c' + IL_005a: br.s IL_005c + + IL_005c: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'CS$<>9__CachedAnonymousMethodDelegate1c' + IL_0061: 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_0066: call !!0 [System.Core]System.Linq.Enumerable::First(class [mscorlib]System.Collections.Generic.IEnumerable`1) + IL_006b: callvirt instance void [mscorlib]System.Globalization.CultureInfo::set_NumberFormat(class [mscorlib]System.Globalization.NumberFormatInfo) + IL_0070: nop + IL_0071: ldloc.2 + IL_0072: callvirt instance void [mscorlib]System.Threading.Thread::set_CurrentCulture(class [mscorlib]System.Globalization.CultureInfo) + IL_0077: nop + IL_0078: ldloc.1 + IL_0079: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32, + class [mscorlib]System.Threading.Thread) + IL_007e: nop + IL_007f: ret + } // end of method InitializerTests::Bug270_NestedInitialisers + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method InitializerTests::.ctor + + .method private hidebysig static void 'b__7'(object sender, + class [mscorlib]System.EventArgs e) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: call void [mscorlib]System.Console::WriteLine() + IL_0005: nop + IL_0006: ret + } // end of method InitializerTests::'b__7' + + .method private hidebysig static bool 'b__1b'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 21 (0x15) + .maxstack 2 + .locals init (bool V_0) + IL_0000: ldarg.0 + IL_0001: callvirt instance string [mscorlib]System.Globalization.NumberFormatInfo::get_CurrencySymbol() + IL_0006: ldstr "$" + IL_000b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0010: stloc.0 + IL_0011: br.s IL_0013 + + IL_0013: ldloc.0 + IL_0014: ret + } // end of method InitializerTests::'b__1b' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** +// Warnung: Win32-Ressourcendatei "../../../TestCases/Pretty\InitializerTests.res" wurde erstellt. diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il new file mode 100644 index 000000000..bf86fbc0c --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.il @@ -0,0 +1,1281 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly extern System.Core +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly mo2wq1js +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module mo2wq1js.dll +// MVID: {99F5978B-D68E-4578-9D8F-7D47C1F63A30} +.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 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests + extends [mscorlib]System.Object +{ + .class auto ansi nested public beforefieldinit C + extends [mscorlib]System.Object + { + .field public int32 Z + .field public valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S Y + .field public class [mscorlib]System.Collections.Generic.List`1 L + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method C::.ctor + + } // end of class C + + .class sequential ansi sealed nested public beforefieldinit S + extends [mscorlib]System.ValueType + { + .field public int32 A + .field public int32 B + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 a) cil managed + { + // Code size 15 (0xf) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_0007: ldarg.0 + IL_0008: ldc.i4.0 + IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B + IL_000e: ret + } // end of method S::.ctor + + } // end of class S + + .class auto ansi sealed nested private MyEnum + extends [mscorlib]System.Enum + { + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum a = int32(0x00000000) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum b = int32(0x00000001) + } // end of class MyEnum + + .class auto ansi sealed nested private MyEnum2 + extends [mscorlib]System.Enum + { + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum2 c = int32(0x00000000) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum2 d = int32(0x00000001) + } // end of class MyEnum2 + + .class auto ansi nested private beforefieldinit Data + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Reflection.DefaultMemberAttribute::.ctor(string) = ( 01 00 04 49 74 65 6D 00 00 ) // ...Item.. + .field public class [mscorlib]System.Collections.Generic.List`1 FieldList + .field private class [mscorlib]System.EventHandler TestEvent + .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private class [mscorlib]System.Collections.Generic.List`1 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method public hidebysig specialname + instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + get_a() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_a + + .method public hidebysig specialname + instance void set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_a + + .method public hidebysig specialname + instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + get_b() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_b + + .method public hidebysig specialname + instance void set_b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_b + + .method public hidebysig specialname + instance class [mscorlib]System.Collections.Generic.List`1 + get_PropertyList() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_PropertyList + + .method public hidebysig specialname + instance void set_PropertyList(class [mscorlib]System.Collections.Generic.List`1 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_PropertyList + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_MoreData() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_MoreData + + .method public hidebysig specialname + instance void set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_MoreData + + .method public hidebysig specialname + instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + get_NestedStruct() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_NestedStruct + + .method public hidebysig specialname + instance void set_NestedStruct(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_NestedStruct + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_Item(int32 i) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } // end of method Data::get_Item + + .method public hidebysig specialname + instance void set_Item(int32 i, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method Data::set_Item + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_Item(int32 i, + string j) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } // end of method Data::get_Item + + .method public hidebysig specialname + instance void set_Item(int32 i, + string j, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method Data::set_Item + + .method public hidebysig specialname + instance void add_TestEvent(class [mscorlib]System.EventHandler 'value') cil managed + { + // Code size 41 (0x29) + .maxstack 3 + .locals init (class [mscorlib]System.EventHandler V_0, + class [mscorlib]System.EventHandler V_1, + class [mscorlib]System.EventHandler V_2) + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: ldarg.1 + IL_000b: call class [mscorlib]System.Delegate [mscorlib]System.Delegate::Combine(class [mscorlib]System.Delegate, + class [mscorlib]System.Delegate) + IL_0010: castclass [mscorlib]System.EventHandler + IL_0015: stloc.2 + IL_0016: ldarg.0 + IL_0017: ldflda class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_001c: ldloc.2 + IL_001d: ldloc.1 + IL_001e: call !!0 [mscorlib]System.Threading.Interlocked::CompareExchange(!!0&, + !!0, + !!0) + IL_0023: stloc.0 + IL_0024: ldloc.0 + IL_0025: ldloc.1 + IL_0026: bne.un.s IL_0007 + + IL_0028: ret + } // end of method Data::add_TestEvent + + .method public hidebysig specialname + instance void remove_TestEvent(class [mscorlib]System.EventHandler 'value') cil managed + { + // Code size 41 (0x29) + .maxstack 3 + .locals init (class [mscorlib]System.EventHandler V_0, + class [mscorlib]System.EventHandler V_1, + class [mscorlib]System.EventHandler V_2) + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: ldarg.1 + IL_000b: call class [mscorlib]System.Delegate [mscorlib]System.Delegate::Remove(class [mscorlib]System.Delegate, + class [mscorlib]System.Delegate) + IL_0010: castclass [mscorlib]System.EventHandler + IL_0015: stloc.2 + IL_0016: ldarg.0 + IL_0017: ldflda class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_001c: ldloc.2 + IL_001d: ldloc.1 + IL_001e: call !!0 [mscorlib]System.Threading.Interlocked::CompareExchange(!!0&, + !!0, + !!0) + IL_0023: stloc.0 + IL_0024: ldloc.0 + IL_0025: ldloc.1 + IL_0026: bne.un.s IL_0007 + + IL_0028: ret + } // end of method Data::remove_TestEvent + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 18 (0x12) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0006: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_000b: ldarg.0 + IL_000c: call instance void [mscorlib]System.Object::.ctor() + IL_0011: ret + } // end of method Data::.ctor + + .event [mscorlib]System.EventHandler TestEvent + { + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::remove_TestEvent(class [mscorlib]System.EventHandler) + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::add_TestEvent(class [mscorlib]System.EventHandler) + } // end of event Data::TestEvent + .property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + a() + { + .get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_a() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + } // end of property Data::a + .property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + b() + { + .get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_b() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + } // end of property Data::b + .property instance class [mscorlib]System.Collections.Generic.List`1 + PropertyList() + { + .get instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_PropertyList(class [mscorlib]System.Collections.Generic.List`1) + } // end of property Data::PropertyList + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + MoreData() + { + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + } // end of property Data::MoreData + .property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + NestedStruct() + { + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_NestedStruct(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData) + .get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_NestedStruct() + } // end of property Data::NestedStruct + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + Item(int32) + { + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32) + } // end of property Data::Item + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + Item(int32, + string) + { + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + string, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32, + string) + } // end of property Data::Item + } // end of class Data + + .class sequential ansi sealed nested private beforefieldinit StructData + extends [mscorlib]System.ValueType + { + .field public int32 Field + .field private int32 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method public hidebysig specialname + instance int32 get_Property() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0006: ret + } // end of method StructData::get_Property + + .method public hidebysig specialname + instance void set_Property(int32 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0007: ret + } // end of method StructData::set_Property + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_MoreData() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0006: ret + } // end of method StructData::get_MoreData + + .method public hidebysig specialname + instance void set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0007: ret + } // end of method StructData::set_MoreData + + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 initialValue) cil managed + { + // Code size 22 (0x16) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0007: ldarg.0 + IL_0008: ldarg.1 + IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_000e: ldarg.0 + IL_000f: ldarg.1 + IL_0010: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0015: ret + } // end of method StructData::.ctor + + .property instance int32 Property() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_Property() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + } // end of property StructData::Property + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + MoreData() + { + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + } // end of property StructData::MoreData + } // end of class StructData + + .field private static class [mscorlib]System.EventHandler 'CS$<>9__CachedAnonymousMethodDelegate8' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private static class [mscorlib]System.Func`2 'CS$<>9__CachedAnonymousMethodDelegate1c' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method private hidebysig static void X(object a, + object b) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method InitializerTests::X + + .method private hidebysig static object + Y() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } // end of method InitializerTests::Y + + .method public hidebysig static void TestCall(int32 a, + class [mscorlib]System.Threading.Thread thread) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method InitializerTests::TestCall + + .method public hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + TestCall(int32 a, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C c) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ret + } // end of method InitializerTests::TestCall + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test1() cil managed + { + // Code size 36 (0x24) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000c: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L + IL_0011: ldloc.0 + IL_0012: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L + IL_0017: ldc.i4.1 + IL_0018: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32) + IL_001d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0022: ldloc.0 + IL_0023: ret + } // end of method InitializerTests::Test1 + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test1Alternative() cil managed + { + // Code size 39 (0x27) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0, + class [mscorlib]System.Collections.Generic.List`1 V_1) + IL_0000: ldc.i4.1 + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000d: stloc.1 + IL_000e: ldloc.1 + IL_000f: ldc.i4.1 + IL_0010: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32) + IL_0015: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001a: ldloc.1 + IL_001b: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L + IL_0020: ldloc.0 + IL_0021: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C) + IL_0026: ret + } // end of method InitializerTests::Test1Alternative + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test2() cil managed + { + // Code size 22 (0x16) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldc.i4.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_000d: ldloc.0 + IL_000e: ldc.i4.2 + IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_0014: ldloc.0 + IL_0015: ret + } // end of method InitializerTests::Test2 + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test3() cil managed + { + // Code size 32 (0x20) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldc.i4.1 + IL_0008: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32) + IL_000d: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0012: ldloc.0 + IL_0013: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0018: ldc.i4.2 + IL_0019: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_001e: ldloc.0 + IL_001f: ret + } // end of method InitializerTests::Test3 + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test3b() cil managed + { + // Code size 33 (0x21) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0) + IL_0000: ldc.i4.0 + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldc.i4.1 + IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_000e: ldloc.0 + IL_000f: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0014: ldc.i4.2 + IL_0015: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_001a: ldloc.0 + IL_001b: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C) + IL_0020: ret + } // end of method InitializerTests::Test3b + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test4() cil managed + { + // Code size 39 (0x27) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_000c: ldc.i4.1 + IL_000d: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_0012: ldloc.0 + IL_0013: ldc.i4.2 + IL_0014: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_0019: ldloc.0 + IL_001a: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_001f: ldc.i4.3 + IL_0020: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B + IL_0025: ldloc.0 + IL_0026: ret + } // end of method InitializerTests::Test4 + + .method public hidebysig static void CollectionInitializerList() cil managed + { + // Code size 39 (0x27) + .maxstack 3 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000a: stloc.0 + IL_000b: ldloc.0 + IL_000c: ldc.i4.1 + IL_000d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0012: ldloc.0 + IL_0013: ldc.i4.2 + IL_0014: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0019: ldloc.0 + IL_001a: ldc.i4.3 + IL_001b: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0020: ldloc.0 + IL_0021: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0026: ret + } // end of method InitializerTests::CollectionInitializerList + + .method public hidebysig static object + RecursiveCollectionInitializer() cil managed + { + // Code size 15 (0xf) + .maxstack 2 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0) + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldloc.0 + IL_0008: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_000d: ldloc.0 + IL_000e: ret + } // end of method InitializerTests::RecursiveCollectionInitializer + + .method public hidebysig static void CollectionInitializerDictionary() cil managed + { + // Code size 54 (0x36) + .maxstack 4 + .locals init (class [mscorlib]System.Collections.Generic.Dictionary`2 V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor() + IL_000a: stloc.0 + IL_000b: ldloc.0 + IL_000c: ldstr "First" + IL_0011: ldc.i4.1 + IL_0012: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0017: ldloc.0 + IL_0018: ldstr "Second" + IL_001d: ldc.i4.2 + IL_001e: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0023: ldloc.0 + IL_0024: ldstr "Third" + IL_0029: ldc.i4.3 + IL_002a: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_002f: ldloc.0 + IL_0030: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0035: ret + } // end of method InitializerTests::CollectionInitializerDictionary + + .method public hidebysig static void CollectionInitializerDictionaryWithEnumTypes() cil managed + { + // Code size 34 (0x22) + .maxstack 4 + .locals init (class [mscorlib]System.Collections.Generic.Dictionary`2 V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor() + IL_000a: stloc.0 + IL_000b: ldloc.0 + IL_000c: ldc.i4.0 + IL_000d: ldc.i4.0 + IL_000e: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0013: ldloc.0 + IL_0014: ldc.i4.1 + IL_0015: ldc.i4.1 + IL_0016: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_001b: ldloc.0 + IL_001c: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0021: ret + } // end of method InitializerTests::CollectionInitializerDictionaryWithEnumTypes + + .method public hidebysig static void NotACollectionInitializer() cil managed + { + // Code size 39 (0x27) + .maxstack 2 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0) + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldc.i4.1 + IL_0008: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_000d: ldloc.0 + IL_000e: ldc.i4.2 + IL_000f: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0014: ldloc.0 + IL_0015: ldc.i4.3 + IL_0016: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001b: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0020: ldloc.0 + IL_0021: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0026: ret + } // end of method InitializerTests::NotACollectionInitializer + + .method public hidebysig static void ObjectInitializer() cil managed + { + // Code size 25 (0x19) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: stloc.0 + IL_000b: ldloc.0 + IL_000c: ldc.i4.0 + IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0012: ldloc.0 + IL_0013: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0018: ret + } // end of method InitializerTests::ObjectInitializer + + .method public hidebysig static void NotAnObjectInitializer() cil managed + { + // Code size 25 (0x19) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldc.i4.0 + IL_0008: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_000d: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0012: ldloc.0 + IL_0013: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0018: ret + } // end of method InitializerTests::NotAnObjectInitializer + + .method public hidebysig static void NotAnObjectInitializerWithEvent() cil managed + { + // Code size 53 (0x35) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'CS$<>9__CachedAnonymousMethodDelegate8' + IL_000c: brtrue.s IL_001f + + IL_000e: ldnull + IL_000f: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'b__7'(object, + class [mscorlib]System.EventArgs) + IL_0015: newobj instance void [mscorlib]System.EventHandler::.ctor(object, + native int) + IL_001a: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'CS$<>9__CachedAnonymousMethodDelegate8' + IL_001f: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'CS$<>9__CachedAnonymousMethodDelegate8' + IL_0024: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::add_TestEvent(class [mscorlib]System.EventHandler) + IL_0029: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_002e: ldloc.0 + IL_002f: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0034: ret + } // end of method InitializerTests::NotAnObjectInitializerWithEvent + + .method public hidebysig static void ObjectInitializerAssignCollectionToField() cil managed + { + // Code size 52 (0x34) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0, + class [mscorlib]System.Collections.Generic.List`1 V_1) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: stloc.0 + IL_000b: ldloc.0 + IL_000c: ldc.i4.0 + IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0012: ldloc.0 + IL_0013: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0018: stloc.1 + IL_0019: ldloc.1 + IL_001a: ldc.i4.0 + IL_001b: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0020: ldloc.1 + IL_0021: ldc.i4.1 + IL_0022: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0027: ldloc.1 + IL_0028: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_002d: ldloc.0 + IL_002e: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0033: ret + } // end of method InitializerTests::ObjectInitializerAssignCollectionToField + + .method public hidebysig static void ObjectInitializerAddToCollectionInField() cil managed + { + // Code size 49 (0x31) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: stloc.0 + IL_000b: ldloc.0 + IL_000c: ldc.i4.0 + IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0012: ldloc.0 + IL_0013: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0018: ldc.i4.0 + IL_0019: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001e: ldloc.0 + IL_001f: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0024: ldc.i4.1 + IL_0025: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002a: ldloc.0 + IL_002b: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0030: ret + } // end of method InitializerTests::ObjectInitializerAddToCollectionInField + + .method public hidebysig static void ObjectInitializerAssignCollectionToProperty() cil managed + { + // Code size 52 (0x34) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0, + class [mscorlib]System.Collections.Generic.List`1 V_1) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: stloc.0 + IL_000b: ldloc.0 + IL_000c: ldc.i4.0 + IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0012: ldloc.0 + IL_0013: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0018: stloc.1 + IL_0019: ldloc.1 + IL_001a: ldc.i4.0 + IL_001b: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0020: ldloc.1 + IL_0021: ldc.i4.1 + IL_0022: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0027: ldloc.1 + IL_0028: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_PropertyList(class [mscorlib]System.Collections.Generic.List`1) + IL_002d: ldloc.0 + IL_002e: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0033: ret + } // end of method InitializerTests::ObjectInitializerAssignCollectionToProperty + + .method public hidebysig static void ObjectInitializerAddToCollectionInProperty() cil managed + { + // Code size 49 (0x31) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: stloc.0 + IL_000b: ldloc.0 + IL_000c: ldc.i4.0 + IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0012: ldloc.0 + IL_0013: callvirt instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + IL_0018: ldc.i4.0 + IL_0019: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001e: ldloc.0 + IL_001f: callvirt instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + IL_0024: ldc.i4.1 + IL_0025: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002a: ldloc.0 + IL_002b: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0030: ret + } // end of method InitializerTests::ObjectInitializerAddToCollectionInProperty + + .method public hidebysig static void ObjectInitializerWithInitializationOfNestedObjects() cil managed + { + // Code size 47 (0x2f) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: stloc.0 + IL_000b: ldloc.0 + IL_000c: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0011: ldc.i4.0 + IL_0012: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0017: ldloc.0 + IL_0018: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_001d: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0022: ldc.i4.1 + IL_0023: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0028: ldloc.0 + IL_0029: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002e: ret + } // end of method InitializerTests::ObjectInitializerWithInitializationOfNestedObjects + + .method private hidebysig static int32 + GetInt() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } // end of method InitializerTests::GetInt + + .method private hidebysig static string + GetString() cil managed + { + // Code size 6 (0x6) + .maxstack 8 + IL_0000: ldstr "Test" + IL_0005: ret + } // end of method InitializerTests::GetString + + .method public hidebysig static void ObjectInitializerWithInitializationOfDeeplyNestedObjects() cil managed + { + // Code size 79 (0x4f) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: stloc.0 + IL_000b: ldloc.0 + IL_000c: ldc.i4.1 + IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0012: ldloc.0 + IL_0013: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0018: ldc.i4.0 + IL_0019: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_001e: ldloc.0 + IL_001f: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0024: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0029: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_002e: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0033: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0038: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_003d: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0042: ldc.i4.1 + IL_0043: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0048: ldloc.0 + IL_0049: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_004e: ret + } // end of method InitializerTests::ObjectInitializerWithInitializationOfDeeplyNestedObjects + + .method public hidebysig static void CollectionInitializerInsideObjectInitializers() cil managed + { + // Code size 57 (0x39) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_1) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: stloc.0 + IL_000b: ldloc.0 + IL_000c: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0011: stloc.1 + IL_0012: ldloc.1 + IL_0013: ldc.i4.0 + IL_0014: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0019: ldloc.1 + IL_001a: ldc.i4.1 + IL_001b: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0020: ldloc.1 + IL_0021: callvirt instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + IL_0026: ldc.i4.0 + IL_0027: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002c: ldloc.1 + IL_002d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + IL_0032: ldloc.0 + IL_0033: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0038: ret + } // end of method InitializerTests::CollectionInitializerInsideObjectInitializers + + .method public hidebysig static void NotAStructInitializer_DefaultConstructor() cil managed + { + // Code size 41 (0x29) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0008: ldloca.s V_0 + IL_000a: ldc.i4.1 + IL_000b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0010: ldloca.s V_0 + IL_0012: ldc.i4.2 + IL_0013: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0018: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_001d: ldloc.0 + IL_001e: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0023: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0028: ret + } // end of method InitializerTests::NotAStructInitializer_DefaultConstructor + + .method public hidebysig static void StructInitializer_DefaultConstructor() cil managed + { + // Code size 41 (0x29) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: ldloca.s V_0 + IL_0007: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_000d: ldloca.s V_0 + IL_000f: ldc.i4.1 + IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0015: ldloca.s V_0 + IL_0017: ldc.i4.2 + IL_0018: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_001d: ldloc.0 + IL_001e: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0023: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0028: ret + } // end of method InitializerTests::StructInitializer_DefaultConstructor + + .method public hidebysig static void NotAStructInitializer_ExplicitConstructor() cil managed + { + // Code size 41 (0x29) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: ldloca.s V_0 + IL_0002: ldc.i4.0 + IL_0003: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::.ctor(int32) + IL_0008: ldloca.s V_0 + IL_000a: ldc.i4.1 + IL_000b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0010: ldloca.s V_0 + IL_0012: ldc.i4.2 + IL_0013: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0018: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_001d: ldloc.0 + IL_001e: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0023: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0028: ret + } // end of method InitializerTests::NotAStructInitializer_ExplicitConstructor + + .method public hidebysig static void StructInitializer_ExplicitConstructor() cil managed + { + // Code size 41 (0x29) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: ldloca.s V_0 + IL_0007: ldc.i4.0 + IL_0008: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::.ctor(int32) + IL_000d: ldloca.s V_0 + IL_000f: ldc.i4.1 + IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0015: ldloca.s V_0 + IL_0017: ldc.i4.2 + IL_0018: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_001d: ldloc.0 + IL_001e: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0023: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0028: ret + } // end of method InitializerTests::StructInitializer_ExplicitConstructor + + .method public hidebysig static void StructInitializerWithInitializationOfNestedObjects() cil managed + { + // Code size 74 (0x4a) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: ldloca.s V_0 + IL_0007: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_000d: ldloca.s V_0 + IL_000f: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + IL_0014: ldc.i4.0 + IL_0015: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_001a: ldloca.s V_0 + IL_001c: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + IL_0021: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0026: ldc.i4.0 + IL_0027: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002c: ldloca.s V_0 + IL_002e: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + IL_0033: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0038: ldc.i4.1 + IL_0039: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_003e: ldloc.0 + IL_003f: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0044: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0049: ret + } // end of method InitializerTests::StructInitializerWithInitializationOfNestedObjects + + .method public hidebysig static void StructInitializerWithinObjectInitializer() cil managed + { + // Code size 49 (0x31) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_1) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: stloc.0 + IL_000b: ldloc.0 + IL_000c: ldloca.s V_1 + IL_000e: ldc.i4.2 + IL_000f: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::.ctor(int32) + IL_0014: ldloca.s V_1 + IL_0016: ldc.i4.1 + IL_0017: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_001c: ldloca.s V_1 + IL_001e: ldc.i4.2 + IL_001f: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0024: ldloc.1 + IL_0025: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_NestedStruct(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData) + IL_002a: ldloc.0 + IL_002b: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0030: ret + } // end of method InitializerTests::StructInitializerWithinObjectInitializer + + .method public hidebysig static void Bug270_NestedInitialisers() cil managed + { + // Code size 119 (0x77) + .maxstack 6 + .locals init (class [mscorlib]System.Globalization.NumberFormatInfo[] V_0, + class [mscorlib]System.Threading.Thread V_1, + class [mscorlib]System.Globalization.CultureInfo V_2, + class [mscorlib]System.Globalization.DateTimeFormatInfo V_3) + IL_0000: ldnull + IL_0001: stloc.0 + IL_0002: ldc.i4.0 + IL_0003: ldnull + IL_0004: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Bug270_NestedInitialisers() + IL_000a: newobj instance void [mscorlib]System.Threading.ThreadStart::.ctor(object, + native int) + IL_000f: newobj instance void [mscorlib]System.Threading.Thread::.ctor(class [mscorlib]System.Threading.ThreadStart) + IL_0014: stloc.1 + IL_0015: ldloc.1 + IL_0016: ldc.i4.1 + IL_0017: callvirt instance void [mscorlib]System.Threading.Thread::set_Priority(valuetype [mscorlib]System.Threading.ThreadPriority) + IL_001c: ldloc.1 + IL_001d: ldc.i4.0 + IL_001e: newobj instance void [mscorlib]System.Globalization.CultureInfo::.ctor(int32) + IL_0023: stloc.2 + IL_0024: ldloc.2 + IL_0025: newobj instance void [mscorlib]System.Globalization.DateTimeFormatInfo::.ctor() + IL_002a: stloc.3 + IL_002b: ldloc.3 + IL_002c: ldstr "ddmmyy" + IL_0031: callvirt instance void [mscorlib]System.Globalization.DateTimeFormatInfo::set_ShortDatePattern(string) + IL_0036: ldloc.3 + IL_0037: callvirt instance void [mscorlib]System.Globalization.CultureInfo::set_DateTimeFormat(class [mscorlib]System.Globalization.DateTimeFormatInfo) + IL_003c: ldloc.2 + IL_003d: ldloc.0 + IL_003e: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'CS$<>9__CachedAnonymousMethodDelegate1c' + IL_0043: brtrue.s IL_0056 + + IL_0045: ldnull + IL_0046: ldftn bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'b__1b'(class [mscorlib]System.Globalization.NumberFormatInfo) + IL_004c: newobj instance void class [mscorlib]System.Func`2::.ctor(object, + native int) + IL_0051: stsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'CS$<>9__CachedAnonymousMethodDelegate1c' + IL_0056: ldsfld class [mscorlib]System.Func`2 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::'CS$<>9__CachedAnonymousMethodDelegate1c' + IL_005b: 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_0060: call !!0 [System.Core]System.Linq.Enumerable::First(class [mscorlib]System.Collections.Generic.IEnumerable`1) + IL_0065: callvirt instance void [mscorlib]System.Globalization.CultureInfo::set_NumberFormat(class [mscorlib]System.Globalization.NumberFormatInfo) + IL_006a: ldloc.2 + IL_006b: callvirt instance void [mscorlib]System.Threading.Thread::set_CurrentCulture(class [mscorlib]System.Globalization.CultureInfo) + IL_0070: ldloc.1 + IL_0071: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32, + class [mscorlib]System.Threading.Thread) + IL_0076: ret + } // end of method InitializerTests::Bug270_NestedInitialisers + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method InitializerTests::.ctor + + .method private hidebysig static void 'b__7'(object sender, + class [mscorlib]System.EventArgs e) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 6 (0x6) + .maxstack 8 + IL_0000: call void [mscorlib]System.Console::WriteLine() + IL_0005: ret + } // end of method InitializerTests::'b__7' + + .method private hidebysig static bool 'b__1b'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 17 (0x11) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance string [mscorlib]System.Globalization.NumberFormatInfo::get_CurrencySymbol() + IL_0006: ldstr "$" + IL_000b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0010: ret + } // end of method InitializerTests::'b__1b' + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** +// Warnung: Win32-Ressourcendatei "../../../TestCases/Pretty\InitializerTests.opt.res" wurde erstellt. diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il new file mode 100644 index 000000000..22e3c0319 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.opt.roslyn.il @@ -0,0 +1,1314 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly extern System.Core +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly InitializerTests +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + // --- The following custom attribute is added automatically, do not uncomment ------- + // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 ) + + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module InitializerTests.dll +// MVID: {1A200C9E-AB38-4402-A1D6-E7C3307A45E2} +.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 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests + extends [mscorlib]System.Object +{ + .class auto ansi nested public beforefieldinit C + extends [mscorlib]System.Object + { + .field public int32 Z + .field public valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S Y + .field public class [mscorlib]System.Collections.Generic.List`1 L + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method C::.ctor + + } // end of class C + + .class sequential ansi sealed nested public beforefieldinit S + extends [mscorlib]System.ValueType + { + .field public int32 A + .field public int32 B + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 a) cil managed + { + // Code size 15 (0xf) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_0007: ldarg.0 + IL_0008: ldc.i4.0 + IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B + IL_000e: ret + } // end of method S::.ctor + + } // end of class S + + .class auto ansi sealed nested private MyEnum + extends [mscorlib]System.Enum + { + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum a = int32(0x00000000) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum b = int32(0x00000001) + } // end of class MyEnum + + .class auto ansi sealed nested private MyEnum2 + extends [mscorlib]System.Enum + { + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum2 c = int32(0x00000000) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum2 d = int32(0x00000001) + } // end of class MyEnum2 + + .class auto ansi nested private beforefieldinit Data + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Reflection.DefaultMemberAttribute::.ctor(string) = ( 01 00 04 49 74 65 6D 00 00 ) // ...Item.. + .field public class [mscorlib]System.Collections.Generic.List`1 FieldList + .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private class [mscorlib]System.Collections.Generic.List`1 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private class [mscorlib]System.EventHandler TestEvent + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method public hidebysig specialname + instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + get_a() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_a + + .method public hidebysig specialname + instance void set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_a + + .method public hidebysig specialname + instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + get_b() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_b + + .method public hidebysig specialname + instance void set_b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_b + + .method public hidebysig specialname + instance class [mscorlib]System.Collections.Generic.List`1 + get_PropertyList() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_PropertyList + + .method public hidebysig specialname + instance void set_PropertyList(class [mscorlib]System.Collections.Generic.List`1 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_PropertyList + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_MoreData() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_MoreData + + .method public hidebysig specialname + instance void set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_MoreData + + .method public hidebysig specialname + instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + get_NestedStruct() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_NestedStruct + + .method public hidebysig specialname + instance void set_NestedStruct(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_NestedStruct + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_Item(int32 i) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } // end of method Data::get_Item + + .method public hidebysig specialname + instance void set_Item(int32 i, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method Data::set_Item + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_Item(int32 i, + string j) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } // end of method Data::get_Item + + .method public hidebysig specialname + instance void set_Item(int32 i, + string j, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method Data::set_Item + + .method public hidebysig specialname + instance void add_TestEvent(class [mscorlib]System.EventHandler 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 41 (0x29) + .maxstack 3 + .locals init (class [mscorlib]System.EventHandler V_0, + class [mscorlib]System.EventHandler V_1, + class [mscorlib]System.EventHandler V_2) + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: ldarg.1 + IL_000b: call class [mscorlib]System.Delegate [mscorlib]System.Delegate::Combine(class [mscorlib]System.Delegate, + class [mscorlib]System.Delegate) + IL_0010: castclass [mscorlib]System.EventHandler + IL_0015: stloc.2 + IL_0016: ldarg.0 + IL_0017: ldflda class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_001c: ldloc.2 + IL_001d: ldloc.1 + IL_001e: call !!0 [mscorlib]System.Threading.Interlocked::CompareExchange(!!0&, + !!0, + !!0) + IL_0023: stloc.0 + IL_0024: ldloc.0 + IL_0025: ldloc.1 + IL_0026: bne.un.s IL_0007 + + IL_0028: ret + } // end of method Data::add_TestEvent + + .method public hidebysig specialname + instance void remove_TestEvent(class [mscorlib]System.EventHandler 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 41 (0x29) + .maxstack 3 + .locals init (class [mscorlib]System.EventHandler V_0, + class [mscorlib]System.EventHandler V_1, + class [mscorlib]System.EventHandler V_2) + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: ldarg.1 + IL_000b: call class [mscorlib]System.Delegate [mscorlib]System.Delegate::Remove(class [mscorlib]System.Delegate, + class [mscorlib]System.Delegate) + IL_0010: castclass [mscorlib]System.EventHandler + IL_0015: stloc.2 + IL_0016: ldarg.0 + IL_0017: ldflda class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_001c: ldloc.2 + IL_001d: ldloc.1 + IL_001e: call !!0 [mscorlib]System.Threading.Interlocked::CompareExchange(!!0&, + !!0, + !!0) + IL_0023: stloc.0 + IL_0024: ldloc.0 + IL_0025: ldloc.1 + IL_0026: bne.un.s IL_0007 + + IL_0028: ret + } // end of method Data::remove_TestEvent + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 18 (0x12) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0006: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_000b: ldarg.0 + IL_000c: call instance void [mscorlib]System.Object::.ctor() + IL_0011: ret + } // end of method Data::.ctor + + .event [mscorlib]System.EventHandler TestEvent + { + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::add_TestEvent(class [mscorlib]System.EventHandler) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::remove_TestEvent(class [mscorlib]System.EventHandler) + } // end of event Data::TestEvent + .property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + a() + { + .get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_a() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + } // end of property Data::a + .property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + b() + { + .get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_b() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + } // end of property Data::b + .property instance class [mscorlib]System.Collections.Generic.List`1 + PropertyList() + { + .get instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_PropertyList(class [mscorlib]System.Collections.Generic.List`1) + } // end of property Data::PropertyList + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + MoreData() + { + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + } // end of property Data::MoreData + .property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + NestedStruct() + { + .get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_NestedStruct() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_NestedStruct(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData) + } // end of property Data::NestedStruct + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + Item(int32) + { + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32) + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + } // end of property Data::Item + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + Item(int32, + string) + { + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32, + string) + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + string, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + } // end of property Data::Item + } // end of class Data + + .class sequential ansi sealed nested private beforefieldinit StructData + extends [mscorlib]System.ValueType + { + .field public int32 Field + .field private int32 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field private class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method public hidebysig specialname + instance int32 get_Property() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0006: ret + } // end of method StructData::get_Property + + .method public hidebysig specialname + instance void set_Property(int32 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0007: ret + } // end of method StructData::set_Property + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_MoreData() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0006: ret + } // end of method StructData::get_MoreData + + .method public hidebysig specialname + instance void set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0007: ret + } // end of method StructData::set_MoreData + + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 initialValue) cil managed + { + // Code size 22 (0x16) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0007: ldarg.0 + IL_0008: ldarg.1 + IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_000e: ldarg.0 + IL_000f: ldarg.1 + IL_0010: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0015: ret + } // end of method StructData::.ctor + + .property instance int32 Property() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_Property() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + } // end of property StructData::Property + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + MoreData() + { + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + } // end of property StructData::MoreData + } // end of class StructData + + .class auto ansi serializable sealed nested private beforefieldinit '<>c' + extends [mscorlib]System.Object + { + .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' + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 11 (0xb) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::.ctor() + IL_0005: stsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9' + IL_000a: ret + } // end of method '<>c'::.cctor + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method '<>c'::.ctor + + .method assembly hidebysig instance void + 'b__23_0'(object sender, + class [mscorlib]System.EventArgs e) cil managed + { + // Code size 6 (0x6) + .maxstack 8 + IL_0000: call void [mscorlib]System.Console::WriteLine() + IL_0005: ret + } // end of method '<>c'::'b__23_0' + + .method assembly hidebysig instance bool + 'b__41_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed + { + // Code size 17 (0x11) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: callvirt instance string [mscorlib]System.Globalization.NumberFormatInfo::get_CurrencySymbol() + IL_0006: ldstr "$" + IL_000b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0010: ret + } // end of method '<>c'::'b__41_0' + + } // end of class '<>c' + + .method private hidebysig static void X(object a, + object b) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method InitializerTests::X + + .method private hidebysig static object + Y() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } // end of method InitializerTests::Y + + .method public hidebysig static void TestCall(int32 a, + class [mscorlib]System.Threading.Thread thread) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method InitializerTests::TestCall + + .method public hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + TestCall(int32 a, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C c) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ret + } // end of method InitializerTests::TestCall + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test1() cil managed + { + // Code size 34 (0x22) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0005: dup + IL_0006: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000b: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L + IL_0010: dup + IL_0011: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L + IL_0016: ldc.i4.1 + IL_0017: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32) + IL_001c: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0021: ret + } // end of method InitializerTests::Test1 + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test1Alternative() cil managed + { + // Code size 35 (0x23) + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0006: dup + IL_0007: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000c: dup + IL_000d: ldc.i4.1 + IL_000e: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32) + IL_0013: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0018: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L + IL_001d: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C) + IL_0022: ret + } // end of method InitializerTests::Test1Alternative + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test2() cil managed + { + // Code size 20 (0x14) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0005: dup + IL_0006: ldc.i4.1 + IL_0007: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_000c: dup + IL_000d: ldc.i4.2 + IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_0013: ret + } // end of method InitializerTests::Test2 + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test3() cil managed + { + // Code size 30 (0x1e) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0005: dup + IL_0006: ldc.i4.1 + IL_0007: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32) + IL_000c: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0011: dup + IL_0012: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0017: ldc.i4.2 + IL_0018: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_001d: ret + } // end of method InitializerTests::Test3 + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test3b() cil managed + { + // Code size 31 (0x1f) + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0006: dup + IL_0007: ldc.i4.1 + IL_0008: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_000d: dup + IL_000e: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0013: ldc.i4.2 + IL_0014: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_0019: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C) + IL_001e: ret + } // end of method InitializerTests::Test3b + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test4() cil managed + { + // Code size 37 (0x25) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0005: dup + IL_0006: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_000b: ldc.i4.1 + IL_000c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_0011: dup + IL_0012: ldc.i4.2 + IL_0013: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_0018: dup + IL_0019: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_001e: ldc.i4.3 + IL_001f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B + IL_0024: ret + } // end of method InitializerTests::Test4 + + .method public hidebysig static void CollectionInitializerList() cil managed + { + // Code size 37 (0x25) + .maxstack 8 + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000a: dup + IL_000b: ldc.i4.1 + IL_000c: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0011: dup + IL_0012: ldc.i4.2 + IL_0013: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0018: dup + IL_0019: ldc.i4.3 + IL_001a: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001f: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0024: ret + } // end of method InitializerTests::CollectionInitializerList + + .method public hidebysig static object + RecursiveCollectionInitializer() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0005: dup + IL_0006: dup + IL_0007: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_000c: ret + } // end of method InitializerTests::RecursiveCollectionInitializer + + .method public hidebysig static void CollectionInitializerDictionary() cil managed + { + // Code size 52 (0x34) + .maxstack 8 + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor() + IL_000a: dup + IL_000b: ldstr "First" + IL_0010: ldc.i4.1 + IL_0011: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0016: dup + IL_0017: ldstr "Second" + IL_001c: ldc.i4.2 + IL_001d: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0022: dup + IL_0023: ldstr "Third" + IL_0028: ldc.i4.3 + IL_0029: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_002e: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0033: ret + } // end of method InitializerTests::CollectionInitializerDictionary + + .method public hidebysig static void CollectionInitializerDictionaryWithEnumTypes() cil managed + { + // Code size 32 (0x20) + .maxstack 8 + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor() + IL_000a: dup + IL_000b: ldc.i4.0 + IL_000c: ldc.i4.0 + IL_000d: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0012: dup + IL_0013: ldc.i4.1 + IL_0014: ldc.i4.1 + IL_0015: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_001a: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_001f: ret + } // end of method InitializerTests::CollectionInitializerDictionaryWithEnumTypes + + .method public hidebysig static void NotACollectionInitializer() cil managed + { + // Code size 39 (0x27) + .maxstack 2 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0) + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldc.i4.1 + IL_0008: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_000d: ldloc.0 + IL_000e: ldc.i4.2 + IL_000f: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0014: ldloc.0 + IL_0015: ldc.i4.3 + IL_0016: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001b: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0020: ldloc.0 + IL_0021: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0026: ret + } // end of method InitializerTests::NotACollectionInitializer + + .method public hidebysig static void ObjectInitializer() cil managed + { + // Code size 23 (0x17) + .maxstack 8 + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: dup + IL_000b: ldc.i4.0 + IL_000c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0011: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0016: ret + } // end of method InitializerTests::ObjectInitializer + + .method public hidebysig static void NotAnObjectInitializer() cil managed + { + // Code size 25 (0x19) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldc.i4.0 + IL_0008: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_000d: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0012: ldloc.0 + IL_0013: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0018: ret + } // end of method InitializerTests::NotAnObjectInitializer + + .method public hidebysig static void NotAnObjectInitializerWithEvent() cil managed + { + // Code size 55 (0x37) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0005: stloc.0 + IL_0006: ldloc.0 + IL_0007: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9__23_0' + IL_000c: dup + IL_000d: brtrue.s IL_0026 + + IL_000f: pop + IL_0010: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9' + IL_0015: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'b__23_0'(object, + class [mscorlib]System.EventArgs) + IL_001b: newobj instance void [mscorlib]System.EventHandler::.ctor(object, + native int) + IL_0020: dup + IL_0021: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9__23_0' + IL_0026: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::add_TestEvent(class [mscorlib]System.EventHandler) + IL_002b: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0030: ldloc.0 + IL_0031: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0036: ret + } // end of method InitializerTests::NotAnObjectInitializerWithEvent + + .method public hidebysig static void ObjectInitializerAssignCollectionToField() cil managed + { + // Code size 48 (0x30) + .maxstack 8 + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: dup + IL_000b: ldc.i4.0 + IL_000c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0011: dup + IL_0012: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0017: dup + IL_0018: ldc.i4.0 + IL_0019: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001e: dup + IL_001f: ldc.i4.1 + IL_0020: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0025: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_002a: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002f: ret + } // end of method InitializerTests::ObjectInitializerAssignCollectionToField + + .method public hidebysig static void ObjectInitializerAddToCollectionInField() cil managed + { + // Code size 47 (0x2f) + .maxstack 8 + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: dup + IL_000b: ldc.i4.0 + IL_000c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0011: dup + IL_0012: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0017: ldc.i4.0 + IL_0018: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001d: dup + IL_001e: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0023: ldc.i4.1 + IL_0024: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0029: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002e: ret + } // end of method InitializerTests::ObjectInitializerAddToCollectionInField + + .method public hidebysig static void ObjectInitializerAssignCollectionToProperty() cil managed + { + // Code size 48 (0x30) + .maxstack 8 + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: dup + IL_000b: ldc.i4.0 + IL_000c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0011: dup + IL_0012: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0017: dup + IL_0018: ldc.i4.0 + IL_0019: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001e: dup + IL_001f: ldc.i4.1 + IL_0020: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0025: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_PropertyList(class [mscorlib]System.Collections.Generic.List`1) + IL_002a: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002f: ret + } // end of method InitializerTests::ObjectInitializerAssignCollectionToProperty + + .method public hidebysig static void ObjectInitializerAddToCollectionInProperty() cil managed + { + // Code size 47 (0x2f) + .maxstack 8 + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: dup + IL_000b: ldc.i4.0 + IL_000c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0011: dup + IL_0012: callvirt instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + IL_0017: ldc.i4.0 + IL_0018: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001d: dup + IL_001e: callvirt instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + IL_0023: ldc.i4.1 + IL_0024: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0029: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002e: ret + } // end of method InitializerTests::ObjectInitializerAddToCollectionInProperty + + .method public hidebysig static void ObjectInitializerWithInitializationOfNestedObjects() cil managed + { + // Code size 45 (0x2d) + .maxstack 8 + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: dup + IL_000b: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0010: ldc.i4.0 + IL_0011: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0016: dup + IL_0017: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_001c: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0021: ldc.i4.1 + IL_0022: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0027: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002c: ret + } // end of method InitializerTests::ObjectInitializerWithInitializationOfNestedObjects + + .method private hidebysig static int32 + GetInt() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } // end of method InitializerTests::GetInt + + .method private hidebysig static string + GetString() cil managed + { + // Code size 6 (0x6) + .maxstack 8 + IL_0000: ldstr "Test" + IL_0005: ret + } // end of method InitializerTests::GetString + + .method public hidebysig static void SimpleDictInitializer() cil managed + { + // Code size 41 (0x29) + .maxstack 8 + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: dup + IL_000b: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0010: ldc.i4.0 + IL_0011: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0016: dup + IL_0017: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_001c: ldc.i4.2 + IL_001d: ldnull + IL_001e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + IL_0023: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0028: ret + } // end of method InitializerTests::SimpleDictInitializer + + .method public hidebysig static void MixedObjectAndDictInitializer() cil managed + { + // Code size 130 (0x82) + .maxstack 6 + .locals init (int32 V_0, + int32 V_1, + string V_2) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: dup + IL_000b: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0010: ldc.i4.0 + IL_0011: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0016: call int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::GetInt() + IL_001b: stloc.0 + IL_001c: dup + IL_001d: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0022: ldloc.0 + IL_0023: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32) + IL_0028: ldc.i4.1 + IL_0029: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_002e: dup + IL_002f: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0034: ldloc.0 + IL_0035: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32) + IL_003a: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_003f: ldc.i4.0 + IL_0040: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0045: call int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::GetInt() + IL_004a: stloc.1 + IL_004b: call string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::GetString() + IL_0050: stloc.2 + IL_0051: dup + IL_0052: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0057: ldloc.0 + IL_0058: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32) + IL_005d: ldloc.1 + IL_005e: ldloc.2 + IL_005f: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0064: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + string, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + IL_0069: dup + IL_006a: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_006f: ldloc.0 + IL_0070: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32) + IL_0075: ldc.i4.2 + IL_0076: ldnull + IL_0077: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + IL_007c: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0081: ret + } // end of method InitializerTests::MixedObjectAndDictInitializer + + .method public hidebysig static void ObjectInitializerWithInitializationOfDeeplyNestedObjects() cil managed + { + // Code size 77 (0x4d) + .maxstack 4 + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: dup + IL_000b: ldc.i4.1 + IL_000c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0011: dup + IL_0012: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0017: ldc.i4.0 + IL_0018: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_001d: dup + IL_001e: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0023: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0028: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_002d: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0032: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0037: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_003c: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0041: ldc.i4.1 + IL_0042: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0047: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_004c: ret + } // end of method InitializerTests::ObjectInitializerWithInitializationOfDeeplyNestedObjects + + .method public hidebysig static void CollectionInitializerInsideObjectInitializers() cil managed + { + // Code size 53 (0x35) + .maxstack 8 + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: dup + IL_000b: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0010: dup + IL_0011: ldc.i4.0 + IL_0012: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0017: dup + IL_0018: ldc.i4.1 + IL_0019: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_001e: dup + IL_001f: callvirt instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + IL_0024: ldc.i4.0 + IL_0025: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002a: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + IL_002f: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0034: ret + } // end of method InitializerTests::CollectionInitializerInsideObjectInitializers + + .method public hidebysig static void NotAStructInitializer_DefaultConstructor() cil managed + { + // Code size 41 (0x29) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0008: ldloca.s V_0 + IL_000a: ldc.i4.1 + IL_000b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0010: ldloca.s V_0 + IL_0012: ldc.i4.2 + IL_0013: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0018: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_001d: ldloc.0 + IL_001e: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0023: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0028: ret + } // end of method InitializerTests::NotAStructInitializer_DefaultConstructor + + .method public hidebysig static void StructInitializer_DefaultConstructor() cil managed + { + // Code size 41 (0x29) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: ldloca.s V_0 + IL_0007: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_000d: ldloca.s V_0 + IL_000f: ldc.i4.1 + IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0015: ldloca.s V_0 + IL_0017: ldc.i4.2 + IL_0018: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_001d: ldloc.0 + IL_001e: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0023: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0028: ret + } // end of method InitializerTests::StructInitializer_DefaultConstructor + + .method public hidebysig static void NotAStructInitializer_ExplicitConstructor() cil managed + { + // Code size 41 (0x29) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: ldloca.s V_0 + IL_0002: ldc.i4.0 + IL_0003: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::.ctor(int32) + IL_0008: ldloca.s V_0 + IL_000a: ldc.i4.1 + IL_000b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0010: ldloca.s V_0 + IL_0012: ldc.i4.2 + IL_0013: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0018: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_001d: ldloc.0 + IL_001e: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0023: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0028: ret + } // end of method InitializerTests::NotAStructInitializer_ExplicitConstructor + + .method public hidebysig static void StructInitializer_ExplicitConstructor() cil managed + { + // Code size 41 (0x29) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: ldloca.s V_0 + IL_0007: ldc.i4.0 + IL_0008: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::.ctor(int32) + IL_000d: ldloca.s V_0 + IL_000f: ldc.i4.1 + IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0015: ldloca.s V_0 + IL_0017: ldc.i4.2 + IL_0018: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_001d: ldloc.0 + IL_001e: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0023: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0028: ret + } // end of method InitializerTests::StructInitializer_ExplicitConstructor + + .method public hidebysig static void StructInitializerWithInitializationOfNestedObjects() cil managed + { + // Code size 74 (0x4a) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: ldloca.s V_0 + IL_0007: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_000d: ldloca.s V_0 + IL_000f: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + IL_0014: ldc.i4.0 + IL_0015: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_001a: ldloca.s V_0 + IL_001c: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + IL_0021: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0026: ldc.i4.0 + IL_0027: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002c: ldloca.s V_0 + IL_002e: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + IL_0033: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0038: ldc.i4.1 + IL_0039: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_003e: ldloc.0 + IL_003f: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0044: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0049: ret + } // end of method InitializerTests::StructInitializerWithInitializationOfNestedObjects + + .method public hidebysig static void StructInitializerWithinObjectInitializer() cil managed + { + // Code size 47 (0x2f) + .maxstack 5 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0005: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000a: dup + IL_000b: ldloca.s V_0 + IL_000d: ldc.i4.2 + IL_000e: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::.ctor(int32) + IL_0013: ldloca.s V_0 + IL_0015: ldc.i4.1 + IL_0016: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_001b: ldloca.s V_0 + IL_001d: ldc.i4.2 + IL_001e: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0023: ldloc.0 + IL_0024: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_NestedStruct(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData) + IL_0029: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002e: ret + } // end of method InitializerTests::StructInitializerWithinObjectInitializer + + .method public hidebysig static void Bug270_NestedInitialisers() cil managed + { + // Code size 115 (0x73) + .maxstack 8 + .locals init (class [mscorlib]System.Globalization.NumberFormatInfo[] V_0) + IL_0000: ldnull + IL_0001: stloc.0 + IL_0002: ldc.i4.0 + IL_0003: ldnull + IL_0004: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Bug270_NestedInitialisers() + IL_000a: newobj instance void [mscorlib]System.Threading.ThreadStart::.ctor(object, + native int) + IL_000f: newobj instance void [mscorlib]System.Threading.Thread::.ctor(class [mscorlib]System.Threading.ThreadStart) + IL_0014: dup + IL_0015: ldc.i4.1 + IL_0016: callvirt instance void [mscorlib]System.Threading.Thread::set_Priority(valuetype [mscorlib]System.Threading.ThreadPriority) + IL_001b: dup + IL_001c: ldc.i4.0 + IL_001d: newobj instance void [mscorlib]System.Globalization.CultureInfo::.ctor(int32) + IL_0022: dup + IL_0023: newobj instance void [mscorlib]System.Globalization.DateTimeFormatInfo::.ctor() + IL_0028: dup + IL_0029: ldstr "ddmmyy" + IL_002e: callvirt instance void [mscorlib]System.Globalization.DateTimeFormatInfo::set_ShortDatePattern(string) + 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_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_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_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) + IL_0063: callvirt instance void [mscorlib]System.Globalization.CultureInfo::set_NumberFormat(class [mscorlib]System.Globalization.NumberFormatInfo) + IL_0068: callvirt instance void [mscorlib]System.Threading.Thread::set_CurrentCulture(class [mscorlib]System.Globalization.CultureInfo) + IL_006d: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32, + class [mscorlib]System.Threading.Thread) + IL_0072: ret + } // end of method InitializerTests::Bug270_NestedInitialisers + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method InitializerTests::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il new file mode 100644 index 000000000..69b897be6 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.roslyn.il @@ -0,0 +1,1533 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly extern System.Core +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly InitializerTests +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + // --- The following custom attribute is added automatically, do not uncomment ------- + // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 ) + + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module InitializerTests.dll +// MVID: {764AEFFE-E491-413B-876B-B40EBE774D84} +.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 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests + extends [mscorlib]System.Object +{ + .class auto ansi nested public beforefieldinit C + extends [mscorlib]System.Object + { + .field public int32 Z + .field public valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S Y + .field public class [mscorlib]System.Collections.Generic.List`1 L + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method C::.ctor + + } // end of class C + + .class sequential ansi sealed nested public beforefieldinit S + extends [mscorlib]System.ValueType + { + .field public int32 A + .field public int32 B + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 a) cil managed + { + // Code size 16 (0x10) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_0008: ldarg.0 + IL_0009: ldc.i4.0 + IL_000a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B + IL_000f: ret + } // end of method S::.ctor + + } // end of class S + + .class auto ansi sealed nested private MyEnum + extends [mscorlib]System.Enum + { + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum a = int32(0x00000000) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum b = int32(0x00000001) + } // end of class MyEnum + + .class auto ansi sealed nested private MyEnum2 + extends [mscorlib]System.Enum + { + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum2 c = int32(0x00000000) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum2 d = int32(0x00000001) + } // end of class MyEnum2 + + .class auto ansi nested private beforefieldinit Data + extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.Reflection.DefaultMemberAttribute::.ctor(string) = ( 01 00 04 49 74 65 6D 00 00 ) // ...Item.. + .field public class [mscorlib]System.Collections.Generic.List`1 FieldList + .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field private class [mscorlib]System.Collections.Generic.List`1 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field private class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field private class [mscorlib]System.EventHandler TestEvent + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .method public hidebysig specialname + instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + get_a() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_a + + .method public hidebysig specialname + instance void set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_a + + .method public hidebysig specialname + instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + get_b() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_b + + .method public hidebysig specialname + instance void set_b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_b + + .method public hidebysig specialname + instance class [mscorlib]System.Collections.Generic.List`1 + get_PropertyList() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_PropertyList + + .method public hidebysig specialname + instance void set_PropertyList(class [mscorlib]System.Collections.Generic.List`1 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_PropertyList + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_MoreData() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_MoreData + + .method public hidebysig specialname + instance void set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_MoreData + + .method public hidebysig specialname + instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + get_NestedStruct() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0006: ret + } // end of method Data::get_NestedStruct + + .method public hidebysig specialname + instance void set_NestedStruct(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::'k__BackingField' + IL_0007: ret + } // end of method Data::set_NestedStruct + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_Item(int32 i) cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method Data::get_Item + + .method public hidebysig specialname + instance void set_Item(int32 i, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method Data::set_Item + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_Item(int32 i, + string j) cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method Data::get_Item + + .method public hidebysig specialname + instance void set_Item(int32 i, + string j, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method Data::set_Item + + .method public hidebysig specialname + instance void add_TestEvent(class [mscorlib]System.EventHandler 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 41 (0x29) + .maxstack 3 + .locals init (class [mscorlib]System.EventHandler V_0, + class [mscorlib]System.EventHandler V_1, + class [mscorlib]System.EventHandler V_2) + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: ldarg.1 + IL_000b: call class [mscorlib]System.Delegate [mscorlib]System.Delegate::Combine(class [mscorlib]System.Delegate, + class [mscorlib]System.Delegate) + IL_0010: castclass [mscorlib]System.EventHandler + IL_0015: stloc.2 + IL_0016: ldarg.0 + IL_0017: ldflda class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_001c: ldloc.2 + IL_001d: ldloc.1 + IL_001e: call !!0 [mscorlib]System.Threading.Interlocked::CompareExchange(!!0&, + !!0, + !!0) + IL_0023: stloc.0 + IL_0024: ldloc.0 + IL_0025: ldloc.1 + IL_0026: bne.un.s IL_0007 + + IL_0028: ret + } // end of method Data::add_TestEvent + + .method public hidebysig specialname + instance void remove_TestEvent(class [mscorlib]System.EventHandler 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 41 (0x29) + .maxstack 3 + .locals init (class [mscorlib]System.EventHandler V_0, + class [mscorlib]System.EventHandler V_1, + class [mscorlib]System.EventHandler V_2) + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: ldarg.1 + IL_000b: call class [mscorlib]System.Delegate [mscorlib]System.Delegate::Remove(class [mscorlib]System.Delegate, + class [mscorlib]System.Delegate) + IL_0010: castclass [mscorlib]System.EventHandler + IL_0015: stloc.2 + IL_0016: ldarg.0 + IL_0017: ldflda class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::TestEvent + IL_001c: ldloc.2 + IL_001d: ldloc.1 + IL_001e: call !!0 [mscorlib]System.Threading.Interlocked::CompareExchange(!!0&, + !!0, + !!0) + IL_0023: stloc.0 + IL_0024: ldloc.0 + IL_0025: ldloc.1 + IL_0026: bne.un.s IL_0007 + + IL_0028: ret + } // end of method Data::remove_TestEvent + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 19 (0x13) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0006: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_000b: ldarg.0 + IL_000c: call instance void [mscorlib]System.Object::.ctor() + IL_0011: nop + IL_0012: ret + } // end of method Data::.ctor + + .event [mscorlib]System.EventHandler TestEvent + { + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::add_TestEvent(class [mscorlib]System.EventHandler) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::remove_TestEvent(class [mscorlib]System.EventHandler) + } // end of event Data::TestEvent + .property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + a() + { + .get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_a() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + } // end of property Data::a + .property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum + b() + { + .get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_b() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + } // end of property Data::b + .property instance class [mscorlib]System.Collections.Generic.List`1 + PropertyList() + { + .get instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_PropertyList(class [mscorlib]System.Collections.Generic.List`1) + } // end of property Data::PropertyList + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + MoreData() + { + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + } // end of property Data::MoreData + .property instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + NestedStruct() + { + .get instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_NestedStruct() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_NestedStruct(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData) + } // end of property Data::NestedStruct + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + Item(int32) + { + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32) + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + } // end of property Data::Item + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + Item(int32, + string) + { + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32, + string) + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + string, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + } // end of property Data::Item + } // end of class Data + + .class sequential ansi sealed nested private beforefieldinit StructData + extends [mscorlib]System.ValueType + { + .field public int32 Field + .field private int32 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field private class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .method public hidebysig specialname + instance int32 get_Property() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0006: ret + } // end of method StructData::get_Property + + .method public hidebysig specialname + instance void set_Property(int32 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0007: ret + } // end of method StructData::set_Property + + .method public hidebysig specialname + instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + get_MoreData() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0006: ret + } // end of method StructData::get_MoreData + + .method public hidebysig specialname + instance void set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::'k__BackingField' + IL_0007: ret + } // end of method StructData::set_MoreData + + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 initialValue) cil managed + { + // Code size 24 (0x18) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_000f: ldarg.0 + IL_0010: ldarg.1 + IL_0011: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0016: nop + IL_0017: ret + } // end of method StructData::.ctor + + .property instance int32 Property() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_Property() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + } // end of property StructData::Property + .property instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data + MoreData() + { + .get instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + } // end of property StructData::MoreData + } // end of class StructData + + .class auto ansi serializable sealed nested private beforefieldinit '<>c' + extends [mscorlib]System.Object + { + .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' + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 11 (0xb) + .maxstack 8 + IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::.ctor() + IL_0005: stsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9' + IL_000a: ret + } // end of method '<>c'::.cctor + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::.ctor + + .method assembly hidebysig instance void + 'b__23_0'(object sender, + class [mscorlib]System.EventArgs e) cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: call void [mscorlib]System.Console::WriteLine() + IL_0005: nop + IL_0006: ret + } // end of method '<>c'::'b__23_0' + + .method assembly hidebysig instance bool + 'b__41_0'(class [mscorlib]System.Globalization.NumberFormatInfo format) cil managed + { + // Code size 17 (0x11) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: callvirt instance string [mscorlib]System.Globalization.NumberFormatInfo::get_CurrencySymbol() + IL_0006: ldstr "$" + IL_000b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0010: ret + } // end of method '<>c'::'b__41_0' + + } // end of class '<>c' + + .method private hidebysig static void X(object a, + object b) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method InitializerTests::X + + .method private hidebysig static object + Y() cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (object V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method InitializerTests::Y + + .method public hidebysig static void TestCall(int32 a, + class [mscorlib]System.Threading.Thread thread) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method InitializerTests::TestCall + + .method public hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + TestCall(int32 a, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C c) cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method InitializerTests::TestCall + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test1() cil managed + { + // Code size 42 (0x2a) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1) + IL_0000: nop + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000d: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L + IL_0012: ldloc.0 + IL_0013: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L + IL_0018: ldc.i4.1 + IL_0019: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32) + IL_001e: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0023: nop + IL_0024: ldloc.0 + IL_0025: stloc.1 + IL_0026: br.s IL_0028 + + IL_0028: ldloc.1 + IL_0029: ret + } // end of method InitializerTests::Test1 + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test1Alternative() cil managed + { + // Code size 41 (0x29) + .maxstack 6 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0) + IL_0000: nop + IL_0001: ldc.i4.1 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0007: dup + IL_0008: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000d: dup + IL_000e: ldc.i4.1 + IL_000f: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32) + IL_0014: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0019: nop + IL_001a: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::L + IL_001f: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C) + IL_0024: stloc.0 + IL_0025: br.s IL_0027 + + IL_0027: ldloc.0 + IL_0028: ret + } // end of method InitializerTests::Test1Alternative + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test2() cil managed + { + // Code size 27 (0x1b) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1) + IL_0000: nop + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldc.i4.1 + IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_000e: ldloc.0 + IL_000f: ldc.i4.2 + IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_0015: ldloc.0 + IL_0016: stloc.1 + IL_0017: br.s IL_0019 + + IL_0019: ldloc.1 + IL_001a: ret + } // end of method InitializerTests::Test2 + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test3() cil managed + { + // Code size 37 (0x25) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1) + IL_0000: nop + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldc.i4.1 + IL_0009: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::.ctor(int32) + IL_000e: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0013: ldloc.0 + IL_0014: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0019: ldc.i4.2 + IL_001a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_001f: ldloc.0 + IL_0020: stloc.1 + IL_0021: br.s IL_0023 + + IL_0023: ldloc.1 + IL_0024: ret + } // end of method InitializerTests::Test3 + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test3b() cil managed + { + // Code size 36 (0x24) + .maxstack 4 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0007: dup + IL_0008: ldc.i4.1 + IL_0009: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_000e: dup + IL_000f: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0014: ldc.i4.2 + IL_0015: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_001a: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C) + IL_001f: stloc.0 + IL_0020: br.s IL_0022 + + IL_0022: ldloc.0 + IL_0023: ret + } // end of method InitializerTests::Test3b + + .method public hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C + Test4() cil managed + { + // Code size 44 (0x2c) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_0, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C V_1) + IL_0000: nop + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_000d: ldc.i4.1 + IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::A + IL_0013: ldloc.0 + IL_0014: ldc.i4.2 + IL_0015: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Z + IL_001a: ldloc.0 + IL_001b: ldflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/C::Y + IL_0020: ldc.i4.3 + IL_0021: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/S::B + IL_0026: ldloc.0 + IL_0027: stloc.1 + IL_0028: br.s IL_002a + + IL_002a: ldloc.1 + IL_002b: ret + } // end of method InitializerTests::Test4 + + .method public hidebysig static void CollectionInitializerList() cil managed + { + // Code size 42 (0x2a) + .maxstack 8 + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000b: dup + IL_000c: ldc.i4.1 + IL_000d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0012: nop + IL_0013: dup + IL_0014: ldc.i4.2 + IL_0015: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001a: nop + IL_001b: dup + IL_001c: ldc.i4.3 + IL_001d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0022: nop + IL_0023: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0028: nop + IL_0029: ret + } // end of method InitializerTests::CollectionInitializerList + + .method public hidebysig static object + RecursiveCollectionInitializer() cil managed + { + // Code size 21 (0x15) + .maxstack 2 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0, + object V_1) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldloc.0 + IL_0009: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_000e: nop + IL_000f: ldloc.0 + IL_0010: stloc.1 + IL_0011: br.s IL_0013 + + IL_0013: ldloc.1 + IL_0014: ret + } // end of method InitializerTests::RecursiveCollectionInitializer + + .method public hidebysig static void CollectionInitializerDictionary() cil managed + { + // Code size 57 (0x39) + .maxstack 8 + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor() + IL_000b: dup + IL_000c: ldstr "First" + IL_0011: ldc.i4.1 + IL_0012: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0017: nop + IL_0018: dup + IL_0019: ldstr "Second" + IL_001e: ldc.i4.2 + IL_001f: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0024: nop + IL_0025: dup + IL_0026: ldstr "Third" + IL_002b: ldc.i4.3 + IL_002c: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0031: nop + IL_0032: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0037: nop + IL_0038: ret + } // end of method InitializerTests::CollectionInitializerDictionary + + .method public hidebysig static void CollectionInitializerDictionaryWithEnumTypes() cil managed + { + // Code size 36 (0x24) + .maxstack 8 + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor() + IL_000b: dup + IL_000c: ldc.i4.0 + IL_000d: ldc.i4.0 + IL_000e: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0013: nop + IL_0014: dup + IL_0015: ldc.i4.1 + IL_0016: ldc.i4.1 + IL_0017: callvirt instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_001c: nop + IL_001d: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0022: nop + IL_0023: ret + } // end of method InitializerTests::CollectionInitializerDictionaryWithEnumTypes + + .method public hidebysig static void NotACollectionInitializer() cil managed + { + // Code size 44 (0x2c) + .maxstack 2 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldc.i4.1 + IL_0009: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_000e: nop + IL_000f: ldloc.0 + IL_0010: ldc.i4.2 + IL_0011: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0016: nop + IL_0017: ldloc.0 + IL_0018: ldc.i4.3 + IL_0019: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001e: nop + IL_001f: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0024: ldloc.0 + IL_0025: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002a: nop + IL_002b: ret + } // end of method InitializerTests::NotACollectionInitializer + + .method public hidebysig static void ObjectInitializer() cil managed + { + // Code size 26 (0x1a) + .maxstack 8 + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: dup + IL_000c: ldc.i4.0 + IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0012: nop + IL_0013: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0018: nop + IL_0019: ret + } // end of method InitializerTests::ObjectInitializer + + .method public hidebysig static void NotAnObjectInitializer() cil managed + { + // Code size 28 (0x1c) + .maxstack 2 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldc.i4.0 + IL_0009: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_000e: nop + IL_000f: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0014: ldloc.0 + IL_0015: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_001a: nop + IL_001b: ret + } // end of method InitializerTests::NotAnObjectInitializer + + .method public hidebysig static void NotAnObjectInitializerWithEvent() cil managed + { + // Code size 58 (0x3a) + .maxstack 3 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data V_0) + IL_0000: nop + IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9__23_0' + IL_000d: dup + IL_000e: brtrue.s IL_0027 + + IL_0010: pop + IL_0011: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9' + IL_0016: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'b__23_0'(object, + class [mscorlib]System.EventArgs) + IL_001c: newobj instance void [mscorlib]System.EventHandler::.ctor(object, + native int) + IL_0021: dup + IL_0022: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/'<>c'::'<>9__23_0' + IL_0027: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::add_TestEvent(class [mscorlib]System.EventHandler) + IL_002c: nop + IL_002d: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0032: ldloc.0 + IL_0033: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0038: nop + IL_0039: ret + } // end of method InitializerTests::NotAnObjectInitializerWithEvent + + .method public hidebysig static void ObjectInitializerAssignCollectionToField() cil managed + { + // Code size 53 (0x35) + .maxstack 8 + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: dup + IL_000c: ldc.i4.0 + IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0012: nop + IL_0013: dup + IL_0014: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0019: dup + IL_001a: ldc.i4.0 + IL_001b: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0020: nop + IL_0021: dup + IL_0022: ldc.i4.1 + IL_0023: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0028: nop + IL_0029: stfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_002e: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0033: nop + IL_0034: ret + } // end of method InitializerTests::ObjectInitializerAssignCollectionToField + + .method public hidebysig static void ObjectInitializerAddToCollectionInField() cil managed + { + // Code size 52 (0x34) + .maxstack 8 + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: dup + IL_000c: ldc.i4.0 + IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0012: nop + IL_0013: dup + IL_0014: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0019: ldc.i4.0 + IL_001a: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001f: nop + IL_0020: dup + IL_0021: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0026: ldc.i4.1 + IL_0027: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002c: nop + IL_002d: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0032: nop + IL_0033: ret + } // end of method InitializerTests::ObjectInitializerAddToCollectionInField + + .method public hidebysig static void ObjectInitializerAssignCollectionToProperty() cil managed + { + // Code size 54 (0x36) + .maxstack 8 + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: dup + IL_000c: ldc.i4.0 + IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0012: nop + IL_0013: dup + IL_0014: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0019: dup + IL_001a: ldc.i4.0 + IL_001b: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0020: nop + IL_0021: dup + IL_0022: ldc.i4.1 + IL_0023: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0028: nop + IL_0029: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_PropertyList(class [mscorlib]System.Collections.Generic.List`1) + IL_002e: nop + IL_002f: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0034: nop + IL_0035: ret + } // end of method InitializerTests::ObjectInitializerAssignCollectionToProperty + + .method public hidebysig static void ObjectInitializerAddToCollectionInProperty() cil managed + { + // Code size 52 (0x34) + .maxstack 8 + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: dup + IL_000c: ldc.i4.0 + IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0012: nop + IL_0013: dup + IL_0014: callvirt instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + IL_0019: ldc.i4.0 + IL_001a: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001f: nop + IL_0020: dup + IL_0021: callvirt instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + IL_0026: ldc.i4.1 + IL_0027: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002c: nop + IL_002d: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0032: nop + IL_0033: ret + } // end of method InitializerTests::ObjectInitializerAddToCollectionInProperty + + .method public hidebysig static void ObjectInitializerWithInitializationOfNestedObjects() cil managed + { + // Code size 49 (0x31) + .maxstack 8 + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: dup + IL_000c: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0011: ldc.i4.0 + IL_0012: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0017: nop + IL_0018: dup + IL_0019: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_001e: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0023: ldc.i4.1 + IL_0024: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0029: nop + IL_002a: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002f: nop + IL_0030: ret + } // end of method InitializerTests::ObjectInitializerWithInitializationOfNestedObjects + + .method private hidebysig static int32 + GetInt() cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (int32 V_0) + IL_0000: nop + IL_0001: ldc.i4.1 + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method InitializerTests::GetInt + + .method private hidebysig static string + GetString() cil managed + { + // Code size 11 (0xb) + .maxstack 1 + .locals init (string V_0) + IL_0000: nop + IL_0001: ldstr "Test" + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method InitializerTests::GetString + + .method public hidebysig static void SimpleDictInitializer() cil managed + { + // Code size 45 (0x2d) + .maxstack 8 + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: dup + IL_000c: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0011: ldc.i4.0 + IL_0012: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0017: nop + IL_0018: dup + IL_0019: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_001e: ldc.i4.2 + IL_001f: ldnull + IL_0020: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + IL_0025: nop + IL_0026: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002b: nop + IL_002c: ret + } // end of method InitializerTests::SimpleDictInitializer + + .method public hidebysig static void MixedObjectAndDictInitializer() cil managed + { + // Code size 137 (0x89) + .maxstack 6 + .locals init (int32 V_0, + int32 V_1, + string V_2) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: dup + IL_000c: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0011: ldc.i4.0 + IL_0012: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0017: nop + IL_0018: call int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::GetInt() + IL_001d: stloc.0 + IL_001e: dup + IL_001f: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0024: ldloc.0 + IL_0025: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32) + IL_002a: ldc.i4.1 + IL_002b: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0030: nop + IL_0031: dup + IL_0032: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0037: ldloc.0 + IL_0038: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32) + IL_003d: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0042: ldc.i4.0 + IL_0043: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0048: nop + IL_0049: call int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::GetInt() + IL_004e: stloc.1 + IL_004f: call string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::GetString() + IL_0054: stloc.2 + IL_0055: dup + IL_0056: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_005b: ldloc.0 + IL_005c: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32) + IL_0061: ldloc.1 + IL_0062: ldloc.2 + IL_0063: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0068: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + string, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + IL_006d: nop + IL_006e: dup + IL_006f: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0074: ldloc.0 + IL_0075: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_Item(int32) + IL_007a: ldc.i4.2 + IL_007b: ldnull + IL_007c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_Item(int32, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + IL_0081: nop + IL_0082: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0087: nop + IL_0088: ret + } // end of method InitializerTests::MixedObjectAndDictInitializer + + .method public hidebysig static void ObjectInitializerWithInitializationOfDeeplyNestedObjects() cil managed + { + // Code size 82 (0x52) + .maxstack 4 + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: dup + IL_000c: ldc.i4.1 + IL_000d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0012: nop + IL_0013: dup + IL_0014: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0019: ldc.i4.0 + IL_001a: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_001f: nop + IL_0020: dup + IL_0021: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0026: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_002b: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0030: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0035: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_003a: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_003f: callvirt instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_MoreData() + IL_0044: ldc.i4.1 + IL_0045: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_004a: nop + IL_004b: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0050: nop + IL_0051: ret + } // end of method InitializerTests::ObjectInitializerWithInitializationOfDeeplyNestedObjects + + .method public hidebysig static void CollectionInitializerInsideObjectInitializers() cil managed + { + // Code size 59 (0x3b) + .maxstack 8 + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: dup + IL_000c: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_0011: dup + IL_0012: ldc.i4.0 + IL_0013: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0018: nop + IL_0019: dup + IL_001a: ldc.i4.1 + IL_001b: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_0020: nop + IL_0021: dup + IL_0022: callvirt instance class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::get_PropertyList() + IL_0027: ldc.i4.0 + IL_0028: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002d: nop + IL_002e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_MoreData(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data) + IL_0033: nop + IL_0034: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0039: nop + IL_003a: ret + } // end of method InitializerTests::CollectionInitializerInsideObjectInitializers + + .method public hidebysig static void NotAStructInitializer_DefaultConstructor() cil managed + { + // Code size 44 (0x2c) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: nop + IL_0001: ldloca.s V_0 + IL_0003: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0009: ldloca.s V_0 + IL_000b: ldc.i4.1 + IL_000c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0011: ldloca.s V_0 + IL_0013: ldc.i4.2 + IL_0014: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0019: nop + IL_001a: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_001f: ldloc.0 + IL_0020: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0025: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002a: nop + IL_002b: ret + } // end of method InitializerTests::NotAStructInitializer_DefaultConstructor + + .method public hidebysig static void StructInitializer_DefaultConstructor() cil managed + { + // Code size 44 (0x2c) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: ldloca.s V_0 + IL_0008: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_000e: ldloca.s V_0 + IL_0010: ldc.i4.1 + IL_0011: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0016: ldloca.s V_0 + IL_0018: ldc.i4.2 + IL_0019: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_001e: nop + IL_001f: ldloc.0 + IL_0020: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0025: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002a: nop + IL_002b: ret + } // end of method InitializerTests::StructInitializer_DefaultConstructor + + .method public hidebysig static void NotAStructInitializer_ExplicitConstructor() cil managed + { + // Code size 44 (0x2c) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: nop + IL_0001: ldloca.s V_0 + IL_0003: ldc.i4.0 + IL_0004: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::.ctor(int32) + IL_0009: ldloca.s V_0 + IL_000b: ldc.i4.1 + IL_000c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0011: ldloca.s V_0 + IL_0013: ldc.i4.2 + IL_0014: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0019: nop + IL_001a: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_001f: ldloc.0 + IL_0020: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0025: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002a: nop + IL_002b: ret + } // end of method InitializerTests::NotAStructInitializer_ExplicitConstructor + + .method public hidebysig static void StructInitializer_ExplicitConstructor() cil managed + { + // Code size 44 (0x2c) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: ldloca.s V_0 + IL_0008: ldc.i4.0 + IL_0009: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::.ctor(int32) + IL_000e: ldloca.s V_0 + IL_0010: ldc.i4.1 + IL_0011: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_0016: ldloca.s V_0 + IL_0018: ldc.i4.2 + IL_0019: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_001e: nop + IL_001f: ldloc.0 + IL_0020: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0025: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_002a: nop + IL_002b: ret + } // end of method InitializerTests::StructInitializer_ExplicitConstructor + + .method public hidebysig static void StructInitializerWithInitializationOfNestedObjects() cil managed + { + // Code size 79 (0x4f) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: ldloca.s V_0 + IL_0008: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_000e: ldloca.s V_0 + IL_0010: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + IL_0015: ldc.i4.0 + IL_0016: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_a(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/MyEnum) + IL_001b: nop + IL_001c: ldloca.s V_0 + IL_001e: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + IL_0023: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_0028: ldc.i4.0 + IL_0029: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_002e: nop + IL_002f: ldloca.s V_0 + IL_0031: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::get_MoreData() + IL_0036: ldfld class [mscorlib]System.Collections.Generic.List`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::FieldList + IL_003b: ldc.i4.1 + IL_003c: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0041: nop + IL_0042: ldloc.0 + IL_0043: box ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData + IL_0048: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_004d: nop + IL_004e: ret + } // end of method InitializerTests::StructInitializerWithInitializationOfNestedObjects + + .method public hidebysig static void StructInitializerWithinObjectInitializer() cil managed + { + // Code size 51 (0x33) + .maxstack 5 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData V_0) + IL_0000: nop + IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Y() + IL_0006: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::.ctor() + IL_000b: dup + IL_000c: ldloca.s V_0 + IL_000e: ldc.i4.2 + IL_000f: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::.ctor(int32) + IL_0014: ldloca.s V_0 + IL_0016: ldc.i4.1 + IL_0017: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::Field + IL_001c: ldloca.s V_0 + IL_001e: ldc.i4.2 + IL_001f: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData::set_Property(int32) + IL_0024: nop + IL_0025: ldloc.0 + IL_0026: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/Data::set_NestedStruct(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests/StructData) + IL_002b: nop + IL_002c: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::X(object, + object) + IL_0031: nop + IL_0032: ret + } // end of method InitializerTests::StructInitializerWithinObjectInitializer + + .method public hidebysig static void Bug270_NestedInitialisers() cil managed + { + // Code size 122 (0x7a) + .maxstack 8 + .locals init (class [mscorlib]System.Globalization.NumberFormatInfo[] V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: stloc.0 + IL_0003: ldc.i4.0 + IL_0004: ldnull + IL_0005: ldftn void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::Bug270_NestedInitialisers() + IL_000b: newobj instance void [mscorlib]System.Threading.ThreadStart::.ctor(object, + native int) + IL_0010: newobj instance void [mscorlib]System.Threading.Thread::.ctor(class [mscorlib]System.Threading.ThreadStart) + IL_0015: dup + IL_0016: ldc.i4.1 + IL_0017: callvirt instance void [mscorlib]System.Threading.Thread::set_Priority(valuetype [mscorlib]System.Threading.ThreadPriority) + IL_001c: nop + IL_001d: dup + IL_001e: ldc.i4.0 + IL_001f: newobj instance void [mscorlib]System.Globalization.CultureInfo::.ctor(int32) + IL_0024: dup + IL_0025: newobj instance void [mscorlib]System.Globalization.DateTimeFormatInfo::.ctor() + IL_002a: dup + IL_002b: ldstr "ddmmyy" + IL_0030: callvirt instance void [mscorlib]System.Globalization.DateTimeFormatInfo::set_ShortDatePattern(string) + IL_0035: nop + IL_0036: callvirt instance void [mscorlib]System.Globalization.CultureInfo::set_DateTimeFormat(class [mscorlib]System.Globalization.DateTimeFormatInfo) + 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_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_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_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) + IL_0067: callvirt instance void [mscorlib]System.Globalization.CultureInfo::set_NumberFormat(class [mscorlib]System.Globalization.NumberFormatInfo) + IL_006c: nop + IL_006d: callvirt instance void [mscorlib]System.Threading.Thread::set_CurrentCulture(class [mscorlib]System.Globalization.CultureInfo) + IL_0072: nop + IL_0073: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests::TestCall(int32, + class [mscorlib]System.Threading.Thread) + IL_0078: nop + IL_0079: ret + } // end of method InitializerTests::Bug270_NestedInitialisers + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method InitializerTests::.ctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs index c6326520d..8345eaf1c 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs @@ -252,6 +252,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty } } + private IEnumerable alternatives; + private static void Operation(ref int item) { } @@ -260,10 +262,17 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty { } - public void ForEach(IEnumerable enumerable) + public void ForEachOnField() { - foreach (string item in enumerable) { - item.ToLower(); + foreach (string alternative in this.alternatives) { + alternative.ToLower(); + } + } + + public void ForEach(IEnumerable alternatives) + { + foreach (string alternative in alternatives) { + alternative.ToLower(); } } @@ -388,7 +397,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty { foreach (int item in items) { int c = item; - Loops.Operation((Func)(() => c == 5)); + Loops.Operation(() => c == 5); } } diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.il index ad08c43b3..030f6bd46 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.il @@ -1,6 +1,6 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17929 -// Copyright (c) Microsoft Corporation. All rights reserved. +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. @@ -10,7 +10,7 @@ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 4:0:0:0 } -.assembly y5enlto2 +.assembly ic2bztjj { .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 @@ -20,15 +20,15 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 } -.module y5enlto2.dll -// MVID: {7F6CCF81-BE23-4326-8F55-7E3BF0A8B7A2} +.module ic2bztjj.dll +// MVID: {821665CB-F67F-4600-8C6C-27617D873D36} .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: 0x009B0000 +// Image base: 0x01550000 // =============== CLASS MEMBERS DECLARATION =================== @@ -618,6 +618,7 @@ } // end of class '<>c__DisplayClass1' + .field private class [mscorlib]System.Collections.Generic.IEnumerable`1 alternatives .method private hidebysig static void Operation(int32& item) cil managed { // Code size 2 (0x2) @@ -635,7 +636,60 @@ } // end of method Loops::Operation .method public hidebysig instance void - ForEach(class [mscorlib]System.Collections.Generic.IEnumerable`1 enumerable) cil managed + ForEachOnField() cil managed + { + // Code size 62 (0x3e) + .maxstack 2 + .locals init (string V_0, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_1, + bool V_2) + IL_0000: nop + IL_0001: nop + IL_0002: ldarg.0 + IL_0003: ldfld class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::alternatives + IL_0008: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_000d: stloc.1 + .try + { + IL_000e: br.s IL_0020 + + IL_0010: ldloc.1 + IL_0011: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0016: stloc.0 + IL_0017: nop + IL_0018: ldloc.0 + IL_0019: callvirt instance string [mscorlib]System.String::ToLower() + IL_001e: pop + IL_001f: nop + IL_0020: ldloc.1 + IL_0021: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() + IL_0026: stloc.2 + IL_0027: ldloc.2 + IL_0028: brtrue.s IL_0010 + + IL_002a: leave.s IL_003c + + } // end .try + finally + { + IL_002c: ldloc.1 + IL_002d: ldnull + IL_002e: ceq + IL_0030: stloc.2 + IL_0031: ldloc.2 + IL_0032: brtrue.s IL_003b + + IL_0034: ldloc.1 + IL_0035: callvirt instance void [mscorlib]System.IDisposable::Dispose() + IL_003a: nop + IL_003b: endfinally + } // end handler + IL_003c: nop + IL_003d: ret + } // end of method Loops::ForEachOnField + + .method public hidebysig instance void + ForEach(class [mscorlib]System.Collections.Generic.IEnumerable`1 alternatives) cil managed { // Code size 57 (0x39) .maxstack 2 @@ -1750,4 +1804,4 @@ // ============================================================= // *********** DISASSEMBLY COMPLETE *********************** -// WARNING: Created Win32 resource file ../../../TestCases/Pretty\Loops.res +// Warnung: Win32-Ressourcendatei "../../../TestCases/Pretty\Loops.res" wurde erstellt. diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.il index a1e2ed464..50a8785a7 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.il @@ -1,6 +1,6 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17929 -// Copyright (c) Microsoft Corporation. All rights reserved. +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. @@ -10,7 +10,7 @@ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 4:0:0:0 } -.assembly jiaqp12i +.assembly fabjeeha { .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 @@ -20,15 +20,15 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 } -.module jiaqp12i.dll -// MVID: {34208704-52B8-49EB-BC77-C3A95E1CBA19} +.module fabjeeha.dll +// MVID: {4FB3AE1F-ECE0-4E7D-84DC-E693282CA0AF} .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: 0x02520000 +// Image base: 0x00D90000 // =============== CLASS MEMBERS DECLARATION =================== @@ -535,6 +535,7 @@ } // end of class '<>c__DisplayClass1' + .field private class [mscorlib]System.Collections.Generic.IEnumerable`1 alternatives .method private hidebysig static void Operation(int32& item) cil managed { // Code size 1 (0x1) @@ -550,7 +551,47 @@ } // end of method Loops::Operation .method public hidebysig instance void - ForEach(class [mscorlib]System.Collections.Generic.IEnumerable`1 enumerable) cil managed + ForEachOnField() cil managed + { + // Code size 49 (0x31) + .maxstack 1 + .locals init (string V_0, + class [mscorlib]System.Collections.Generic.IEnumerator`1 V_1) + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::alternatives + IL_0006: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_000b: stloc.1 + .try + { + IL_000c: br.s IL_001c + + IL_000e: ldloc.1 + IL_000f: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0014: stloc.0 + IL_0015: ldloc.0 + IL_0016: callvirt instance string [mscorlib]System.String::ToLower() + IL_001b: pop + IL_001c: ldloc.1 + IL_001d: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() + IL_0022: brtrue.s IL_000e + + IL_0024: leave.s IL_0030 + + } // end .try + finally + { + IL_0026: ldloc.1 + IL_0027: brfalse.s IL_002f + + IL_0029: ldloc.1 + IL_002a: callvirt instance void [mscorlib]System.IDisposable::Dispose() + IL_002f: endfinally + } // end handler + IL_0030: ret + } // end of method Loops::ForEachOnField + + .method public hidebysig instance void + ForEach(class [mscorlib]System.Collections.Generic.IEnumerable`1 alternatives) cil managed { // Code size 44 (0x2c) .maxstack 1 @@ -1361,4 +1402,4 @@ // ============================================================= // *********** DISASSEMBLY COMPLETE *********************** -// WARNING: Created Win32 resource file ../../../TestCases/Pretty\Loops.opt.res +// Warnung: Win32-Ressourcendatei "../../../TestCases/Pretty\Loops.opt.res" wurde erstellt. diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.roslyn.il index a3b169382..8fc3ae3c4 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.opt.roslyn.il @@ -1,6 +1,6 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17929 -// Copyright (c) Microsoft Corporation. All rights reserved. +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. @@ -25,14 +25,14 @@ .ver 0:0:0:0 } .module Loops.dll -// MVID: {8D392B4A-5D21-407A-B579-FCDFA93069CE} +// MVID: {F03B196B-9B00-49BE-A335-2D460586E39A} .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: 0x00DA0000 +// Image base: 0x02D60000 // =============== CLASS MEMBERS DECLARATION =================== @@ -510,7 +510,7 @@ } // end of property CustomStructEnumeratorWithIDisposable`1::Current } // end of class CustomStructEnumeratorWithIDisposable`1 - .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass23_0' + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass25_0' extends [mscorlib]System.Object { .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -523,7 +523,7 @@ IL_0000: ldarg.0 IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0006: ret - } // end of method '<>c__DisplayClass23_0'::.ctor + } // end of method '<>c__DisplayClass25_0'::.ctor .method assembly hidebysig instance bool 'b__0'() cil managed @@ -531,14 +531,15 @@ // Code size 10 (0xa) .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass23_0'::c + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass25_0'::c IL_0006: ldc.i4.5 IL_0007: ceq IL_0009: ret - } // end of method '<>c__DisplayClass23_0'::'b__0' + } // end of method '<>c__DisplayClass25_0'::'b__0' - } // end of class '<>c__DisplayClass23_0' + } // end of class '<>c__DisplayClass25_0' + .field private class [mscorlib]System.Collections.Generic.IEnumerable`1 alternatives .method private hidebysig static void Operation(int32& item) cil managed { // Code size 1 (0x1) @@ -554,7 +555,44 @@ } // end of method Loops::Operation .method public hidebysig instance void - ForEach(class [mscorlib]System.Collections.Generic.IEnumerable`1 enumerable) cil managed + ForEachOnField() cil managed + { + // Code size 47 (0x2f) + .maxstack 1 + .locals init (class [mscorlib]System.Collections.Generic.IEnumerator`1 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::alternatives + IL_0006: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_000b: stloc.0 + .try + { + IL_000c: br.s IL_001a + + IL_000e: ldloc.0 + IL_000f: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0014: callvirt instance string [mscorlib]System.String::ToLower() + IL_0019: pop + IL_001a: ldloc.0 + IL_001b: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000e + + IL_0022: leave.s IL_002e + + } // end .try + finally + { + IL_0024: ldloc.0 + IL_0025: brfalse.s IL_002d + + IL_0027: ldloc.0 + IL_0028: callvirt instance void [mscorlib]System.IDisposable::Dispose() + IL_002d: endfinally + } // end handler + IL_002e: ret + } // end of method Loops::ForEachOnField + + .method public hidebysig instance void + ForEach(class [mscorlib]System.Collections.Generic.IEnumerable`1 alternatives) cil managed { // Code size 42 (0x2a) .maxstack 1 @@ -1063,11 +1101,11 @@ IL_0009: ldloca.s V_0 IL_000b: call instance !0 valuetype [mscorlib]System.Collections.Generic.List`1/Enumerator::get_Current() IL_0010: stloc.1 - IL_0011: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass23_0'::.ctor() + IL_0011: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass25_0'::.ctor() IL_0016: dup IL_0017: ldloc.1 - IL_0018: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass23_0'::c - IL_001d: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass23_0'::'b__0'() + IL_0018: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass25_0'::c + IL_001d: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass25_0'::'b__0'() IL_0023: newobj instance void class [mscorlib]System.Func`1::.ctor(object, native int) IL_0028: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Operation(class [mscorlib]System.Func`1) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.roslyn.il index 864b1e5c5..f10e2f5ff 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.roslyn.il @@ -1,6 +1,6 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17929 -// Copyright (c) Microsoft Corporation. All rights reserved. +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. @@ -25,14 +25,14 @@ .ver 0:0:0:0 } .module Loops.dll -// MVID: {C6DBFA5B-CB31-4084-8E6F-7BA877923008} +// MVID: {F66BA703-8DC0-4A56-81BC-D288A1D83D30} .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: 0x00A80000 +// Image base: 0x02D60000 // =============== CLASS MEMBERS DECLARATION =================== @@ -592,7 +592,7 @@ } // end of property CustomStructEnumeratorWithIDisposable`1::Current } // end of class CustomStructEnumeratorWithIDisposable`1 - .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass23_0' + .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass25_0' extends [mscorlib]System.Object { .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -606,7 +606,7 @@ IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0006: nop IL_0007: ret - } // end of method '<>c__DisplayClass23_0'::.ctor + } // end of method '<>c__DisplayClass25_0'::.ctor .method assembly hidebysig instance bool 'b__0'() cil managed @@ -614,14 +614,15 @@ // Code size 10 (0xa) .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass23_0'::c + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass25_0'::c IL_0006: ldc.i4.5 IL_0007: ceq IL_0009: ret - } // end of method '<>c__DisplayClass23_0'::'b__0' + } // end of method '<>c__DisplayClass25_0'::'b__0' - } // end of class '<>c__DisplayClass23_0' + } // end of class '<>c__DisplayClass25_0' + .field private class [mscorlib]System.Collections.Generic.IEnumerable`1 alternatives .method private hidebysig static void Operation(int32& item) cil managed { // Code size 2 (0x2) @@ -639,7 +640,52 @@ } // end of method Loops::Operation .method public hidebysig instance void - ForEach(class [mscorlib]System.Collections.Generic.IEnumerable`1 enumerable) cil managed + ForEachOnField() cil managed + { + // Code size 54 (0x36) + .maxstack 1 + .locals init (class [mscorlib]System.Collections.Generic.IEnumerator`1 V_0, + string V_1) + IL_0000: nop + IL_0001: nop + IL_0002: ldarg.0 + IL_0003: ldfld class [mscorlib]System.Collections.Generic.IEnumerable`1 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::alternatives + IL_0008: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1 class [mscorlib]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_000d: stloc.0 + .try + { + IL_000e: br.s IL_0020 + + IL_0010: ldloc.0 + IL_0011: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0016: stloc.1 + IL_0017: nop + IL_0018: ldloc.1 + IL_0019: callvirt instance string [mscorlib]System.String::ToLower() + IL_001e: pop + IL_001f: nop + IL_0020: ldloc.0 + IL_0021: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() + IL_0026: brtrue.s IL_0010 + + IL_0028: leave.s IL_0035 + + } // end .try + finally + { + IL_002a: ldloc.0 + IL_002b: brfalse.s IL_0034 + + IL_002d: ldloc.0 + IL_002e: callvirt instance void [mscorlib]System.IDisposable::Dispose() + IL_0033: nop + IL_0034: endfinally + } // end handler + IL_0035: ret + } // end of method Loops::ForEachOnField + + .method public hidebysig instance void + ForEach(class [mscorlib]System.Collections.Generic.IEnumerable`1 alternatives) cil managed { // Code size 49 (0x31) .maxstack 1 @@ -1259,7 +1305,7 @@ .maxstack 2 .locals init (valuetype [mscorlib]System.Collections.Generic.List`1/Enumerator V_0, int32 V_1, - class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass23_0' V_2) + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass25_0' V_2) IL_0000: nop IL_0001: nop IL_0002: ldarg.0 @@ -1272,14 +1318,14 @@ IL_000b: ldloca.s V_0 IL_000d: call instance !0 valuetype [mscorlib]System.Collections.Generic.List`1/Enumerator::get_Current() IL_0012: stloc.1 - IL_0013: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass23_0'::.ctor() + IL_0013: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass25_0'::.ctor() IL_0018: stloc.2 IL_0019: nop IL_001a: ldloc.2 IL_001b: ldloc.1 - IL_001c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass23_0'::c + IL_001c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass25_0'::c IL_0021: ldloc.2 - IL_0022: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass23_0'::'b__0'() + IL_0022: ldftn instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops/'<>c__DisplayClass25_0'::'b__0'() IL_0028: newobj instance void class [mscorlib]System.Func`1::.ctor(object, native int) IL_002d: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Loops::Operation(class [mscorlib]System.Func`1) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs index e08a8b8fd..3da7eada2 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs @@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public event EventHandler AutomaticEvent; [field: NonSerialized] - public event EventHandler AutomaticEventWithInitializer = (EventHandler)delegate(object sender, EventArgs e) { + public event EventHandler AutomaticEventWithInitializer = delegate(object sender, EventArgs e) { }; public event EventHandler CustomEvent { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs index ba9ca3afe..32a91494f 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs @@ -111,7 +111,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public object FromLetWhereSelect() { return from o in this.orders - let t = o.Details.Sum((Func)((OrderDetail d) => d.UnitPrice * d.Quantity)) + let t = o.Details.Sum((OrderDetail d) => d.UnitPrice * d.Quantity) where t >= 1000m select new { OrderID = o.OrderID, diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs new file mode 100644 index 000000000..0b118981a --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs @@ -0,0 +1,450 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty +{ + public static class Switch + { + public class SetProperty + { + public readonly PropertyInfo Property; + + public int Set { + get; + set; + } + + public SetProperty(PropertyInfo property) + { + this.Property = property; + } + } + + public enum State + { + False = 0, + True = 1, + Null = 2 + } + + public static State SwitchOverNullableBool(bool? value) + { + switch (value) { + case false: + return State.False; + case true: + return State.True; + case null: + return State.Null; + default: + throw new InvalidOperationException(); + } + } + + public static bool? SwitchOverNullableEnum(State? state) + { + switch (state) { + case State.False: + return false; + case State.True: + return true; + case State.Null: + return null; + default: + throw new InvalidOperationException(); + } + } + + public static string SparseIntegerSwitch(int i) + { + Console.WriteLine("SparseIntegerSwitch: " + i); + switch (i) { + case -10000000: + return "-10 mln"; + case -100: + return "-hundred"; + case -1: + return "-1"; + case 0: + return "0"; + case 1: + return "1"; + case 2: + return "2"; + case 4: + return "4"; + case 100: + return "hundred"; + case 10000: + return "ten thousand"; + case 10001: + return "ten thousand and one"; + case 2147483647: + return "int.MaxValue"; + default: + return "something else"; + } + } + + public static string SwitchOverNullableInt(int? i) + { + switch (i) { + case null: + return "null"; + case 0: + return "zero"; + case 5: + return "five"; + case 10: + return "ten"; + default: + return "large"; + } + } + + public static string SwitchOverNullableIntNullCaseCombined(int? i) + { + switch (i) { + case null: + case 0: + return "zero"; + case 5: + return "five"; + case 10: + return "ten"; + default: + return "large"; + } + } + + public static string SwitchOverNullableIntShifted(int? i) + { + switch (i + 5) { + case null: + return "null"; + case 0: + return "zero"; + case 5: + return "five"; + case 10: + return "ten"; + default: + return "large"; + } + } + + public static string SwitchOverNullableIntShiftedNullCaseCombined(int? i) + { + switch (i + 5) { + case null: + case 0: + return "zero"; + case 5: + return "five"; + case 10: + return "ten"; + default: + return "large"; + } + } + + public static string SwitchOverNullableIntNoNullCase(int? i) + { + switch (i) { + case 0: + return "zero"; + case 5: + return "five"; + case 10: + return "ten"; + default: + return "other"; + } + } + + public static string SwitchOverNullableIntNoNullCaseShifted(int? i) + { + switch (i + 5) { + case 0: + return "zero"; + case 5: + return "five"; + case 10: + return "ten"; + default: + return "other"; + } + } + + public static void SwitchOverInt(int i) + { + switch (i) { + case 0: + Console.WriteLine("zero"); + break; + case 5: + Console.WriteLine("five"); + break; + case 10: + Console.WriteLine("ten"); + break; + case 15: + Console.WriteLine("fifteen"); + break; + case 20: + Console.WriteLine("twenty"); + break; + case 25: + Console.WriteLine("twenty-five"); + break; + case 30: + Console.WriteLine("thirty"); + break; + } + } + + public static string ShortSwitchOverString(string text) + { + Console.WriteLine("ShortSwitchOverString: " + text); + switch (text) { + case "First case": + return "Text1"; + case "Second case": + return "Text2"; + case "Third case": + return "Text3"; + default: + return "Default"; + } + } + + public static string ShortSwitchOverStringWithNullCase(string text) + { + Console.WriteLine("ShortSwitchOverStringWithNullCase: " + text); + switch (text) { + case "First case": + return "Text1"; + case "Second case": + return "Text2"; + case null: + return "null"; + default: + return "Default"; + } + } + + public static string SwitchOverString1(string text) + { + Console.WriteLine("SwitchOverString1: " + text); + switch (text) { + case "First case": + return "Text1"; + case "Second case": + case "2nd case": + return "Text2"; + case "Third case": + return "Text3"; + case "Fourth case": + return "Text4"; + case "Fifth case": + return "Text5"; + case "Sixth case": + return "Text6"; + case null: + return null; + default: + return "Default"; + } + } + + public static string SwitchOverString2() + { + Console.WriteLine("SwitchOverString2:"); + switch (Environment.UserName) { + case "First case": + return "Text1"; + case "Second case": + return "Text2"; + case "Third case": + return "Text3"; + case "Fourth case": + return "Text4"; + case "Fifth case": + return "Text5"; + case "Sixth case": + return "Text6"; + case "Seventh case": + return "Text7"; + case "Eighth case": + return "Text8"; + case "Ninth case": + return "Text9"; + case "Tenth case": + return "Text10"; + case "Eleventh case": + return "Text11"; + default: + return "Default"; + } + } + + public static string SwitchOverBool(bool b) + { + Console.WriteLine("SwitchOverBool: " + b.ToString()); + switch (b) { + case true: + return bool.TrueString; + case false: + return bool.FalseString; + default: + return null; + } + } + + public static void SwitchInLoop(int i) + { + Console.WriteLine("SwitchInLoop: " + i); + while (true) { + switch (i) { + case 1: + Console.WriteLine("one"); + break; + case 2: + Console.WriteLine("two"); + break; + //case 3: + // Console.WriteLine("three"); + // continue; + case 4: + Console.WriteLine("four"); + return; + default: + Console.WriteLine("default"); + Console.WriteLine("more code"); + return; + } + i++; + } + } + + public static void SwitchWithGoto(int i) + { + Console.WriteLine("SwitchWithGoto: " + i); + switch (i) { + case 1: + Console.WriteLine("one"); + goto default; + case 2: + Console.WriteLine("two"); + goto case 3; + case 3: + Console.WriteLine("three"); + break; + case 4: + Console.WriteLine("four"); + return; + default: + Console.WriteLine("default"); + break; + } + Console.WriteLine("End of method"); + } + + private static SetProperty[] GetProperties() + { + return new SetProperty[0]; + } + + public static void SwitchOnStringInForLoop() + { + List list = new List(); + List list2 = new List(); + SetProperty[] properties = Switch.GetProperties(); + for (int i = 0; i < properties.Length; i++) { + SetProperty setProperty = properties[i]; + switch (setProperty.Property.Name) { + case "Name1": + setProperty.Set = 1; + list.Add(setProperty); + break; + case "Name2": + setProperty.Set = 2; + list.Add(setProperty); + break; + case "Name3": + setProperty.Set = 3; + list.Add(setProperty); + break; + case "Name4": + setProperty.Set = 4; + list.Add(setProperty); + break; + case "Name5": + case "Name6": + list.Add(setProperty); + break; + default: + list2.Add(setProperty); + break; + } + } + } + + public static void SwitchWithComplexCondition(string[] args) + { + switch ((args.Length == 0) ? "dummy" : args[0]) { + case "a": + Console.WriteLine("a"); + break; + case "b": + Console.WriteLine("b"); + break; + case "c": + Console.WriteLine("c"); + break; + case "d": + Console.WriteLine("d"); + break; + } + Console.WriteLine("end"); + } + + public static void SwitchWithArray(string[] args) + { + switch (args[0]) { + case "a": + Console.WriteLine("a"); + break; + case "b": + Console.WriteLine("b"); + break; + case "c": + Console.WriteLine("c"); + break; + case "d": + Console.WriteLine("d"); + break; + } + Console.WriteLine("end"); + } + } +} \ No newline at end of file diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.il new file mode 100644 index 000000000..9db363234 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.il @@ -0,0 +1,1624 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly o03zflju +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module o03zflju.dll +// MVID: {0EF64C57-A49E-4138-9C3F-BDAB86B2E450} +.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: 0x01330000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch + extends [mscorlib]System.Object +{ + .class auto ansi nested public beforefieldinit SetProperty + extends [mscorlib]System.Object + { + .field public initonly class [mscorlib]System.Reflection.PropertyInfo Property + .field private int32 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method public hidebysig specialname + instance int32 get_Set() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 11 (0xb) + .maxstack 1 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::'k__BackingField' + IL_0006: stloc.0 + IL_0007: br.s IL_0009 + + IL_0009: ldloc.0 + IL_000a: ret + } // end of method SetProperty::get_Set + + .method public hidebysig specialname + instance void set_Set(int32 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::'k__BackingField' + IL_0007: ret + } // end of method SetProperty::set_Set + + .method public hidebysig specialname rtspecialname + instance void .ctor(class [mscorlib]System.Reflection.PropertyInfo 'property') cil managed + { + // Code size 17 (0x11) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: nop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld class [mscorlib]System.Reflection.PropertyInfo ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::Property + IL_000f: nop + IL_0010: ret + } // end of method SetProperty::.ctor + + .property instance int32 Set() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::get_Set() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + } // end of property SetProperty::Set + } // end of class SetProperty + + .class auto ansi sealed nested public State + extends [mscorlib]System.Enum + { + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State False = int32(0x00000000) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State True = int32(0x00000001) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State Null = int32(0x00000002) + } // end of class State + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State + SwitchOverNullableBool(valuetype [mscorlib]System.Nullable`1 'value') cil managed + { + // Code size 53 (0x35) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State V_0, + bool V_1) + IL_0000: nop + IL_0001: ldarga.s 'value' + IL_0003: dup + IL_0004: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0009: stloc.1 + IL_000a: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000f: brfalse.s IL_0029 + + IL_0011: ldloc.1 + IL_0012: switch ( + IL_0021, + IL_0025) + IL_001f: br.s IL_002d + + IL_0021: ldc.i4.0 + IL_0022: stloc.0 + IL_0023: br.s IL_0033 + + IL_0025: ldc.i4.1 + IL_0026: stloc.0 + IL_0027: br.s IL_0033 + + IL_0029: ldc.i4.2 + IL_002a: stloc.0 + IL_002b: br.s IL_0033 + + IL_002d: newobj instance void [mscorlib]System.InvalidOperationException::.ctor() + IL_0032: throw + + IL_0033: ldloc.0 + IL_0034: ret + } // end of method Switch::SwitchOverNullableBool + + .method public hidebysig static valuetype [mscorlib]System.Nullable`1 + SwitchOverNullableEnum(valuetype [mscorlib]System.Nullable`1 state) cil managed + { + // Code size 75 (0x4b) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State V_1, + valuetype [mscorlib]System.Nullable`1 V_2) + IL_0000: nop + IL_0001: ldarga.s state + IL_0003: dup + IL_0004: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0009: stloc.1 + IL_000a: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000f: brfalse.s IL_0043 + + IL_0011: ldloc.1 + IL_0012: switch ( + IL_0025, + IL_002e, + IL_0037) + IL_0023: br.s IL_0043 + + IL_0025: ldc.i4.0 + IL_0026: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_002b: stloc.0 + IL_002c: br.s IL_0049 + + IL_002e: ldc.i4.1 + IL_002f: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0034: stloc.0 + IL_0035: br.s IL_0049 + + IL_0037: ldloca.s V_2 + IL_0039: initobj valuetype [mscorlib]System.Nullable`1 + IL_003f: ldloc.2 + IL_0040: stloc.0 + IL_0041: br.s IL_0049 + + IL_0043: newobj instance void [mscorlib]System.InvalidOperationException::.ctor() + IL_0048: throw + + IL_0049: ldloc.0 + IL_004a: ret + } // end of method Switch::SwitchOverNullableEnum + + .method public hidebysig static string + SparseIntegerSwitch(int32 i) cil managed + { + // Code size 209 (0xd1) + .maxstack 2 + .locals init (string V_0, + int32 V_1) + IL_0000: nop + IL_0001: ldstr "SparseIntegerSwitch: " + IL_0006: ldarg.0 + IL_0007: box [mscorlib]System.Int32 + IL_000c: call string [mscorlib]System.String::Concat(object, + object) + IL_0011: call void [mscorlib]System.Console::WriteLine(string) + IL_0016: nop + IL_0017: ldarg.0 + IL_0018: stloc.1 + IL_0019: ldloc.1 + IL_001a: ldc.i4.4 + IL_001b: bgt.s IL_004c + + IL_001d: ldloc.1 + IL_001e: ldc.i4 0xff676980 + IL_0023: beq.s IL_006f + + IL_0025: ldloc.1 + IL_0026: ldc.i4.s -100 + IL_0028: beq.s IL_0077 + + IL_002a: ldloc.1 + IL_002b: ldc.i4.m1 + IL_002c: sub + IL_002d: switch ( + IL_007f, + IL_0087, + IL_008f, + IL_0097, + IL_00c7, + IL_009f) + IL_004a: br.s IL_00c7 + + IL_004c: ldloc.1 + IL_004d: ldc.i4.s 100 + IL_004f: beq.s IL_00a7 + + IL_0051: ldloc.1 + IL_0052: ldc.i4 0x2710 + IL_0057: sub + IL_0058: switch ( + IL_00af, + IL_00b7) + IL_0065: ldloc.1 + IL_0066: ldc.i4 0x7fffffff + IL_006b: beq.s IL_00bf + + IL_006d: br.s IL_00c7 + + IL_006f: ldstr "-10 mln" + IL_0074: stloc.0 + IL_0075: br.s IL_00cf + + IL_0077: ldstr "-hundred" + IL_007c: stloc.0 + IL_007d: br.s IL_00cf + + IL_007f: ldstr "-1" + IL_0084: stloc.0 + IL_0085: br.s IL_00cf + + IL_0087: ldstr "0" + IL_008c: stloc.0 + IL_008d: br.s IL_00cf + + IL_008f: ldstr "1" + IL_0094: stloc.0 + IL_0095: br.s IL_00cf + + IL_0097: ldstr "2" + IL_009c: stloc.0 + IL_009d: br.s IL_00cf + + IL_009f: ldstr "4" + IL_00a4: stloc.0 + IL_00a5: br.s IL_00cf + + IL_00a7: ldstr "hundred" + IL_00ac: stloc.0 + IL_00ad: br.s IL_00cf + + IL_00af: ldstr "ten thousand" + IL_00b4: stloc.0 + IL_00b5: br.s IL_00cf + + IL_00b7: ldstr "ten thousand and one" + IL_00bc: stloc.0 + IL_00bd: br.s IL_00cf + + IL_00bf: ldstr "int.MaxValue" + IL_00c4: stloc.0 + IL_00c5: br.s IL_00cf + + IL_00c7: ldstr "something else" + IL_00cc: stloc.0 + IL_00cd: br.s IL_00cf + + IL_00cf: ldloc.0 + IL_00d0: ret + } // end of method Switch::SparseIntegerSwitch + + .method public hidebysig static string + SwitchOverNullableInt(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 74 (0x4a) + .maxstack 2 + .locals init (string V_0, + int32 V_1) + IL_0000: nop + IL_0001: ldarga.s i + IL_0003: dup + IL_0004: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0009: stloc.1 + IL_000a: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000f: brfalse.s IL_0020 + + IL_0011: ldloc.1 + IL_0012: ldc.i4.0 + IL_0013: beq.s IL_0028 + + IL_0015: ldloc.1 + IL_0016: ldc.i4.5 + IL_0017: beq.s IL_0030 + + IL_0019: ldloc.1 + IL_001a: ldc.i4.s 10 + IL_001c: beq.s IL_0038 + + IL_001e: br.s IL_0040 + + IL_0020: ldstr "null" + IL_0025: stloc.0 + IL_0026: br.s IL_0048 + + IL_0028: ldstr "zero" + IL_002d: stloc.0 + IL_002e: br.s IL_0048 + + IL_0030: ldstr "five" + IL_0035: stloc.0 + IL_0036: br.s IL_0048 + + IL_0038: ldstr "ten" + IL_003d: stloc.0 + IL_003e: br.s IL_0048 + + IL_0040: ldstr "large" + IL_0045: stloc.0 + IL_0046: br.s IL_0048 + + IL_0048: ldloc.0 + IL_0049: ret + } // end of method Switch::SwitchOverNullableInt + + .method public hidebysig static string + SwitchOverNullableIntNullCaseCombined(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 66 (0x42) + .maxstack 2 + .locals init (string V_0, + int32 V_1) + IL_0000: nop + IL_0001: ldarga.s i + IL_0003: dup + IL_0004: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0009: stloc.1 + IL_000a: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000f: brfalse.s IL_0020 + + IL_0011: ldloc.1 + IL_0012: ldc.i4.0 + IL_0013: beq.s IL_0020 + + IL_0015: ldloc.1 + IL_0016: ldc.i4.5 + IL_0017: beq.s IL_0028 + + IL_0019: ldloc.1 + IL_001a: ldc.i4.s 10 + IL_001c: beq.s IL_0030 + + IL_001e: br.s IL_0038 + + IL_0020: ldstr "zero" + IL_0025: stloc.0 + IL_0026: br.s IL_0040 + + IL_0028: ldstr "five" + IL_002d: stloc.0 + IL_002e: br.s IL_0040 + + IL_0030: ldstr "ten" + IL_0035: stloc.0 + IL_0036: br.s IL_0040 + + IL_0038: ldstr "large" + IL_003d: stloc.0 + IL_003e: br.s IL_0040 + + IL_0040: ldloc.0 + IL_0041: ret + } // end of method Switch::SwitchOverNullableIntNullCaseCombined + + .method public hidebysig static string + SwitchOverNullableIntShifted(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 112 (0x70) + .maxstack 2 + .locals init (string V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype [mscorlib]System.Nullable`1 V_2, + int32 V_3) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloca.s V_1 + IL_0005: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000a: brtrue.s IL_0017 + + IL_000c: ldloca.s V_2 + IL_000e: initobj valuetype [mscorlib]System.Nullable`1 + IL_0014: ldloc.2 + IL_0015: br.s IL_0025 + + IL_0017: ldloca.s V_1 + IL_0019: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_001e: ldc.i4.5 + IL_001f: add + IL_0020: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0025: nop + IL_0026: stloc.2 + IL_0027: ldloca.s V_2 + IL_0029: dup + IL_002a: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_002f: stloc.3 + IL_0030: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0035: brfalse.s IL_0046 + + IL_0037: ldloc.3 + IL_0038: ldc.i4.0 + IL_0039: beq.s IL_004e + + IL_003b: ldloc.3 + IL_003c: ldc.i4.5 + IL_003d: beq.s IL_0056 + + IL_003f: ldloc.3 + IL_0040: ldc.i4.s 10 + IL_0042: beq.s IL_005e + + IL_0044: br.s IL_0066 + + IL_0046: ldstr "null" + IL_004b: stloc.0 + IL_004c: br.s IL_006e + + IL_004e: ldstr "zero" + IL_0053: stloc.0 + IL_0054: br.s IL_006e + + IL_0056: ldstr "five" + IL_005b: stloc.0 + IL_005c: br.s IL_006e + + IL_005e: ldstr "ten" + IL_0063: stloc.0 + IL_0064: br.s IL_006e + + IL_0066: ldstr "large" + IL_006b: stloc.0 + IL_006c: br.s IL_006e + + IL_006e: ldloc.0 + IL_006f: ret + } // end of method Switch::SwitchOverNullableIntShifted + + .method public hidebysig static string + SwitchOverNullableIntShiftedNullCaseCombined(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 104 (0x68) + .maxstack 2 + .locals init (string V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype [mscorlib]System.Nullable`1 V_2, + int32 V_3) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloca.s V_1 + IL_0005: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000a: brtrue.s IL_0017 + + IL_000c: ldloca.s V_2 + IL_000e: initobj valuetype [mscorlib]System.Nullable`1 + IL_0014: ldloc.2 + IL_0015: br.s IL_0025 + + IL_0017: ldloca.s V_1 + IL_0019: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_001e: ldc.i4.5 + IL_001f: add + IL_0020: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0025: nop + IL_0026: stloc.2 + IL_0027: ldloca.s V_2 + IL_0029: dup + IL_002a: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_002f: stloc.3 + IL_0030: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0035: brfalse.s IL_0046 + + IL_0037: ldloc.3 + IL_0038: ldc.i4.0 + IL_0039: beq.s IL_0046 + + IL_003b: ldloc.3 + IL_003c: ldc.i4.5 + IL_003d: beq.s IL_004e + + IL_003f: ldloc.3 + IL_0040: ldc.i4.s 10 + IL_0042: beq.s IL_0056 + + IL_0044: br.s IL_005e + + IL_0046: ldstr "zero" + IL_004b: stloc.0 + IL_004c: br.s IL_0066 + + IL_004e: ldstr "five" + IL_0053: stloc.0 + IL_0054: br.s IL_0066 + + IL_0056: ldstr "ten" + IL_005b: stloc.0 + IL_005c: br.s IL_0066 + + IL_005e: ldstr "large" + IL_0063: stloc.0 + IL_0064: br.s IL_0066 + + IL_0066: ldloc.0 + IL_0067: ret + } // end of method Switch::SwitchOverNullableIntShiftedNullCaseCombined + + .method public hidebysig static string + SwitchOverNullableIntNoNullCase(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 66 (0x42) + .maxstack 2 + .locals init (string V_0, + int32 V_1) + IL_0000: nop + IL_0001: ldarga.s i + IL_0003: dup + IL_0004: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0009: stloc.1 + IL_000a: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000f: brfalse.s IL_0038 + + IL_0011: ldloc.1 + IL_0012: ldc.i4.0 + IL_0013: beq.s IL_0020 + + IL_0015: ldloc.1 + IL_0016: ldc.i4.5 + IL_0017: beq.s IL_0028 + + IL_0019: ldloc.1 + IL_001a: ldc.i4.s 10 + IL_001c: beq.s IL_0030 + + IL_001e: br.s IL_0038 + + IL_0020: ldstr "zero" + IL_0025: stloc.0 + IL_0026: br.s IL_0040 + + IL_0028: ldstr "five" + IL_002d: stloc.0 + IL_002e: br.s IL_0040 + + IL_0030: ldstr "ten" + IL_0035: stloc.0 + IL_0036: br.s IL_0040 + + IL_0038: ldstr "other" + IL_003d: stloc.0 + IL_003e: br.s IL_0040 + + IL_0040: ldloc.0 + IL_0041: ret + } // end of method Switch::SwitchOverNullableIntNoNullCase + + .method public hidebysig static string + SwitchOverNullableIntNoNullCaseShifted(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 104 (0x68) + .maxstack 2 + .locals init (string V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype [mscorlib]System.Nullable`1 V_2, + int32 V_3) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloca.s V_1 + IL_0005: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000a: brtrue.s IL_0017 + + IL_000c: ldloca.s V_2 + IL_000e: initobj valuetype [mscorlib]System.Nullable`1 + IL_0014: ldloc.2 + IL_0015: br.s IL_0025 + + IL_0017: ldloca.s V_1 + IL_0019: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_001e: ldc.i4.5 + IL_001f: add + IL_0020: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0025: nop + IL_0026: stloc.2 + IL_0027: ldloca.s V_2 + IL_0029: dup + IL_002a: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_002f: stloc.3 + IL_0030: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0035: brfalse.s IL_005e + + IL_0037: ldloc.3 + IL_0038: ldc.i4.0 + IL_0039: beq.s IL_0046 + + IL_003b: ldloc.3 + IL_003c: ldc.i4.5 + IL_003d: beq.s IL_004e + + IL_003f: ldloc.3 + IL_0040: ldc.i4.s 10 + IL_0042: beq.s IL_0056 + + IL_0044: br.s IL_005e + + IL_0046: ldstr "zero" + IL_004b: stloc.0 + IL_004c: br.s IL_0066 + + IL_004e: ldstr "five" + IL_0053: stloc.0 + IL_0054: br.s IL_0066 + + IL_0056: ldstr "ten" + IL_005b: stloc.0 + IL_005c: br.s IL_0066 + + IL_005e: ldstr "other" + IL_0063: stloc.0 + IL_0064: br.s IL_0066 + + IL_0066: ldloc.0 + IL_0067: ret + } // end of method Switch::SwitchOverNullableIntNoNullCaseShifted + + .method public hidebysig static void SwitchOverInt(int32 i) cil managed + { + // Code size 144 (0x90) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.0 + IL_0003: ldloc.0 + IL_0004: ldc.i4.s 10 + IL_0006: bgt.s IL_0017 + + IL_0008: ldloc.0 + IL_0009: ldc.i4.0 + IL_000a: beq.s IL_0034 + + IL_000c: ldloc.0 + IL_000d: ldc.i4.5 + IL_000e: beq.s IL_0041 + + IL_0010: ldloc.0 + IL_0011: ldc.i4.s 10 + IL_0013: beq.s IL_004e + + IL_0015: br.s IL_008f + + IL_0017: ldloc.0 + IL_0018: ldc.i4.s 20 + IL_001a: bgt.s IL_0028 + + IL_001c: ldloc.0 + IL_001d: ldc.i4.s 15 + IL_001f: beq.s IL_005b + + IL_0021: ldloc.0 + IL_0022: ldc.i4.s 20 + IL_0024: beq.s IL_0068 + + IL_0026: br.s IL_008f + + IL_0028: ldloc.0 + IL_0029: ldc.i4.s 25 + IL_002b: beq.s IL_0075 + + IL_002d: ldloc.0 + IL_002e: ldc.i4.s 30 + IL_0030: beq.s IL_0082 + + IL_0032: br.s IL_008f + + IL_0034: ldstr "zero" + IL_0039: call void [mscorlib]System.Console::WriteLine(string) + IL_003e: nop + IL_003f: br.s IL_008f + + IL_0041: ldstr "five" + IL_0046: call void [mscorlib]System.Console::WriteLine(string) + IL_004b: nop + IL_004c: br.s IL_008f + + IL_004e: ldstr "ten" + IL_0053: call void [mscorlib]System.Console::WriteLine(string) + IL_0058: nop + IL_0059: br.s IL_008f + + IL_005b: ldstr "fifteen" + IL_0060: call void [mscorlib]System.Console::WriteLine(string) + IL_0065: nop + IL_0066: br.s IL_008f + + IL_0068: ldstr "twenty" + IL_006d: call void [mscorlib]System.Console::WriteLine(string) + IL_0072: nop + IL_0073: br.s IL_008f + + IL_0075: ldstr "twenty-five" + IL_007a: call void [mscorlib]System.Console::WriteLine(string) + IL_007f: nop + IL_0080: br.s IL_008f + + IL_0082: ldstr "thirty" + IL_0087: call void [mscorlib]System.Console::WriteLine(string) + IL_008c: nop + IL_008d: br.s IL_008f + + IL_008f: ret + } // end of method Switch::SwitchOverInt + + .method public hidebysig static string + ShortSwitchOverString(string text) cil managed + { + // Code size 98 (0x62) + .maxstack 2 + .locals init (string V_0, + string V_1) + IL_0000: nop + IL_0001: ldstr "ShortSwitchOverString: " + IL_0006: ldarg.0 + IL_0007: call string [mscorlib]System.String::Concat(string, + string) + IL_000c: call void [mscorlib]System.Console::WriteLine(string) + IL_0011: nop + IL_0012: ldarg.0 + IL_0013: stloc.1 + IL_0014: ldloc.1 + IL_0015: brfalse.s IL_0058 + + IL_0017: ldloc.1 + IL_0018: ldstr "First case" + IL_001d: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0022: brtrue.s IL_0040 + + IL_0024: ldloc.1 + IL_0025: ldstr "Second case" + IL_002a: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002f: brtrue.s IL_0048 + + IL_0031: ldloc.1 + IL_0032: ldstr "Third case" + IL_0037: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_003c: brtrue.s IL_0050 + + IL_003e: br.s IL_0058 + + IL_0040: ldstr "Text1" + IL_0045: stloc.0 + IL_0046: br.s IL_0060 + + IL_0048: ldstr "Text2" + IL_004d: stloc.0 + IL_004e: br.s IL_0060 + + IL_0050: ldstr "Text3" + IL_0055: stloc.0 + IL_0056: br.s IL_0060 + + IL_0058: ldstr "Default" + IL_005d: stloc.0 + IL_005e: br.s IL_0060 + + IL_0060: ldloc.0 + IL_0061: ret + } // end of method Switch::ShortSwitchOverString + + .method public hidebysig static string + ShortSwitchOverStringWithNullCase(string text) cil managed + { + // Code size 85 (0x55) + .maxstack 2 + .locals init (string V_0, + string V_1) + IL_0000: nop + IL_0001: ldstr "ShortSwitchOverStringWithNullCase: " + IL_0006: ldarg.0 + IL_0007: call string [mscorlib]System.String::Concat(string, + string) + IL_000c: call void [mscorlib]System.Console::WriteLine(string) + IL_0011: nop + IL_0012: ldarg.0 + IL_0013: stloc.1 + IL_0014: ldloc.1 + IL_0015: brfalse.s IL_0043 + + IL_0017: ldloc.1 + IL_0018: ldstr "First case" + IL_001d: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0022: brtrue.s IL_0033 + + IL_0024: ldloc.1 + IL_0025: ldstr "Second case" + IL_002a: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002f: brtrue.s IL_003b + + IL_0031: br.s IL_004b + + IL_0033: ldstr "Text1" + IL_0038: stloc.0 + IL_0039: br.s IL_0053 + + IL_003b: ldstr "Text2" + IL_0040: stloc.0 + IL_0041: br.s IL_0053 + + IL_0043: ldstr "null" + IL_0048: stloc.0 + IL_0049: br.s IL_0053 + + IL_004b: ldstr "Default" + IL_0050: stloc.0 + IL_0051: br.s IL_0053 + + IL_0053: ldloc.0 + IL_0054: ret + } // end of method Switch::ShortSwitchOverStringWithNullCase + + .method public hidebysig static string + SwitchOverString1(string text) cil managed + { + // Code size 247 (0xf7) + .maxstack 4 + .locals init (string V_0, + string V_1, + int32 V_2) + IL_0000: nop + IL_0001: ldstr "SwitchOverString1: " + IL_0006: ldarg.0 + IL_0007: call string [mscorlib]System.String::Concat(string, + string) + IL_000c: call void [mscorlib]System.Console::WriteLine(string) + IL_0011: nop + IL_0012: ldarg.0 + IL_0013: stloc.1 + IL_0014: ldloc.1 + IL_0015: brfalse IL_00e9 + + IL_001a: volatile. + IL_001c: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{0EF64C57-A49E-4138-9C3F-BDAB86B2E450}'::'$$method0x600000d-1' + IL_0021: brtrue.s IL_0084 + + IL_0023: ldc.i4.7 + IL_0024: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) + IL_0029: dup + IL_002a: ldstr "First case" + IL_002f: ldc.i4.0 + IL_0030: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0035: dup + IL_0036: ldstr "Second case" + IL_003b: ldc.i4.1 + IL_003c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0041: dup + IL_0042: ldstr "2nd case" + IL_0047: ldc.i4.2 + IL_0048: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_004d: dup + IL_004e: ldstr "Third case" + IL_0053: ldc.i4.3 + IL_0054: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0059: dup + IL_005a: ldstr "Fourth case" + IL_005f: ldc.i4.4 + IL_0060: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0065: dup + IL_0066: ldstr "Fifth case" + IL_006b: ldc.i4.5 + IL_006c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0071: dup + IL_0072: ldstr "Sixth case" + IL_0077: ldc.i4.6 + IL_0078: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_007d: volatile. + IL_007f: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{0EF64C57-A49E-4138-9C3F-BDAB86B2E450}'::'$$method0x600000d-1' + IL_0084: volatile. + IL_0086: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{0EF64C57-A49E-4138-9C3F-BDAB86B2E450}'::'$$method0x600000d-1' + IL_008b: ldloc.1 + IL_008c: ldloca.s V_2 + IL_008e: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, + !1&) + IL_0093: brfalse.s IL_00ed + + IL_0095: ldloc.2 + IL_0096: switch ( + IL_00b9, + IL_00c1, + IL_00c1, + IL_00c9, + IL_00d1, + IL_00d9, + IL_00e1) + IL_00b7: br.s IL_00ed + + IL_00b9: ldstr "Text1" + IL_00be: stloc.0 + IL_00bf: br.s IL_00f5 + + IL_00c1: ldstr "Text2" + IL_00c6: stloc.0 + IL_00c7: br.s IL_00f5 + + IL_00c9: ldstr "Text3" + IL_00ce: stloc.0 + IL_00cf: br.s IL_00f5 + + IL_00d1: ldstr "Text4" + IL_00d6: stloc.0 + IL_00d7: br.s IL_00f5 + + IL_00d9: ldstr "Text5" + IL_00de: stloc.0 + IL_00df: br.s IL_00f5 + + IL_00e1: ldstr "Text6" + IL_00e6: stloc.0 + IL_00e7: br.s IL_00f5 + + IL_00e9: ldnull + IL_00ea: stloc.0 + IL_00eb: br.s IL_00f5 + + IL_00ed: ldstr "Default" + IL_00f2: stloc.0 + IL_00f3: br.s IL_00f5 + + IL_00f5: ldloc.0 + IL_00f6: ret + } // end of method Switch::SwitchOverString1 + + .method public hidebysig static string + SwitchOverString2() cil managed + { + // Code size 354 (0x162) + .maxstack 4 + .locals init (string V_0, + string V_1, + int32 V_2) + IL_0000: nop + IL_0001: ldstr "SwitchOverString2:" + IL_0006: call void [mscorlib]System.Console::WriteLine(string) + IL_000b: nop + IL_000c: call string [mscorlib]System.Environment::get_UserName() + IL_0011: stloc.1 + IL_0012: ldloc.1 + IL_0013: brfalse IL_0158 + + IL_0018: volatile. + IL_001a: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{0EF64C57-A49E-4138-9C3F-BDAB86B2E450}'::'$$method0x600000e-1' + IL_001f: brtrue IL_00b8 + + IL_0024: ldc.i4.s 11 + IL_0026: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) + IL_002b: dup + IL_002c: ldstr "First case" + IL_0031: ldc.i4.0 + IL_0032: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0037: dup + IL_0038: ldstr "Second case" + IL_003d: ldc.i4.1 + IL_003e: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0043: dup + IL_0044: ldstr "Third case" + IL_0049: ldc.i4.2 + IL_004a: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_004f: dup + IL_0050: ldstr "Fourth case" + IL_0055: ldc.i4.3 + IL_0056: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_005b: dup + IL_005c: ldstr "Fifth case" + IL_0061: ldc.i4.4 + IL_0062: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0067: dup + IL_0068: ldstr "Sixth case" + IL_006d: ldc.i4.5 + IL_006e: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0073: dup + IL_0074: ldstr "Seventh case" + IL_0079: ldc.i4.6 + IL_007a: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_007f: dup + IL_0080: ldstr "Eighth case" + IL_0085: ldc.i4.7 + IL_0086: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_008b: dup + IL_008c: ldstr "Ninth case" + IL_0091: ldc.i4.8 + IL_0092: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0097: dup + IL_0098: ldstr "Tenth case" + IL_009d: ldc.i4.s 9 + IL_009f: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_00a4: dup + IL_00a5: ldstr "Eleventh case" + IL_00aa: ldc.i4.s 10 + IL_00ac: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_00b1: volatile. + IL_00b3: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{0EF64C57-A49E-4138-9C3F-BDAB86B2E450}'::'$$method0x600000e-1' + IL_00b8: volatile. + IL_00ba: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{0EF64C57-A49E-4138-9C3F-BDAB86B2E450}'::'$$method0x600000e-1' + IL_00bf: ldloc.1 + IL_00c0: ldloca.s V_2 + IL_00c2: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, + !1&) + IL_00c7: brfalse IL_0158 + + IL_00cc: ldloc.2 + IL_00cd: switch ( + IL_0100, + IL_0108, + IL_0110, + IL_0118, + IL_0120, + IL_0128, + IL_0130, + IL_0138, + IL_0140, + IL_0148, + IL_0150) + IL_00fe: br.s IL_0158 + + IL_0100: ldstr "Text1" + IL_0105: stloc.0 + IL_0106: br.s IL_0160 + + IL_0108: ldstr "Text2" + IL_010d: stloc.0 + IL_010e: br.s IL_0160 + + IL_0110: ldstr "Text3" + IL_0115: stloc.0 + IL_0116: br.s IL_0160 + + IL_0118: ldstr "Text4" + IL_011d: stloc.0 + IL_011e: br.s IL_0160 + + IL_0120: ldstr "Text5" + IL_0125: stloc.0 + IL_0126: br.s IL_0160 + + IL_0128: ldstr "Text6" + IL_012d: stloc.0 + IL_012e: br.s IL_0160 + + IL_0130: ldstr "Text7" + IL_0135: stloc.0 + IL_0136: br.s IL_0160 + + IL_0138: ldstr "Text8" + IL_013d: stloc.0 + IL_013e: br.s IL_0160 + + IL_0140: ldstr "Text9" + IL_0145: stloc.0 + IL_0146: br.s IL_0160 + + IL_0148: ldstr "Text10" + IL_014d: stloc.0 + IL_014e: br.s IL_0160 + + IL_0150: ldstr "Text11" + IL_0155: stloc.0 + IL_0156: br.s IL_0160 + + IL_0158: ldstr "Default" + IL_015d: stloc.0 + IL_015e: br.s IL_0160 + + IL_0160: ldloc.0 + IL_0161: ret + } // end of method Switch::SwitchOverString2 + + .method public hidebysig static string + SwitchOverBool(bool b) cil managed + { + // Code size 64 (0x40) + .maxstack 2 + .locals init (string V_0, + bool V_1) + IL_0000: nop + IL_0001: ldstr "SwitchOverBool: " + IL_0006: ldarga.s b + IL_0008: call instance string [mscorlib]System.Boolean::ToString() + IL_000d: call string [mscorlib]System.String::Concat(string, + string) + IL_0012: call void [mscorlib]System.Console::WriteLine(string) + IL_0017: nop + IL_0018: ldarg.0 + IL_0019: stloc.1 + IL_001a: ldloc.1 + IL_001b: switch ( + IL_0032, + IL_002a) + IL_0028: br.s IL_003a + + IL_002a: ldsfld string [mscorlib]System.Boolean::TrueString + IL_002f: stloc.0 + IL_0030: br.s IL_003e + + IL_0032: ldsfld string [mscorlib]System.Boolean::FalseString + IL_0037: stloc.0 + IL_0038: br.s IL_003e + + IL_003a: ldnull + IL_003b: stloc.0 + IL_003c: br.s IL_003e + + IL_003e: ldloc.0 + IL_003f: ret + } // end of method Switch::SwitchOverBool + + .method public hidebysig static void SwitchInLoop(int32 i) cil managed + { + // Code size 128 (0x80) + .maxstack 2 + .locals init (int32 V_0, + bool V_1) + IL_0000: nop + IL_0001: ldstr "SwitchInLoop: " + IL_0006: ldarg.0 + IL_0007: box [mscorlib]System.Int32 + IL_000c: call string [mscorlib]System.String::Concat(object, + object) + IL_0011: call void [mscorlib]System.Console::WriteLine(string) + IL_0016: nop + IL_0017: br.s IL_007b + + IL_0019: nop + IL_001a: ldarg.0 + IL_001b: stloc.0 + IL_001c: ldloc.0 + IL_001d: ldc.i4.1 + IL_001e: sub + IL_001f: switch ( + IL_0036, + IL_0043, + IL_005d, + IL_0050) + IL_0034: br.s IL_005d + + IL_0036: ldstr "one" + IL_003b: call void [mscorlib]System.Console::WriteLine(string) + IL_0040: nop + IL_0041: br.s IL_0075 + + IL_0043: ldstr "two" + IL_0048: call void [mscorlib]System.Console::WriteLine(string) + IL_004d: nop + IL_004e: br.s IL_0075 + + IL_0050: ldstr "four" + IL_0055: call void [mscorlib]System.Console::WriteLine(string) + IL_005a: nop + IL_005b: br.s IL_007f + + IL_005d: ldstr "default" + IL_0062: call void [mscorlib]System.Console::WriteLine(string) + IL_0067: nop + IL_0068: ldstr "more code" + IL_006d: call void [mscorlib]System.Console::WriteLine(string) + IL_0072: nop + IL_0073: br.s IL_007f + + IL_0075: ldarg.0 + IL_0076: ldc.i4.1 + IL_0077: add + IL_0078: starg.s i + IL_007a: nop + IL_007b: ldc.i4.1 + IL_007c: stloc.1 + IL_007d: br.s IL_0019 + + IL_007f: ret + } // end of method Switch::SwitchInLoop + + .method public hidebysig static void SwitchWithGoto(int32 i) cil managed + { + // Code size 128 (0x80) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: nop + IL_0001: ldstr "SwitchWithGoto: " + IL_0006: ldarg.0 + IL_0007: box [mscorlib]System.Int32 + IL_000c: call string [mscorlib]System.String::Concat(object, + object) + IL_0011: call void [mscorlib]System.Console::WriteLine(string) + IL_0016: nop + IL_0017: ldarg.0 + IL_0018: stloc.0 + IL_0019: ldloc.0 + IL_001a: ldc.i4.1 + IL_001b: sub + IL_001c: switch ( + IL_0033, + IL_0040, + IL_004d, + IL_005a) + IL_0031: br.s IL_0067 + + IL_0033: ldstr "one" + IL_0038: call void [mscorlib]System.Console::WriteLine(string) + IL_003d: nop + IL_003e: br.s IL_0067 + + IL_0040: ldstr "two" + IL_0045: call void [mscorlib]System.Console::WriteLine(string) + IL_004a: nop + IL_004b: br.s IL_004d + + IL_004d: ldstr "three" + IL_0052: call void [mscorlib]System.Console::WriteLine(string) + IL_0057: nop + IL_0058: br.s IL_0074 + + IL_005a: ldstr "four" + IL_005f: call void [mscorlib]System.Console::WriteLine(string) + IL_0064: nop + IL_0065: br.s IL_007f + + IL_0067: ldstr "default" + IL_006c: call void [mscorlib]System.Console::WriteLine(string) + IL_0071: nop + IL_0072: br.s IL_0074 + + IL_0074: ldstr "End of method" + IL_0079: call void [mscorlib]System.Console::WriteLine(string) + IL_007e: nop + IL_007f: ret + } // end of method Switch::SwitchWithGoto + + .method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] + GetProperties() cil managed + { + // Code size 12 (0xc) + .maxstack 1 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] V_0) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: newarr ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty + IL_0007: stloc.0 + IL_0008: br.s IL_000a + + IL_000a: ldloc.0 + IL_000b: ret + } // end of method Switch::GetProperties + + .method public hidebysig static void SwitchOnStringInForLoop() cil managed + { + // Code size 321 (0x141) + .maxstack 4 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0, + class [mscorlib]System.Collections.Generic.List`1 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] V_2, + int32 V_3, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty V_4, + string V_5, + int32 V_6, + bool V_7) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0006: stloc.0 + IL_0007: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000c: stloc.1 + IL_000d: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch::GetProperties() + IL_0012: stloc.2 + IL_0013: ldc.i4.0 + IL_0014: stloc.3 + IL_0015: br IL_0131 + + IL_001a: nop + IL_001b: ldloc.2 + IL_001c: ldloc.3 + IL_001d: ldelem.ref + IL_001e: stloc.s V_4 + IL_0020: ldloc.s V_4 + IL_0022: ldfld class [mscorlib]System.Reflection.PropertyInfo ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::Property + IL_0027: callvirt instance string [mscorlib]System.Reflection.MemberInfo::get_Name() + IL_002c: stloc.s V_5 + IL_002e: ldloc.s V_5 + IL_0030: brfalse IL_0121 + + IL_0035: volatile. + IL_0037: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{0EF64C57-A49E-4138-9C3F-BDAB86B2E450}'::'$$method0x6000013-1' + IL_003c: brtrue.s IL_0093 + + IL_003e: ldc.i4.6 + IL_003f: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) + IL_0044: dup + IL_0045: ldstr "Name1" + IL_004a: ldc.i4.0 + IL_004b: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0050: dup + IL_0051: ldstr "Name2" + IL_0056: ldc.i4.1 + IL_0057: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_005c: dup + IL_005d: ldstr "Name3" + IL_0062: ldc.i4.2 + IL_0063: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0068: dup + IL_0069: ldstr "Name4" + IL_006e: ldc.i4.3 + IL_006f: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0074: dup + IL_0075: ldstr "Name5" + IL_007a: ldc.i4.4 + IL_007b: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0080: dup + IL_0081: ldstr "Name6" + IL_0086: ldc.i4.5 + IL_0087: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_008c: volatile. + IL_008e: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{0EF64C57-A49E-4138-9C3F-BDAB86B2E450}'::'$$method0x6000013-1' + IL_0093: volatile. + IL_0095: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{0EF64C57-A49E-4138-9C3F-BDAB86B2E450}'::'$$method0x6000013-1' + IL_009a: ldloc.s V_5 + IL_009c: ldloca.s V_6 + IL_009e: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, + !1&) + IL_00a3: brfalse.s IL_0121 + + IL_00a5: ldloc.s V_6 + IL_00a7: switch ( + IL_00c6, + IL_00da, + IL_00ee, + IL_0102, + IL_0116, + IL_0116) + IL_00c4: br.s IL_0121 + + IL_00c6: ldloc.s V_4 + IL_00c8: ldc.i4.1 + IL_00c9: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00ce: nop + IL_00cf: ldloc.0 + IL_00d0: ldloc.s V_4 + IL_00d2: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00d7: nop + IL_00d8: br.s IL_012c + + IL_00da: ldloc.s V_4 + IL_00dc: ldc.i4.2 + IL_00dd: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00e2: nop + IL_00e3: ldloc.0 + IL_00e4: ldloc.s V_4 + IL_00e6: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00eb: nop + IL_00ec: br.s IL_012c + + IL_00ee: ldloc.s V_4 + IL_00f0: ldc.i4.3 + IL_00f1: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00f6: nop + IL_00f7: ldloc.0 + IL_00f8: ldloc.s V_4 + IL_00fa: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00ff: nop + IL_0100: br.s IL_012c + + IL_0102: ldloc.s V_4 + IL_0104: ldc.i4.4 + IL_0105: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_010a: nop + IL_010b: ldloc.0 + IL_010c: ldloc.s V_4 + IL_010e: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0113: nop + IL_0114: br.s IL_012c + + IL_0116: ldloc.0 + IL_0117: ldloc.s V_4 + IL_0119: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_011e: nop + IL_011f: br.s IL_012c + + IL_0121: ldloc.1 + IL_0122: ldloc.s V_4 + IL_0124: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0129: nop + IL_012a: br.s IL_012c + + IL_012c: nop + IL_012d: ldloc.3 + IL_012e: ldc.i4.1 + IL_012f: add + IL_0130: stloc.3 + IL_0131: ldloc.3 + IL_0132: ldloc.2 + IL_0133: ldlen + IL_0134: conv.i4 + IL_0135: clt + IL_0137: stloc.s V_7 + IL_0139: ldloc.s V_7 + IL_013b: brtrue IL_001a + + IL_0140: ret + } // end of method Switch::SwitchOnStringInForLoop + + .method public hidebysig static void SwitchWithComplexCondition(string[] args) cil managed + { + // Code size 139 (0x8b) + .maxstack 2 + .locals init (string V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldlen + IL_0003: conv.i4 + IL_0004: brfalse.s IL_000b + + IL_0006: ldarg.0 + IL_0007: ldc.i4.0 + IL_0008: ldelem.ref + IL_0009: br.s IL_0010 + + IL_000b: ldstr "dummy" + IL_0010: nop + IL_0011: stloc.0 + IL_0012: ldloc.0 + IL_0013: brfalse.s IL_007f + + IL_0015: ldloc.0 + IL_0016: ldstr "a" + IL_001b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0020: brtrue.s IL_004b + + IL_0022: ldloc.0 + IL_0023: ldstr "b" + IL_0028: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002d: brtrue.s IL_0058 + + IL_002f: ldloc.0 + IL_0030: ldstr "c" + IL_0035: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_003a: brtrue.s IL_0065 + + IL_003c: ldloc.0 + IL_003d: ldstr "d" + IL_0042: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0047: brtrue.s IL_0072 + + IL_0049: br.s IL_007f + + IL_004b: ldstr "a" + IL_0050: call void [mscorlib]System.Console::WriteLine(string) + IL_0055: nop + IL_0056: br.s IL_007f + + IL_0058: ldstr "b" + IL_005d: call void [mscorlib]System.Console::WriteLine(string) + IL_0062: nop + IL_0063: br.s IL_007f + + IL_0065: ldstr "c" + IL_006a: call void [mscorlib]System.Console::WriteLine(string) + IL_006f: nop + IL_0070: br.s IL_007f + + IL_0072: ldstr "d" + IL_0077: call void [mscorlib]System.Console::WriteLine(string) + IL_007c: nop + IL_007d: br.s IL_007f + + IL_007f: ldstr "end" + IL_0084: call void [mscorlib]System.Console::WriteLine(string) + IL_0089: nop + IL_008a: ret + } // end of method Switch::SwitchWithComplexCondition + + .method public hidebysig static void SwitchWithArray(string[] args) cil managed + { + // Code size 126 (0x7e) + .maxstack 2 + .locals init (string V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldc.i4.0 + IL_0003: ldelem.ref + IL_0004: stloc.0 + IL_0005: ldloc.0 + IL_0006: brfalse.s IL_0072 + + IL_0008: ldloc.0 + IL_0009: ldstr "a" + IL_000e: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0013: brtrue.s IL_003e + + IL_0015: ldloc.0 + IL_0016: ldstr "b" + IL_001b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0020: brtrue.s IL_004b + + IL_0022: ldloc.0 + IL_0023: ldstr "c" + IL_0028: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002d: brtrue.s IL_0058 + + IL_002f: ldloc.0 + IL_0030: ldstr "d" + IL_0035: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_003a: brtrue.s IL_0065 + + IL_003c: br.s IL_0072 + + IL_003e: ldstr "a" + IL_0043: call void [mscorlib]System.Console::WriteLine(string) + IL_0048: nop + IL_0049: br.s IL_0072 + + IL_004b: ldstr "b" + IL_0050: call void [mscorlib]System.Console::WriteLine(string) + IL_0055: nop + IL_0056: br.s IL_0072 + + IL_0058: ldstr "c" + IL_005d: call void [mscorlib]System.Console::WriteLine(string) + IL_0062: nop + IL_0063: br.s IL_0072 + + IL_0065: ldstr "d" + IL_006a: call void [mscorlib]System.Console::WriteLine(string) + IL_006f: nop + IL_0070: br.s IL_0072 + + IL_0072: ldstr "end" + IL_0077: call void [mscorlib]System.Console::WriteLine(string) + IL_007c: nop + IL_007d: ret + } // end of method Switch::SwitchWithArray + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch + +.class private auto ansi '{0EF64C57-A49E-4138-9C3F-BDAB86B2E450}' + extends [mscorlib]System.Object +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x600000d-1' + .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x600000e-1' + .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x6000013-1' +} // end of class '{0EF64C57-A49E-4138-9C3F-BDAB86B2E450}' + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** +// Warnung: Win32-Ressourcendatei "../../../TestCases/Pretty\Switch.res" wurde erstellt. diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.il new file mode 100644 index 000000000..c4fc03c00 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.il @@ -0,0 +1,1385 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly pryqrprl +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module pryqrprl.dll +// MVID: {FFEEBB9C-152A-467A-A4B4-51CF03878E20} +.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: 0x00B70000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch + extends [mscorlib]System.Object +{ + .class auto ansi nested public beforefieldinit SetProperty + extends [mscorlib]System.Object + { + .field public initonly class [mscorlib]System.Reflection.PropertyInfo Property + .field private int32 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method public hidebysig specialname + instance int32 get_Set() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::'k__BackingField' + IL_0006: ret + } // end of method SetProperty::get_Set + + .method public hidebysig specialname + instance void set_Set(int32 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::'k__BackingField' + IL_0007: ret + } // end of method SetProperty::set_Set + + .method public hidebysig specialname rtspecialname + instance void .ctor(class [mscorlib]System.Reflection.PropertyInfo 'property') cil managed + { + // Code size 14 (0xe) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [mscorlib]System.Reflection.PropertyInfo ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::Property + IL_000d: ret + } // end of method SetProperty::.ctor + + .property instance int32 Set() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::get_Set() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + } // end of property SetProperty::Set + } // end of class SetProperty + + .class auto ansi sealed nested public State + extends [mscorlib]System.Enum + { + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State False = int32(0x00000000) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State True = int32(0x00000001) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State Null = int32(0x00000002) + } // end of class State + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State + SwitchOverNullableBool(valuetype [mscorlib]System.Nullable`1 'value') cil managed + { + // Code size 44 (0x2c) + .maxstack 2 + .locals init (bool V_0) + IL_0000: ldarga.s 'value' + IL_0002: dup + IL_0003: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0008: stloc.0 + IL_0009: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000e: brfalse.s IL_0024 + + IL_0010: ldloc.0 + IL_0011: switch ( + IL_0020, + IL_0022) + IL_001e: br.s IL_0026 + + IL_0020: ldc.i4.0 + IL_0021: ret + + IL_0022: ldc.i4.1 + IL_0023: ret + + IL_0024: ldc.i4.2 + IL_0025: ret + + IL_0026: newobj instance void [mscorlib]System.InvalidOperationException::.ctor() + IL_002b: throw + } // end of method Switch::SwitchOverNullableBool + + .method public hidebysig static valuetype [mscorlib]System.Nullable`1 + SwitchOverNullableEnum(valuetype [mscorlib]System.Nullable`1 state) cil managed + { + // Code size 66 (0x42) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State V_0, + valuetype [mscorlib]System.Nullable`1 V_1) + IL_0000: ldarga.s state + IL_0002: dup + IL_0003: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0008: stloc.0 + IL_0009: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000e: brfalse.s IL_003c + + IL_0010: ldloc.0 + IL_0011: switch ( + IL_0024, + IL_002b, + IL_0032) + IL_0022: br.s IL_003c + + IL_0024: ldc.i4.0 + IL_0025: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_002a: ret + + IL_002b: ldc.i4.1 + IL_002c: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0031: ret + + IL_0032: ldloca.s V_1 + IL_0034: initobj valuetype [mscorlib]System.Nullable`1 + IL_003a: ldloc.1 + IL_003b: ret + + IL_003c: newobj instance void [mscorlib]System.InvalidOperationException::.ctor() + IL_0041: throw + } // end of method Switch::SwitchOverNullableEnum + + .method public hidebysig static string + SparseIntegerSwitch(int32 i) cil managed + { + // Code size 181 (0xb5) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldstr "SparseIntegerSwitch: " + IL_0005: ldarg.0 + IL_0006: box [mscorlib]System.Int32 + IL_000b: call string [mscorlib]System.String::Concat(object, + object) + IL_0010: call void [mscorlib]System.Console::WriteLine(string) + IL_0015: ldarg.0 + IL_0016: stloc.0 + IL_0017: ldloc.0 + IL_0018: ldc.i4.4 + IL_0019: bgt.s IL_004a + + IL_001b: ldloc.0 + IL_001c: ldc.i4 0xff676980 + IL_0021: beq.s IL_006d + + IL_0023: ldloc.0 + IL_0024: ldc.i4.s -100 + IL_0026: beq.s IL_0073 + + IL_0028: ldloc.0 + IL_0029: ldc.i4.m1 + IL_002a: sub + IL_002b: switch ( + IL_0079, + IL_007f, + IL_0085, + IL_008b, + IL_00af, + IL_0091) + IL_0048: br.s IL_00af + + IL_004a: ldloc.0 + IL_004b: ldc.i4.s 100 + IL_004d: beq.s IL_0097 + + IL_004f: ldloc.0 + IL_0050: ldc.i4 0x2710 + IL_0055: sub + IL_0056: switch ( + IL_009d, + IL_00a3) + IL_0063: ldloc.0 + IL_0064: ldc.i4 0x7fffffff + IL_0069: beq.s IL_00a9 + + IL_006b: br.s IL_00af + + IL_006d: ldstr "-10 mln" + IL_0072: ret + + IL_0073: ldstr "-hundred" + IL_0078: ret + + IL_0079: ldstr "-1" + IL_007e: ret + + IL_007f: ldstr "0" + IL_0084: ret + + IL_0085: ldstr "1" + IL_008a: ret + + IL_008b: ldstr "2" + IL_0090: ret + + IL_0091: ldstr "4" + IL_0096: ret + + IL_0097: ldstr "hundred" + IL_009c: ret + + IL_009d: ldstr "ten thousand" + IL_00a2: ret + + IL_00a3: ldstr "ten thousand and one" + IL_00a8: ret + + IL_00a9: ldstr "int.MaxValue" + IL_00ae: ret + + IL_00af: ldstr "something else" + IL_00b4: ret + } // end of method Switch::SparseIntegerSwitch + + .method public hidebysig static string + SwitchOverNullableInt(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 61 (0x3d) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldarga.s i + IL_0002: dup + IL_0003: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0008: stloc.0 + IL_0009: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000e: brfalse.s IL_001f + + IL_0010: ldloc.0 + IL_0011: ldc.i4.0 + IL_0012: beq.s IL_0025 + + IL_0014: ldloc.0 + IL_0015: ldc.i4.5 + IL_0016: beq.s IL_002b + + IL_0018: ldloc.0 + IL_0019: ldc.i4.s 10 + IL_001b: beq.s IL_0031 + + IL_001d: br.s IL_0037 + + IL_001f: ldstr "null" + IL_0024: ret + + IL_0025: ldstr "zero" + IL_002a: ret + + IL_002b: ldstr "five" + IL_0030: ret + + IL_0031: ldstr "ten" + IL_0036: ret + + IL_0037: ldstr "large" + IL_003c: ret + } // end of method Switch::SwitchOverNullableInt + + .method public hidebysig static string + SwitchOverNullableIntNullCaseCombined(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 55 (0x37) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldarga.s i + IL_0002: dup + IL_0003: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0008: stloc.0 + IL_0009: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000e: brfalse.s IL_001f + + IL_0010: ldloc.0 + IL_0011: ldc.i4.0 + IL_0012: beq.s IL_001f + + IL_0014: ldloc.0 + IL_0015: ldc.i4.5 + IL_0016: beq.s IL_0025 + + IL_0018: ldloc.0 + IL_0019: ldc.i4.s 10 + IL_001b: beq.s IL_002b + + IL_001d: br.s IL_0031 + + IL_001f: ldstr "zero" + IL_0024: ret + + IL_0025: ldstr "five" + IL_002a: ret + + IL_002b: ldstr "ten" + IL_0030: ret + + IL_0031: ldstr "large" + IL_0036: ret + } // end of method Switch::SwitchOverNullableIntNullCaseCombined + + .method public hidebysig static string + SwitchOverNullableIntShifted(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 98 (0x62) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype [mscorlib]System.Nullable`1 V_2, + int32 V_3) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0009: brtrue.s IL_0016 + + IL_000b: ldloca.s V_1 + IL_000d: initobj valuetype [mscorlib]System.Nullable`1 + IL_0013: ldloc.1 + IL_0014: br.s IL_0024 + + IL_0016: ldloca.s V_0 + IL_0018: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_001d: ldc.i4.5 + IL_001e: add + IL_001f: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0024: stloc.2 + IL_0025: ldloca.s V_2 + IL_0027: dup + IL_0028: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_002d: stloc.3 + IL_002e: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0033: brfalse.s IL_0044 + + IL_0035: ldloc.3 + IL_0036: ldc.i4.0 + IL_0037: beq.s IL_004a + + IL_0039: ldloc.3 + IL_003a: ldc.i4.5 + IL_003b: beq.s IL_0050 + + IL_003d: ldloc.3 + IL_003e: ldc.i4.s 10 + IL_0040: beq.s IL_0056 + + IL_0042: br.s IL_005c + + IL_0044: ldstr "null" + IL_0049: ret + + IL_004a: ldstr "zero" + IL_004f: ret + + IL_0050: ldstr "five" + IL_0055: ret + + IL_0056: ldstr "ten" + IL_005b: ret + + IL_005c: ldstr "large" + IL_0061: ret + } // end of method Switch::SwitchOverNullableIntShifted + + .method public hidebysig static string + SwitchOverNullableIntShiftedNullCaseCombined(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 92 (0x5c) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype [mscorlib]System.Nullable`1 V_2, + int32 V_3) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0009: brtrue.s IL_0016 + + IL_000b: ldloca.s V_1 + IL_000d: initobj valuetype [mscorlib]System.Nullable`1 + IL_0013: ldloc.1 + IL_0014: br.s IL_0024 + + IL_0016: ldloca.s V_0 + IL_0018: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_001d: ldc.i4.5 + IL_001e: add + IL_001f: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0024: stloc.2 + IL_0025: ldloca.s V_2 + IL_0027: dup + IL_0028: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_002d: stloc.3 + IL_002e: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0033: brfalse.s IL_0044 + + IL_0035: ldloc.3 + IL_0036: ldc.i4.0 + IL_0037: beq.s IL_0044 + + IL_0039: ldloc.3 + IL_003a: ldc.i4.5 + IL_003b: beq.s IL_004a + + IL_003d: ldloc.3 + IL_003e: ldc.i4.s 10 + IL_0040: beq.s IL_0050 + + IL_0042: br.s IL_0056 + + IL_0044: ldstr "zero" + IL_0049: ret + + IL_004a: ldstr "five" + IL_004f: ret + + IL_0050: ldstr "ten" + IL_0055: ret + + IL_0056: ldstr "large" + IL_005b: ret + } // end of method Switch::SwitchOverNullableIntShiftedNullCaseCombined + + .method public hidebysig static string + SwitchOverNullableIntNoNullCase(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 55 (0x37) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldarga.s i + IL_0002: dup + IL_0003: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0008: stloc.0 + IL_0009: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000e: brfalse.s IL_0031 + + IL_0010: ldloc.0 + IL_0011: ldc.i4.0 + IL_0012: beq.s IL_001f + + IL_0014: ldloc.0 + IL_0015: ldc.i4.5 + IL_0016: beq.s IL_0025 + + IL_0018: ldloc.0 + IL_0019: ldc.i4.s 10 + IL_001b: beq.s IL_002b + + IL_001d: br.s IL_0031 + + IL_001f: ldstr "zero" + IL_0024: ret + + IL_0025: ldstr "five" + IL_002a: ret + + IL_002b: ldstr "ten" + IL_0030: ret + + IL_0031: ldstr "other" + IL_0036: ret + } // end of method Switch::SwitchOverNullableIntNoNullCase + + .method public hidebysig static string + SwitchOverNullableIntNoNullCaseShifted(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 92 (0x5c) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype [mscorlib]System.Nullable`1 V_2, + int32 V_3) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0009: brtrue.s IL_0016 + + IL_000b: ldloca.s V_1 + IL_000d: initobj valuetype [mscorlib]System.Nullable`1 + IL_0013: ldloc.1 + IL_0014: br.s IL_0024 + + IL_0016: ldloca.s V_0 + IL_0018: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_001d: ldc.i4.5 + IL_001e: add + IL_001f: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0024: stloc.2 + IL_0025: ldloca.s V_2 + IL_0027: dup + IL_0028: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_002d: stloc.3 + IL_002e: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0033: brfalse.s IL_0056 + + IL_0035: ldloc.3 + IL_0036: ldc.i4.0 + IL_0037: beq.s IL_0044 + + IL_0039: ldloc.3 + IL_003a: ldc.i4.5 + IL_003b: beq.s IL_004a + + IL_003d: ldloc.3 + IL_003e: ldc.i4.s 10 + IL_0040: beq.s IL_0050 + + IL_0042: br.s IL_0056 + + IL_0044: ldstr "zero" + IL_0049: ret + + IL_004a: ldstr "five" + IL_004f: ret + + IL_0050: ldstr "ten" + IL_0055: ret + + IL_0056: ldstr "other" + IL_005b: ret + } // end of method Switch::SwitchOverNullableIntNoNullCaseShifted + + .method public hidebysig static void SwitchOverInt(int32 i) cil managed + { + // Code size 125 (0x7d) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: ldc.i4.s 10 + IL_0005: bgt.s IL_0015 + + IL_0007: ldloc.0 + IL_0008: ldc.i4.0 + IL_0009: beq.s IL_0030 + + IL_000b: ldloc.0 + IL_000c: ldc.i4.5 + IL_000d: beq.s IL_003b + + IL_000f: ldloc.0 + IL_0010: ldc.i4.s 10 + IL_0012: beq.s IL_0046 + + IL_0014: ret + + IL_0015: ldloc.0 + IL_0016: ldc.i4.s 20 + IL_0018: bgt.s IL_0025 + + IL_001a: ldloc.0 + IL_001b: ldc.i4.s 15 + IL_001d: beq.s IL_0051 + + IL_001f: ldloc.0 + IL_0020: ldc.i4.s 20 + IL_0022: beq.s IL_005c + + IL_0024: ret + + IL_0025: ldloc.0 + IL_0026: ldc.i4.s 25 + IL_0028: beq.s IL_0067 + + IL_002a: ldloc.0 + IL_002b: ldc.i4.s 30 + IL_002d: beq.s IL_0072 + + IL_002f: ret + + IL_0030: ldstr "zero" + IL_0035: call void [mscorlib]System.Console::WriteLine(string) + IL_003a: ret + + IL_003b: ldstr "five" + IL_0040: call void [mscorlib]System.Console::WriteLine(string) + IL_0045: ret + + IL_0046: ldstr "ten" + IL_004b: call void [mscorlib]System.Console::WriteLine(string) + IL_0050: ret + + IL_0051: ldstr "fifteen" + IL_0056: call void [mscorlib]System.Console::WriteLine(string) + IL_005b: ret + + IL_005c: ldstr "twenty" + IL_0061: call void [mscorlib]System.Console::WriteLine(string) + IL_0066: ret + + IL_0067: ldstr "twenty-five" + IL_006c: call void [mscorlib]System.Console::WriteLine(string) + IL_0071: ret + + IL_0072: ldstr "thirty" + IL_0077: call void [mscorlib]System.Console::WriteLine(string) + IL_007c: ret + } // end of method Switch::SwitchOverInt + + .method public hidebysig static string + ShortSwitchOverString(string text) cil managed + { + // Code size 86 (0x56) + .maxstack 2 + .locals init (string V_0) + IL_0000: ldstr "ShortSwitchOverString: " + IL_0005: ldarg.0 + IL_0006: call string [mscorlib]System.String::Concat(string, + string) + IL_000b: call void [mscorlib]System.Console::WriteLine(string) + IL_0010: ldarg.0 + IL_0011: dup + IL_0012: stloc.0 + IL_0013: brfalse.s IL_0050 + + IL_0015: ldloc.0 + IL_0016: ldstr "First case" + IL_001b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0020: brtrue.s IL_003e + + IL_0022: ldloc.0 + IL_0023: ldstr "Second case" + IL_0028: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002d: brtrue.s IL_0044 + + IL_002f: ldloc.0 + IL_0030: ldstr "Third case" + IL_0035: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_003a: brtrue.s IL_004a + + IL_003c: br.s IL_0050 + + IL_003e: ldstr "Text1" + IL_0043: ret + + IL_0044: ldstr "Text2" + IL_0049: ret + + IL_004a: ldstr "Text3" + IL_004f: ret + + IL_0050: ldstr "Default" + IL_0055: ret + } // end of method Switch::ShortSwitchOverString + + .method public hidebysig static string + ShortSwitchOverStringWithNullCase(string text) cil managed + { + // Code size 73 (0x49) + .maxstack 2 + .locals init (string V_0) + IL_0000: ldstr "ShortSwitchOverStringWithNullCase: " + IL_0005: ldarg.0 + IL_0006: call string [mscorlib]System.String::Concat(string, + string) + IL_000b: call void [mscorlib]System.Console::WriteLine(string) + IL_0010: ldarg.0 + IL_0011: dup + IL_0012: stloc.0 + IL_0013: brfalse.s IL_003d + + IL_0015: ldloc.0 + IL_0016: ldstr "First case" + IL_001b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0020: brtrue.s IL_0031 + + IL_0022: ldloc.0 + IL_0023: ldstr "Second case" + IL_0028: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002d: brtrue.s IL_0037 + + IL_002f: br.s IL_0043 + + IL_0031: ldstr "Text1" + IL_0036: ret + + IL_0037: ldstr "Text2" + IL_003c: ret + + IL_003d: ldstr "null" + IL_0042: ret + + IL_0043: ldstr "Default" + IL_0048: ret + } // end of method Switch::ShortSwitchOverStringWithNullCase + + .method public hidebysig static string + SwitchOverString1(string text) cil managed + { + // Code size 227 (0xe3) + .maxstack 4 + .locals init (string V_0, + int32 V_1) + IL_0000: ldstr "SwitchOverString1: " + IL_0005: ldarg.0 + IL_0006: call string [mscorlib]System.String::Concat(string, + string) + IL_000b: call void [mscorlib]System.Console::WriteLine(string) + IL_0010: ldarg.0 + IL_0011: dup + IL_0012: stloc.0 + IL_0013: brfalse IL_00db + + IL_0018: volatile. + IL_001a: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{FFEEBB9C-152A-467A-A4B4-51CF03878E20}'::'$$method0x600000d-1' + IL_001f: brtrue.s IL_0082 + + IL_0021: ldc.i4.7 + IL_0022: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) + IL_0027: dup + IL_0028: ldstr "First case" + IL_002d: ldc.i4.0 + IL_002e: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0033: dup + IL_0034: ldstr "Second case" + IL_0039: ldc.i4.1 + IL_003a: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_003f: dup + IL_0040: ldstr "2nd case" + IL_0045: ldc.i4.2 + IL_0046: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_004b: dup + IL_004c: ldstr "Third case" + IL_0051: ldc.i4.3 + IL_0052: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0057: dup + IL_0058: ldstr "Fourth case" + IL_005d: ldc.i4.4 + IL_005e: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0063: dup + IL_0064: ldstr "Fifth case" + IL_0069: ldc.i4.5 + IL_006a: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_006f: dup + IL_0070: ldstr "Sixth case" + IL_0075: ldc.i4.6 + IL_0076: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_007b: volatile. + IL_007d: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{FFEEBB9C-152A-467A-A4B4-51CF03878E20}'::'$$method0x600000d-1' + IL_0082: volatile. + IL_0084: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{FFEEBB9C-152A-467A-A4B4-51CF03878E20}'::'$$method0x600000d-1' + IL_0089: ldloc.0 + IL_008a: ldloca.s V_1 + IL_008c: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, + !1&) + IL_0091: brfalse.s IL_00dd + + IL_0093: ldloc.1 + IL_0094: switch ( + IL_00b7, + IL_00bd, + IL_00bd, + IL_00c3, + IL_00c9, + IL_00cf, + IL_00d5) + IL_00b5: br.s IL_00dd + + IL_00b7: ldstr "Text1" + IL_00bc: ret + + IL_00bd: ldstr "Text2" + IL_00c2: ret + + IL_00c3: ldstr "Text3" + IL_00c8: ret + + IL_00c9: ldstr "Text4" + IL_00ce: ret + + IL_00cf: ldstr "Text5" + IL_00d4: ret + + IL_00d5: ldstr "Text6" + IL_00da: ret + + IL_00db: ldnull + IL_00dc: ret + + IL_00dd: ldstr "Default" + IL_00e2: ret + } // end of method Switch::SwitchOverString1 + + .method public hidebysig static string + SwitchOverString2() cil managed + { + // Code size 323 (0x143) + .maxstack 4 + .locals init (string V_0, + int32 V_1) + IL_0000: ldstr "SwitchOverString2:" + IL_0005: call void [mscorlib]System.Console::WriteLine(string) + IL_000a: call string [mscorlib]System.Environment::get_UserName() + IL_000f: dup + IL_0010: stloc.0 + IL_0011: brfalse IL_013d + + IL_0016: volatile. + IL_0018: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{FFEEBB9C-152A-467A-A4B4-51CF03878E20}'::'$$method0x600000e-1' + IL_001d: brtrue IL_00b6 + + IL_0022: ldc.i4.s 11 + IL_0024: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) + IL_0029: dup + IL_002a: ldstr "First case" + IL_002f: ldc.i4.0 + IL_0030: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0035: dup + IL_0036: ldstr "Second case" + IL_003b: ldc.i4.1 + IL_003c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0041: dup + IL_0042: ldstr "Third case" + IL_0047: ldc.i4.2 + IL_0048: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_004d: dup + IL_004e: ldstr "Fourth case" + IL_0053: ldc.i4.3 + IL_0054: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0059: dup + IL_005a: ldstr "Fifth case" + IL_005f: ldc.i4.4 + IL_0060: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0065: dup + IL_0066: ldstr "Sixth case" + IL_006b: ldc.i4.5 + IL_006c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0071: dup + IL_0072: ldstr "Seventh case" + IL_0077: ldc.i4.6 + IL_0078: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_007d: dup + IL_007e: ldstr "Eighth case" + IL_0083: ldc.i4.7 + IL_0084: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0089: dup + IL_008a: ldstr "Ninth case" + IL_008f: ldc.i4.8 + IL_0090: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0095: dup + IL_0096: ldstr "Tenth case" + IL_009b: ldc.i4.s 9 + IL_009d: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_00a2: dup + IL_00a3: ldstr "Eleventh case" + IL_00a8: ldc.i4.s 10 + IL_00aa: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_00af: volatile. + IL_00b1: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{FFEEBB9C-152A-467A-A4B4-51CF03878E20}'::'$$method0x600000e-1' + IL_00b6: volatile. + IL_00b8: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{FFEEBB9C-152A-467A-A4B4-51CF03878E20}'::'$$method0x600000e-1' + IL_00bd: ldloc.0 + IL_00be: ldloca.s V_1 + IL_00c0: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, + !1&) + IL_00c5: brfalse.s IL_013d + + IL_00c7: ldloc.1 + IL_00c8: switch ( + IL_00fb, + IL_0101, + IL_0107, + IL_010d, + IL_0113, + IL_0119, + IL_011f, + IL_0125, + IL_012b, + IL_0131, + IL_0137) + IL_00f9: br.s IL_013d + + IL_00fb: ldstr "Text1" + IL_0100: ret + + IL_0101: ldstr "Text2" + IL_0106: ret + + IL_0107: ldstr "Text3" + IL_010c: ret + + IL_010d: ldstr "Text4" + IL_0112: ret + + IL_0113: ldstr "Text5" + IL_0118: ret + + IL_0119: ldstr "Text6" + IL_011e: ret + + IL_011f: ldstr "Text7" + IL_0124: ret + + IL_0125: ldstr "Text8" + IL_012a: ret + + IL_012b: ldstr "Text9" + IL_0130: ret + + IL_0131: ldstr "Text10" + IL_0136: ret + + IL_0137: ldstr "Text11" + IL_013c: ret + + IL_013d: ldstr "Default" + IL_0142: ret + } // end of method Switch::SwitchOverString2 + + .method public hidebysig static string + SwitchOverBool(bool b) cil managed + { + // Code size 54 (0x36) + .maxstack 2 + .locals init (bool V_0) + IL_0000: ldstr "SwitchOverBool: " + IL_0005: ldarga.s b + IL_0007: call instance string [mscorlib]System.Boolean::ToString() + IL_000c: call string [mscorlib]System.String::Concat(string, + string) + IL_0011: call void [mscorlib]System.Console::WriteLine(string) + IL_0016: ldarg.0 + IL_0017: stloc.0 + IL_0018: ldloc.0 + IL_0019: switch ( + IL_002e, + IL_0028) + IL_0026: br.s IL_0034 + + IL_0028: ldsfld string [mscorlib]System.Boolean::TrueString + IL_002d: ret + + IL_002e: ldsfld string [mscorlib]System.Boolean::FalseString + IL_0033: ret + + IL_0034: ldnull + IL_0035: ret + } // end of method Switch::SwitchOverBool + + .method public hidebysig static void SwitchInLoop(int32 i) cil managed + { + // Code size 112 (0x70) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldstr "SwitchInLoop: " + IL_0005: ldarg.0 + IL_0006: box [mscorlib]System.Int32 + IL_000b: call string [mscorlib]System.String::Concat(object, + object) + IL_0010: call void [mscorlib]System.Console::WriteLine(string) + IL_0015: ldarg.0 + IL_0016: stloc.0 + IL_0017: ldloc.0 + IL_0018: ldc.i4.1 + IL_0019: sub + IL_001a: switch ( + IL_0031, + IL_003d, + IL_0054, + IL_0049) + IL_002f: br.s IL_0054 + + IL_0031: ldstr "one" + IL_0036: call void [mscorlib]System.Console::WriteLine(string) + IL_003b: br.s IL_0069 + + IL_003d: ldstr "two" + IL_0042: call void [mscorlib]System.Console::WriteLine(string) + IL_0047: br.s IL_0069 + + IL_0049: ldstr "four" + IL_004e: call void [mscorlib]System.Console::WriteLine(string) + IL_0053: ret + + IL_0054: ldstr "default" + IL_0059: call void [mscorlib]System.Console::WriteLine(string) + IL_005e: ldstr "more code" + IL_0063: call void [mscorlib]System.Console::WriteLine(string) + IL_0068: ret + + IL_0069: ldarg.0 + IL_006a: ldc.i4.1 + IL_006b: add + IL_006c: starg.s i + IL_006e: br.s IL_0015 + } // end of method Switch::SwitchInLoop + + .method public hidebysig static void SwitchWithGoto(int32 i) cil managed + { + // Code size 115 (0x73) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: ldstr "SwitchWithGoto: " + IL_0005: ldarg.0 + IL_0006: box [mscorlib]System.Int32 + IL_000b: call string [mscorlib]System.String::Concat(object, + object) + IL_0010: call void [mscorlib]System.Console::WriteLine(string) + IL_0015: ldarg.0 + IL_0016: stloc.0 + IL_0017: ldloc.0 + IL_0018: ldc.i4.1 + IL_0019: sub + IL_001a: switch ( + IL_0031, + IL_003d, + IL_0047, + IL_0053) + IL_002f: br.s IL_005e + + IL_0031: ldstr "one" + IL_0036: call void [mscorlib]System.Console::WriteLine(string) + IL_003b: br.s IL_005e + + IL_003d: ldstr "two" + IL_0042: call void [mscorlib]System.Console::WriteLine(string) + IL_0047: ldstr "three" + IL_004c: call void [mscorlib]System.Console::WriteLine(string) + IL_0051: br.s IL_0068 + + IL_0053: ldstr "four" + IL_0058: call void [mscorlib]System.Console::WriteLine(string) + IL_005d: ret + + IL_005e: ldstr "default" + IL_0063: call void [mscorlib]System.Console::WriteLine(string) + IL_0068: ldstr "End of method" + IL_006d: call void [mscorlib]System.Console::WriteLine(string) + IL_0072: ret + } // end of method Switch::SwitchWithGoto + + .method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] + GetProperties() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: newarr ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty + IL_0006: ret + } // end of method Switch::GetProperties + + .method public hidebysig static void SwitchOnStringInForLoop() cil managed + { + // Code size 299 (0x12b) + .maxstack 4 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0, + class [mscorlib]System.Collections.Generic.List`1 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] V_2, + int32 V_3, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty V_4, + string V_5, + int32 V_6) + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0005: stloc.0 + IL_0006: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000b: stloc.1 + IL_000c: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch::GetProperties() + IL_0011: stloc.2 + IL_0012: ldc.i4.0 + IL_0013: stloc.3 + IL_0014: br IL_0121 + + IL_0019: ldloc.2 + IL_001a: ldloc.3 + IL_001b: ldelem.ref + IL_001c: stloc.s V_4 + IL_001e: ldloc.s V_4 + IL_0020: ldfld class [mscorlib]System.Reflection.PropertyInfo ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::Property + IL_0025: callvirt instance string [mscorlib]System.Reflection.MemberInfo::get_Name() + IL_002a: dup + IL_002b: stloc.s V_5 + IL_002d: brfalse IL_0115 + + IL_0032: volatile. + IL_0034: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{FFEEBB9C-152A-467A-A4B4-51CF03878E20}'::'$$method0x6000013-1' + IL_0039: brtrue.s IL_0090 + + IL_003b: ldc.i4.6 + IL_003c: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) + IL_0041: dup + IL_0042: ldstr "Name1" + IL_0047: ldc.i4.0 + IL_0048: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_004d: dup + IL_004e: ldstr "Name2" + IL_0053: ldc.i4.1 + IL_0054: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0059: dup + IL_005a: ldstr "Name3" + IL_005f: ldc.i4.2 + IL_0060: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0065: dup + IL_0066: ldstr "Name4" + IL_006b: ldc.i4.3 + IL_006c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0071: dup + IL_0072: ldstr "Name5" + IL_0077: ldc.i4.4 + IL_0078: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_007d: dup + IL_007e: ldstr "Name6" + IL_0083: ldc.i4.5 + IL_0084: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + !1) + IL_0089: volatile. + IL_008b: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{FFEEBB9C-152A-467A-A4B4-51CF03878E20}'::'$$method0x6000013-1' + IL_0090: volatile. + IL_0092: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{FFEEBB9C-152A-467A-A4B4-51CF03878E20}'::'$$method0x6000013-1' + IL_0097: ldloc.s V_5 + IL_0099: ldloca.s V_6 + IL_009b: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, + !1&) + IL_00a0: brfalse.s IL_0115 + + IL_00a2: ldloc.s V_6 + IL_00a4: switch ( + IL_00c3, + IL_00d5, + IL_00e7, + IL_00f9, + IL_010b, + IL_010b) + IL_00c1: br.s IL_0115 + + IL_00c3: ldloc.s V_4 + IL_00c5: ldc.i4.1 + IL_00c6: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00cb: ldloc.0 + IL_00cc: ldloc.s V_4 + IL_00ce: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00d3: br.s IL_011d + + IL_00d5: ldloc.s V_4 + IL_00d7: ldc.i4.2 + IL_00d8: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00dd: ldloc.0 + IL_00de: ldloc.s V_4 + IL_00e0: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00e5: br.s IL_011d + + IL_00e7: ldloc.s V_4 + IL_00e9: ldc.i4.3 + IL_00ea: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00ef: ldloc.0 + IL_00f0: ldloc.s V_4 + IL_00f2: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00f7: br.s IL_011d + + IL_00f9: ldloc.s V_4 + IL_00fb: ldc.i4.4 + IL_00fc: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_0101: ldloc.0 + IL_0102: ldloc.s V_4 + IL_0104: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0109: br.s IL_011d + + IL_010b: ldloc.0 + IL_010c: ldloc.s V_4 + IL_010e: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0113: br.s IL_011d + + IL_0115: ldloc.1 + IL_0116: ldloc.s V_4 + IL_0118: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_011d: ldloc.3 + IL_011e: ldc.i4.1 + IL_011f: add + IL_0120: stloc.3 + IL_0121: ldloc.3 + IL_0122: ldloc.2 + IL_0123: ldlen + IL_0124: conv.i4 + IL_0125: blt IL_0019 + + IL_012a: ret + } // end of method Switch::SwitchOnStringInForLoop + + .method public hidebysig static void SwitchWithComplexCondition(string[] args) cil managed + { + // Code size 130 (0x82) + .maxstack 2 + .locals init (string V_0) + IL_0000: ldarg.0 + IL_0001: ldlen + IL_0002: conv.i4 + IL_0003: brfalse.s IL_000a + + IL_0005: ldarg.0 + IL_0006: ldc.i4.0 + IL_0007: ldelem.ref + IL_0008: br.s IL_000f + + IL_000a: ldstr "dummy" + IL_000f: dup + IL_0010: stloc.0 + IL_0011: brfalse.s IL_0077 + + IL_0013: ldloc.0 + IL_0014: ldstr "a" + IL_0019: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_001e: brtrue.s IL_0049 + + IL_0020: ldloc.0 + IL_0021: ldstr "b" + IL_0026: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002b: brtrue.s IL_0055 + + IL_002d: ldloc.0 + IL_002e: ldstr "c" + IL_0033: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0038: brtrue.s IL_0061 + + IL_003a: ldloc.0 + IL_003b: ldstr "d" + IL_0040: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0045: brtrue.s IL_006d + + IL_0047: br.s IL_0077 + + IL_0049: ldstr "a" + IL_004e: call void [mscorlib]System.Console::WriteLine(string) + IL_0053: br.s IL_0077 + + IL_0055: ldstr "b" + IL_005a: call void [mscorlib]System.Console::WriteLine(string) + IL_005f: br.s IL_0077 + + IL_0061: ldstr "c" + IL_0066: call void [mscorlib]System.Console::WriteLine(string) + IL_006b: br.s IL_0077 + + IL_006d: ldstr "d" + IL_0072: call void [mscorlib]System.Console::WriteLine(string) + IL_0077: ldstr "end" + IL_007c: call void [mscorlib]System.Console::WriteLine(string) + IL_0081: ret + } // end of method Switch::SwitchWithComplexCondition + + .method public hidebysig static void SwitchWithArray(string[] args) cil managed + { + // Code size 118 (0x76) + .maxstack 2 + .locals init (string V_0) + IL_0000: ldarg.0 + IL_0001: ldc.i4.0 + IL_0002: ldelem.ref + IL_0003: dup + IL_0004: stloc.0 + IL_0005: brfalse.s IL_006b + + IL_0007: ldloc.0 + IL_0008: ldstr "a" + IL_000d: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0012: brtrue.s IL_003d + + IL_0014: ldloc.0 + IL_0015: ldstr "b" + IL_001a: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_001f: brtrue.s IL_0049 + + IL_0021: ldloc.0 + IL_0022: ldstr "c" + IL_0027: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002c: brtrue.s IL_0055 + + IL_002e: ldloc.0 + IL_002f: ldstr "d" + IL_0034: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0039: brtrue.s IL_0061 + + IL_003b: br.s IL_006b + + IL_003d: ldstr "a" + IL_0042: call void [mscorlib]System.Console::WriteLine(string) + IL_0047: br.s IL_006b + + IL_0049: ldstr "b" + IL_004e: call void [mscorlib]System.Console::WriteLine(string) + IL_0053: br.s IL_006b + + IL_0055: ldstr "c" + IL_005a: call void [mscorlib]System.Console::WriteLine(string) + IL_005f: br.s IL_006b + + IL_0061: ldstr "d" + IL_0066: call void [mscorlib]System.Console::WriteLine(string) + IL_006b: ldstr "end" + IL_0070: call void [mscorlib]System.Console::WriteLine(string) + IL_0075: ret + } // end of method Switch::SwitchWithArray + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch + +.class private auto ansi '{FFEEBB9C-152A-467A-A4B4-51CF03878E20}' + extends [mscorlib]System.Object +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x600000d-1' + .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x600000e-1' + .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x6000013-1' +} // end of class '{FFEEBB9C-152A-467A-A4B4-51CF03878E20}' + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** +// Warnung: Win32-Ressourcendatei "../../../TestCases/Pretty\Switch.opt.res" wurde erstellt. diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.roslyn.il new file mode 100644 index 000000000..c2c1f5cae --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.roslyn.il @@ -0,0 +1,1502 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly Switch +{ + .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 Switch.dll +// MVID: {5D628BA5-FC59-43EC-A162-63729510F134} +.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: 0x01390000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch + extends [mscorlib]System.Object +{ + .class auto ansi nested public beforefieldinit SetProperty + extends [mscorlib]System.Object + { + .field public initonly class [mscorlib]System.Reflection.PropertyInfo Property + .field private int32 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method public hidebysig specialname + instance int32 get_Set() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::'k__BackingField' + IL_0006: ret + } // end of method SetProperty::get_Set + + .method public hidebysig specialname + instance void set_Set(int32 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::'k__BackingField' + IL_0007: ret + } // end of method SetProperty::set_Set + + .method public hidebysig specialname rtspecialname + instance void .ctor(class [mscorlib]System.Reflection.PropertyInfo 'property') cil managed + { + // Code size 14 (0xe) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [mscorlib]System.Reflection.PropertyInfo ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::Property + IL_000d: ret + } // end of method SetProperty::.ctor + + .property instance int32 Set() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::get_Set() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + } // end of property SetProperty::Set + } // end of class SetProperty + + .class auto ansi sealed nested public State + extends [mscorlib]System.Enum + { + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State False = int32(0x00000000) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State True = int32(0x00000001) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State Null = int32(0x00000002) + } // end of class State + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State + SwitchOverNullableBool(valuetype [mscorlib]System.Nullable`1 'value') cil managed + { + // Code size 40 (0x28) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + bool V_1) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0009: brfalse.s IL_0020 + + IL_000b: ldloca.s V_0 + IL_000d: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0012: stloc.1 + IL_0013: ldloc.1 + IL_0014: brfalse.s IL_001c + + IL_0016: ldloc.1 + IL_0017: ldc.i4.1 + IL_0018: beq.s IL_001e + + IL_001a: br.s IL_0022 + + IL_001c: ldc.i4.0 + IL_001d: ret + + IL_001e: ldc.i4.1 + IL_001f: ret + + IL_0020: ldc.i4.2 + IL_0021: ret + + IL_0022: newobj instance void [mscorlib]System.InvalidOperationException::.ctor() + IL_0027: throw + } // end of method Switch::SwitchOverNullableBool + + .method public hidebysig static valuetype [mscorlib]System.Nullable`1 + SwitchOverNullableEnum(valuetype [mscorlib]System.Nullable`1 state) cil managed + { + // Code size 69 (0x45) + .maxstack 1 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State V_1, + valuetype [mscorlib]System.Nullable`1 V_2) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0009: brfalse.s IL_003f + + IL_000b: ldloca.s V_0 + IL_000d: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0012: stloc.1 + IL_0013: ldloc.1 + IL_0014: switch ( + IL_0027, + IL_002e, + IL_0035) + IL_0025: br.s IL_003f + + IL_0027: ldc.i4.0 + IL_0028: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_002d: ret + + IL_002e: ldc.i4.1 + IL_002f: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0034: ret + + IL_0035: ldloca.s V_2 + IL_0037: initobj valuetype [mscorlib]System.Nullable`1 + IL_003d: ldloc.2 + IL_003e: ret + + IL_003f: newobj instance void [mscorlib]System.InvalidOperationException::.ctor() + IL_0044: throw + } // end of method Switch::SwitchOverNullableEnum + + .method public hidebysig static string + SparseIntegerSwitch(int32 i) cil managed + { + // Code size 185 (0xb9) + .maxstack 2 + IL_0000: ldstr "SparseIntegerSwitch: " + IL_0005: ldarg.0 + IL_0006: box [mscorlib]System.Int32 + IL_000b: call string [mscorlib]System.String::Concat(object, + object) + IL_0010: call void [mscorlib]System.Console::WriteLine(string) + IL_0015: ldarg.0 + IL_0016: ldc.i4.4 + IL_0017: bgt.s IL_0048 + + IL_0019: ldarg.0 + IL_001a: ldc.i4 0xff676980 + IL_001f: beq.s IL_0071 + + IL_0021: ldarg.0 + IL_0022: ldc.i4.s -100 + IL_0024: beq.s IL_0077 + + IL_0026: ldarg.0 + IL_0027: ldc.i4.m1 + IL_0028: sub + IL_0029: switch ( + IL_007d, + IL_0083, + IL_0089, + IL_008f, + IL_00b3, + IL_0095) + IL_0046: br.s IL_00b3 + + IL_0048: ldarg.0 + IL_0049: ldc.i4 0x2710 + IL_004e: bgt.s IL_005f + + IL_0050: ldarg.0 + IL_0051: ldc.i4.s 100 + IL_0053: beq.s IL_009b + + IL_0055: ldarg.0 + IL_0056: ldc.i4 0x2710 + IL_005b: beq.s IL_00a1 + + IL_005d: br.s IL_00b3 + + IL_005f: ldarg.0 + IL_0060: ldc.i4 0x2711 + IL_0065: beq.s IL_00a7 + + IL_0067: ldarg.0 + IL_0068: ldc.i4 0x7fffffff + IL_006d: beq.s IL_00ad + + IL_006f: br.s IL_00b3 + + IL_0071: ldstr "-10 mln" + IL_0076: ret + + IL_0077: ldstr "-hundred" + IL_007c: ret + + IL_007d: ldstr "-1" + IL_0082: ret + + IL_0083: ldstr "0" + IL_0088: ret + + IL_0089: ldstr "1" + IL_008e: ret + + IL_008f: ldstr "2" + IL_0094: ret + + IL_0095: ldstr "4" + IL_009a: ret + + IL_009b: ldstr "hundred" + IL_00a0: ret + + IL_00a1: ldstr "ten thousand" + IL_00a6: ret + + IL_00a7: ldstr "ten thousand and one" + IL_00ac: ret + + IL_00ad: ldstr "int.MaxValue" + IL_00b2: ret + + IL_00b3: ldstr "something else" + IL_00b8: ret + } // end of method Switch::SparseIntegerSwitch + + .method public hidebysig static string + SwitchOverNullableInt(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 63 (0x3f) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + int32 V_1) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0009: brfalse.s IL_0021 + + IL_000b: ldloca.s V_0 + IL_000d: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0012: stloc.1 + IL_0013: ldloc.1 + IL_0014: brfalse.s IL_0027 + + IL_0016: ldloc.1 + IL_0017: ldc.i4.5 + IL_0018: beq.s IL_002d + + IL_001a: ldloc.1 + IL_001b: ldc.i4.s 10 + IL_001d: beq.s IL_0033 + + IL_001f: br.s IL_0039 + + IL_0021: ldstr "null" + IL_0026: ret + + IL_0027: ldstr "zero" + IL_002c: ret + + IL_002d: ldstr "five" + IL_0032: ret + + IL_0033: ldstr "ten" + IL_0038: ret + + IL_0039: ldstr "large" + IL_003e: ret + } // end of method Switch::SwitchOverNullableInt + + .method public hidebysig static string + SwitchOverNullableIntNullCaseCombined(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 57 (0x39) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + int32 V_1) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0009: brfalse.s IL_0021 + + IL_000b: ldloca.s V_0 + IL_000d: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0012: stloc.1 + IL_0013: ldloc.1 + IL_0014: brfalse.s IL_0021 + + IL_0016: ldloc.1 + IL_0017: ldc.i4.5 + IL_0018: beq.s IL_0027 + + IL_001a: ldloc.1 + IL_001b: ldc.i4.s 10 + IL_001d: beq.s IL_002d + + IL_001f: br.s IL_0033 + + IL_0021: ldstr "zero" + IL_0026: ret + + IL_0027: ldstr "five" + IL_002c: ret + + IL_002d: ldstr "ten" + IL_0032: ret + + IL_0033: ldstr "large" + IL_0038: ret + } // end of method Switch::SwitchOverNullableIntNullCaseCombined + + .method public hidebysig static string + SwitchOverNullableIntShifted(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 98 (0x62) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype [mscorlib]System.Nullable`1 V_2, + int32 V_3) + IL_0000: ldarg.0 + IL_0001: stloc.1 + IL_0002: ldloca.s V_1 + IL_0004: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0009: brtrue.s IL_0016 + + IL_000b: ldloca.s V_2 + IL_000d: initobj valuetype [mscorlib]System.Nullable`1 + IL_0013: ldloc.2 + IL_0014: br.s IL_0024 + + IL_0016: ldloca.s V_1 + IL_0018: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_001d: ldc.i4.5 + IL_001e: add + IL_001f: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0024: stloc.0 + IL_0025: ldloca.s V_0 + IL_0027: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_002c: brfalse.s IL_0044 + + IL_002e: ldloca.s V_0 + IL_0030: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0035: stloc.3 + IL_0036: ldloc.3 + IL_0037: brfalse.s IL_004a + + IL_0039: ldloc.3 + IL_003a: ldc.i4.5 + IL_003b: beq.s IL_0050 + + IL_003d: ldloc.3 + IL_003e: ldc.i4.s 10 + IL_0040: beq.s IL_0056 + + IL_0042: br.s IL_005c + + IL_0044: ldstr "null" + IL_0049: ret + + IL_004a: ldstr "zero" + IL_004f: ret + + IL_0050: ldstr "five" + IL_0055: ret + + IL_0056: ldstr "ten" + IL_005b: ret + + IL_005c: ldstr "large" + IL_0061: ret + } // end of method Switch::SwitchOverNullableIntShifted + + .method public hidebysig static string + SwitchOverNullableIntShiftedNullCaseCombined(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 92 (0x5c) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype [mscorlib]System.Nullable`1 V_2, + int32 V_3) + IL_0000: ldarg.0 + IL_0001: stloc.1 + IL_0002: ldloca.s V_1 + IL_0004: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0009: brtrue.s IL_0016 + + IL_000b: ldloca.s V_2 + IL_000d: initobj valuetype [mscorlib]System.Nullable`1 + IL_0013: ldloc.2 + IL_0014: br.s IL_0024 + + IL_0016: ldloca.s V_1 + IL_0018: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_001d: ldc.i4.5 + IL_001e: add + IL_001f: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0024: stloc.0 + IL_0025: ldloca.s V_0 + IL_0027: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_002c: brfalse.s IL_0044 + + IL_002e: ldloca.s V_0 + IL_0030: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0035: stloc.3 + IL_0036: ldloc.3 + IL_0037: brfalse.s IL_0044 + + IL_0039: ldloc.3 + IL_003a: ldc.i4.5 + IL_003b: beq.s IL_004a + + IL_003d: ldloc.3 + IL_003e: ldc.i4.s 10 + IL_0040: beq.s IL_0050 + + IL_0042: br.s IL_0056 + + IL_0044: ldstr "zero" + IL_0049: ret + + IL_004a: ldstr "five" + IL_004f: ret + + IL_0050: ldstr "ten" + IL_0055: ret + + IL_0056: ldstr "large" + IL_005b: ret + } // end of method Switch::SwitchOverNullableIntShiftedNullCaseCombined + + .method public hidebysig static string + SwitchOverNullableIntNoNullCase(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 57 (0x39) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + int32 V_1) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0009: brfalse.s IL_0033 + + IL_000b: ldloca.s V_0 + IL_000d: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0012: stloc.1 + IL_0013: ldloc.1 + IL_0014: brfalse.s IL_0021 + + IL_0016: ldloc.1 + IL_0017: ldc.i4.5 + IL_0018: beq.s IL_0027 + + IL_001a: ldloc.1 + IL_001b: ldc.i4.s 10 + IL_001d: beq.s IL_002d + + IL_001f: br.s IL_0033 + + IL_0021: ldstr "zero" + IL_0026: ret + + IL_0027: ldstr "five" + IL_002c: ret + + IL_002d: ldstr "ten" + IL_0032: ret + + IL_0033: ldstr "other" + IL_0038: ret + } // end of method Switch::SwitchOverNullableIntNoNullCase + + .method public hidebysig static string + SwitchOverNullableIntNoNullCaseShifted(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 92 (0x5c) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype [mscorlib]System.Nullable`1 V_2, + int32 V_3) + IL_0000: ldarg.0 + IL_0001: stloc.1 + IL_0002: ldloca.s V_1 + IL_0004: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_0009: brtrue.s IL_0016 + + IL_000b: ldloca.s V_2 + IL_000d: initobj valuetype [mscorlib]System.Nullable`1 + IL_0013: ldloc.2 + IL_0014: br.s IL_0024 + + IL_0016: ldloca.s V_1 + IL_0018: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_001d: ldc.i4.5 + IL_001e: add + IL_001f: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0024: stloc.0 + IL_0025: ldloca.s V_0 + IL_0027: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_002c: brfalse.s IL_0056 + + IL_002e: ldloca.s V_0 + IL_0030: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0035: stloc.3 + IL_0036: ldloc.3 + IL_0037: brfalse.s IL_0044 + + IL_0039: ldloc.3 + IL_003a: ldc.i4.5 + IL_003b: beq.s IL_004a + + IL_003d: ldloc.3 + IL_003e: ldc.i4.s 10 + IL_0040: beq.s IL_0050 + + IL_0042: br.s IL_0056 + + IL_0044: ldstr "zero" + IL_0049: ret + + IL_004a: ldstr "five" + IL_004f: ret + + IL_0050: ldstr "ten" + IL_0055: ret + + IL_0056: ldstr "other" + IL_005b: ret + } // end of method Switch::SwitchOverNullableIntNoNullCaseShifted + + .method public hidebysig static void SwitchOverInt(int32 i) cil managed + { + // Code size 122 (0x7a) + .maxstack 2 + IL_0000: ldarg.0 + IL_0001: ldc.i4.s 10 + IL_0003: bgt.s IL_0012 + + IL_0005: ldarg.0 + IL_0006: brfalse.s IL_002d + + IL_0008: ldarg.0 + IL_0009: ldc.i4.5 + IL_000a: beq.s IL_0038 + + IL_000c: ldarg.0 + IL_000d: ldc.i4.s 10 + IL_000f: beq.s IL_0043 + + IL_0011: ret + + IL_0012: ldarg.0 + IL_0013: ldc.i4.s 20 + IL_0015: bgt.s IL_0022 + + IL_0017: ldarg.0 + IL_0018: ldc.i4.s 15 + IL_001a: beq.s IL_004e + + IL_001c: ldarg.0 + IL_001d: ldc.i4.s 20 + IL_001f: beq.s IL_0059 + + IL_0021: ret + + IL_0022: ldarg.0 + IL_0023: ldc.i4.s 25 + IL_0025: beq.s IL_0064 + + IL_0027: ldarg.0 + IL_0028: ldc.i4.s 30 + IL_002a: beq.s IL_006f + + IL_002c: ret + + IL_002d: ldstr "zero" + IL_0032: call void [mscorlib]System.Console::WriteLine(string) + IL_0037: ret + + IL_0038: ldstr "five" + IL_003d: call void [mscorlib]System.Console::WriteLine(string) + IL_0042: ret + + IL_0043: ldstr "ten" + IL_0048: call void [mscorlib]System.Console::WriteLine(string) + IL_004d: ret + + IL_004e: ldstr "fifteen" + IL_0053: call void [mscorlib]System.Console::WriteLine(string) + IL_0058: ret + + IL_0059: ldstr "twenty" + IL_005e: call void [mscorlib]System.Console::WriteLine(string) + IL_0063: ret + + IL_0064: ldstr "twenty-five" + IL_0069: call void [mscorlib]System.Console::WriteLine(string) + IL_006e: ret + + IL_006f: ldstr "thirty" + IL_0074: call void [mscorlib]System.Console::WriteLine(string) + IL_0079: ret + } // end of method Switch::SwitchOverInt + + .method public hidebysig static string + ShortSwitchOverString(string text) cil managed + { + // Code size 81 (0x51) + .maxstack 2 + IL_0000: ldstr "ShortSwitchOverString: " + IL_0005: ldarg.0 + IL_0006: call string [mscorlib]System.String::Concat(string, + string) + IL_000b: call void [mscorlib]System.Console::WriteLine(string) + IL_0010: ldarg.0 + IL_0011: ldstr "First case" + IL_0016: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_001b: brtrue.s IL_0039 + + IL_001d: ldarg.0 + IL_001e: ldstr "Second case" + IL_0023: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0028: brtrue.s IL_003f + + IL_002a: ldarg.0 + IL_002b: ldstr "Third case" + IL_0030: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0035: brtrue.s IL_0045 + + IL_0037: br.s IL_004b + + IL_0039: ldstr "Text1" + IL_003e: ret + + IL_003f: ldstr "Text2" + IL_0044: ret + + IL_0045: ldstr "Text3" + IL_004a: ret + + IL_004b: ldstr "Default" + IL_0050: ret + } // end of method Switch::ShortSwitchOverString + + .method public hidebysig static string + ShortSwitchOverStringWithNullCase(string text) cil managed + { + // Code size 71 (0x47) + .maxstack 2 + IL_0000: ldstr "ShortSwitchOverStringWithNullCase: " + IL_0005: ldarg.0 + IL_0006: call string [mscorlib]System.String::Concat(string, + string) + IL_000b: call void [mscorlib]System.Console::WriteLine(string) + IL_0010: ldarg.0 + IL_0011: ldstr "First case" + IL_0016: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_001b: brtrue.s IL_002f + + IL_001d: ldarg.0 + IL_001e: ldstr "Second case" + IL_0023: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0028: brtrue.s IL_0035 + + IL_002a: ldarg.0 + IL_002b: brfalse.s IL_003b + + IL_002d: br.s IL_0041 + + IL_002f: ldstr "Text1" + IL_0034: ret + + IL_0035: ldstr "Text2" + IL_003a: ret + + IL_003b: ldstr "null" + IL_0040: ret + + IL_0041: ldstr "Default" + IL_0046: ret + } // end of method Switch::ShortSwitchOverStringWithNullCase + + .method public hidebysig static string + SwitchOverString1(string text) cil managed + { + // Code size 289 (0x121) + .maxstack 2 + .locals init (uint32 V_0) + IL_0000: ldstr "SwitchOverString1: " + IL_0005: ldarg.0 + IL_0006: call string [mscorlib]System.String::Concat(string, + string) + IL_000b: call void [mscorlib]System.Console::WriteLine(string) + IL_0010: ldarg.0 + IL_0011: call uint32 ''::ComputeStringHash(string) + IL_0016: stloc.0 + IL_0017: ldloc.0 + IL_0018: ldc.i4 0xf3d44a6 + IL_001d: bgt.un.s IL_0052 + + IL_001f: ldloc.0 + IL_0020: ldc.i4 0x8861b86 + IL_0025: bgt.un.s IL_003d + + IL_0027: ldloc.0 + IL_0028: brfalse IL_00f0 + + IL_002d: ldloc.0 + IL_002e: ldc.i4 0x8861b86 + IL_0033: beq IL_00d2 + + IL_0038: br IL_011b + + IL_003d: ldloc.0 + IL_003e: ldc.i4 0xc9a8f4f + IL_0043: beq.s IL_0084 + + IL_0045: ldloc.0 + IL_0046: ldc.i4 0xf3d44a6 + IL_004b: beq.s IL_00b4 + + IL_004d: br IL_011b + + IL_0052: ldloc.0 + IL_0053: ldc.i4 0x652a1179 + IL_0058: bgt.un.s IL_006f + + IL_005a: ldloc.0 + IL_005b: ldc.i4 0x51650fb9 + IL_0060: beq.s IL_00e1 + + IL_0062: ldloc.0 + IL_0063: ldc.i4 0x652a1179 + IL_0068: beq.s IL_00a5 + + IL_006a: br IL_011b + + IL_006f: ldloc.0 + IL_0070: ldc.i4 0xea3d096b + IL_0075: beq.s IL_0096 + + IL_0077: ldloc.0 + IL_0078: ldc.i4 0xf701cc7f + IL_007d: beq.s IL_00c3 + + IL_007f: br IL_011b + + IL_0084: ldarg.0 + IL_0085: ldstr "First case" + IL_008a: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_008f: brtrue.s IL_00f5 + + IL_0091: br IL_011b + + IL_0096: ldarg.0 + IL_0097: ldstr "Second case" + IL_009c: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00a1: brtrue.s IL_00fb + + IL_00a3: br.s IL_011b + + IL_00a5: ldarg.0 + IL_00a6: ldstr "2nd case" + IL_00ab: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00b0: brtrue.s IL_00fb + + IL_00b2: br.s IL_011b + + IL_00b4: ldarg.0 + IL_00b5: ldstr "Third case" + IL_00ba: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00bf: brtrue.s IL_0101 + + IL_00c1: br.s IL_011b + + IL_00c3: ldarg.0 + IL_00c4: ldstr "Fourth case" + IL_00c9: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00ce: brtrue.s IL_0107 + + IL_00d0: br.s IL_011b + + IL_00d2: ldarg.0 + IL_00d3: ldstr "Fifth case" + IL_00d8: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00dd: brtrue.s IL_010d + + IL_00df: br.s IL_011b + + IL_00e1: ldarg.0 + IL_00e2: ldstr "Sixth case" + IL_00e7: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00ec: brtrue.s IL_0113 + + IL_00ee: br.s IL_011b + + IL_00f0: ldarg.0 + IL_00f1: brfalse.s IL_0119 + + IL_00f3: br.s IL_011b + + IL_00f5: ldstr "Text1" + IL_00fa: ret + + IL_00fb: ldstr "Text2" + IL_0100: ret + + IL_0101: ldstr "Text3" + IL_0106: ret + + IL_0107: ldstr "Text4" + IL_010c: ret + + IL_010d: ldstr "Text5" + IL_0112: ret + + IL_0113: ldstr "Text6" + IL_0118: ret + + IL_0119: ldnull + IL_011a: ret + + IL_011b: ldstr "Default" + IL_0120: ret + } // end of method Switch::SwitchOverString1 + + .method public hidebysig static string + SwitchOverString2() cil managed + { + // Code size 446 (0x1be) + .maxstack 2 + .locals init (string V_0, + uint32 V_1) + IL_0000: ldstr "SwitchOverString2:" + IL_0005: call void [mscorlib]System.Console::WriteLine(string) + IL_000a: call string [mscorlib]System.Environment::get_UserName() + IL_000f: stloc.0 + IL_0010: ldloc.0 + IL_0011: call uint32 ''::ComputeStringHash(string) + IL_0016: stloc.1 + IL_0017: ldloc.1 + IL_0018: ldc.i4 0x4c7c71f6 + IL_001d: bgt.un.s IL_0065 + + IL_001f: ldloc.1 + IL_0020: ldc.i4 0xc9a8f4f + IL_0025: bgt.un.s IL_003f + + IL_0027: ldloc.1 + IL_0028: ldc.i4 0x8861b86 + IL_002d: beq IL_0107 + + IL_0032: ldloc.1 + IL_0033: ldc.i4 0xc9a8f4f + IL_0038: beq.s IL_00b3 + + IL_003a: br IL_01b8 + + IL_003f: ldloc.1 + IL_0040: ldc.i4 0xf3d44a6 + IL_0045: beq IL_00dd + + IL_004a: ldloc.1 + IL_004b: ldc.i4 0x20289804 + IL_0050: beq IL_013a + + IL_0055: ldloc.1 + IL_0056: ldc.i4 0x4c7c71f6 + IL_005b: beq IL_0149 + + IL_0060: br IL_01b8 + + IL_0065: ldloc.1 + IL_0066: ldc.i4 0xa151b28a + IL_006b: bgt.un.s IL_0093 + + IL_006d: ldloc.1 + IL_006e: ldc.i4 0x4d0cea48 + IL_0073: beq IL_0167 + + IL_0078: ldloc.1 + IL_0079: ldc.i4 0x51650fb9 + IL_007e: beq IL_0119 + + IL_0083: ldloc.1 + IL_0084: ldc.i4 0xa151b28a + IL_0089: beq IL_012b + + IL_008e: br IL_01b8 + + IL_0093: ldloc.1 + IL_0094: ldc.i4 0xea3d096b + IL_0099: beq.s IL_00c8 + + IL_009b: ldloc.1 + IL_009c: ldc.i4 0xed5134d4 + IL_00a1: beq IL_0158 + + IL_00a6: ldloc.1 + IL_00a7: ldc.i4 0xf701cc7f + IL_00ac: beq.s IL_00f2 + + IL_00ae: br IL_01b8 + + IL_00b3: ldloc.0 + IL_00b4: ldstr "First case" + IL_00b9: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00be: brtrue IL_0176 + + IL_00c3: br IL_01b8 + + IL_00c8: ldloc.0 + IL_00c9: ldstr "Second case" + IL_00ce: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00d3: brtrue IL_017c + + IL_00d8: br IL_01b8 + + IL_00dd: ldloc.0 + IL_00de: ldstr "Third case" + IL_00e3: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00e8: brtrue IL_0182 + + IL_00ed: br IL_01b8 + + IL_00f2: ldloc.0 + IL_00f3: ldstr "Fourth case" + IL_00f8: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00fd: brtrue IL_0188 + + IL_0102: br IL_01b8 + + IL_0107: ldloc.0 + IL_0108: ldstr "Fifth case" + IL_010d: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0112: brtrue.s IL_018e + + IL_0114: br IL_01b8 + + IL_0119: ldloc.0 + IL_011a: ldstr "Sixth case" + IL_011f: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0124: brtrue.s IL_0194 + + IL_0126: br IL_01b8 + + IL_012b: ldloc.0 + IL_012c: ldstr "Seventh case" + IL_0131: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0136: brtrue.s IL_019a + + IL_0138: br.s IL_01b8 + + IL_013a: ldloc.0 + IL_013b: ldstr "Eighth case" + IL_0140: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0145: brtrue.s IL_01a0 + + IL_0147: br.s IL_01b8 + + IL_0149: ldloc.0 + IL_014a: ldstr "Ninth case" + IL_014f: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0154: brtrue.s IL_01a6 + + IL_0156: br.s IL_01b8 + + IL_0158: ldloc.0 + IL_0159: ldstr "Tenth case" + IL_015e: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0163: brtrue.s IL_01ac + + IL_0165: br.s IL_01b8 + + IL_0167: ldloc.0 + IL_0168: ldstr "Eleventh case" + IL_016d: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0172: brtrue.s IL_01b2 + + IL_0174: br.s IL_01b8 + + IL_0176: ldstr "Text1" + IL_017b: ret + + IL_017c: ldstr "Text2" + IL_0181: ret + + IL_0182: ldstr "Text3" + IL_0187: ret + + IL_0188: ldstr "Text4" + IL_018d: ret + + IL_018e: ldstr "Text5" + IL_0193: ret + + IL_0194: ldstr "Text6" + IL_0199: ret + + IL_019a: ldstr "Text7" + IL_019f: ret + + IL_01a0: ldstr "Text8" + IL_01a5: ret + + IL_01a6: ldstr "Text9" + IL_01ab: ret + + IL_01ac: ldstr "Text10" + IL_01b1: ret + + IL_01b2: ldstr "Text11" + IL_01b7: ret + + IL_01b8: ldstr "Default" + IL_01bd: ret + } // end of method Switch::SwitchOverString2 + + .method public hidebysig static string + SwitchOverBool(bool b) cil managed + { + // Code size 43 (0x2b) + .maxstack 8 + IL_0000: ldstr "SwitchOverBool: " + IL_0005: ldarga.s b + IL_0007: call instance string [mscorlib]System.Boolean::ToString() + IL_000c: call string [mscorlib]System.String::Concat(string, + string) + IL_0011: call void [mscorlib]System.Console::WriteLine(string) + IL_0016: ldarg.0 + IL_0017: brfalse.s IL_0023 + + IL_0019: ldarg.0 + IL_001a: ldc.i4.1 + IL_001b: bne.un.s IL_0029 + + IL_001d: ldsfld string [mscorlib]System.Boolean::TrueString + IL_0022: ret + + IL_0023: ldsfld string [mscorlib]System.Boolean::FalseString + IL_0028: ret + + IL_0029: ldnull + IL_002a: ret + } // end of method Switch::SwitchOverBool + + .method public hidebysig static void SwitchInLoop(int32 i) cil managed + { + // Code size 110 (0x6e) + .maxstack 2 + IL_0000: ldstr "SwitchInLoop: " + IL_0005: ldarg.0 + IL_0006: box [mscorlib]System.Int32 + IL_000b: call string [mscorlib]System.String::Concat(object, + object) + IL_0010: call void [mscorlib]System.Console::WriteLine(string) + IL_0015: ldarg.0 + IL_0016: ldc.i4.1 + IL_0017: sub + IL_0018: switch ( + IL_002f, + IL_003b, + IL_0052, + IL_0047) + IL_002d: br.s IL_0052 + + IL_002f: ldstr "one" + IL_0034: call void [mscorlib]System.Console::WriteLine(string) + IL_0039: br.s IL_0067 + + IL_003b: ldstr "two" + IL_0040: call void [mscorlib]System.Console::WriteLine(string) + IL_0045: br.s IL_0067 + + IL_0047: ldstr "four" + IL_004c: call void [mscorlib]System.Console::WriteLine(string) + IL_0051: ret + + IL_0052: ldstr "default" + IL_0057: call void [mscorlib]System.Console::WriteLine(string) + IL_005c: ldstr "more code" + IL_0061: call void [mscorlib]System.Console::WriteLine(string) + IL_0066: ret + + IL_0067: ldarg.0 + IL_0068: ldc.i4.1 + IL_0069: add + IL_006a: starg.s i + IL_006c: br.s IL_0015 + } // end of method Switch::SwitchInLoop + + .method public hidebysig static void SwitchWithGoto(int32 i) cil managed + { + // Code size 113 (0x71) + .maxstack 2 + IL_0000: ldstr "SwitchWithGoto: " + IL_0005: ldarg.0 + IL_0006: box [mscorlib]System.Int32 + IL_000b: call string [mscorlib]System.String::Concat(object, + object) + IL_0010: call void [mscorlib]System.Console::WriteLine(string) + IL_0015: ldarg.0 + IL_0016: ldc.i4.1 + IL_0017: sub + IL_0018: switch ( + IL_002f, + IL_003b, + IL_0045, + IL_0051) + IL_002d: br.s IL_005c + + IL_002f: ldstr "one" + IL_0034: call void [mscorlib]System.Console::WriteLine(string) + IL_0039: br.s IL_005c + + IL_003b: ldstr "two" + IL_0040: call void [mscorlib]System.Console::WriteLine(string) + IL_0045: ldstr "three" + IL_004a: call void [mscorlib]System.Console::WriteLine(string) + IL_004f: br.s IL_0066 + + IL_0051: ldstr "four" + IL_0056: call void [mscorlib]System.Console::WriteLine(string) + IL_005b: ret + + IL_005c: ldstr "default" + IL_0061: call void [mscorlib]System.Console::WriteLine(string) + IL_0066: ldstr "End of method" + IL_006b: call void [mscorlib]System.Console::WriteLine(string) + IL_0070: ret + } // end of method Switch::SwitchWithGoto + + .method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] + GetProperties() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: newarr ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty + IL_0006: ret + } // end of method Switch::GetProperties + + .method public hidebysig static void SwitchOnStringInForLoop() cil managed + { + // Code size 234 (0xea) + .maxstack 2 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0, + class [mscorlib]System.Collections.Generic.List`1 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] V_2, + int32 V_3, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty V_4, + string V_5) + IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0005: stloc.0 + IL_0006: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000b: stloc.1 + IL_000c: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch::GetProperties() + IL_0011: stloc.2 + IL_0012: ldc.i4.0 + IL_0013: stloc.3 + IL_0014: br IL_00e0 + + IL_0019: ldloc.2 + IL_001a: ldloc.3 + IL_001b: ldelem.ref + IL_001c: stloc.s V_4 + IL_001e: ldloc.s V_4 + IL_0020: ldfld class [mscorlib]System.Reflection.PropertyInfo ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::Property + IL_0025: callvirt instance string [mscorlib]System.Reflection.MemberInfo::get_Name() + IL_002a: stloc.s V_5 + IL_002c: ldloc.s V_5 + IL_002e: ldstr "Name1" + IL_0033: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0038: brtrue.s IL_0082 + + IL_003a: ldloc.s V_5 + IL_003c: ldstr "Name2" + IL_0041: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0046: brtrue.s IL_0094 + + IL_0048: ldloc.s V_5 + IL_004a: ldstr "Name3" + IL_004f: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0054: brtrue.s IL_00a6 + + IL_0056: ldloc.s V_5 + IL_0058: ldstr "Name4" + IL_005d: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0062: brtrue.s IL_00b8 + + IL_0064: ldloc.s V_5 + IL_0066: ldstr "Name5" + IL_006b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0070: brtrue.s IL_00ca + + IL_0072: ldloc.s V_5 + IL_0074: ldstr "Name6" + IL_0079: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_007e: brtrue.s IL_00ca + + IL_0080: br.s IL_00d4 + + IL_0082: ldloc.s V_4 + IL_0084: ldc.i4.1 + IL_0085: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_008a: ldloc.0 + IL_008b: ldloc.s V_4 + IL_008d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0092: br.s IL_00dc + + IL_0094: ldloc.s V_4 + IL_0096: ldc.i4.2 + IL_0097: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_009c: ldloc.0 + IL_009d: ldloc.s V_4 + IL_009f: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00a4: br.s IL_00dc + + IL_00a6: ldloc.s V_4 + IL_00a8: ldc.i4.3 + IL_00a9: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00ae: ldloc.0 + IL_00af: ldloc.s V_4 + IL_00b1: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00b6: br.s IL_00dc + + IL_00b8: ldloc.s V_4 + IL_00ba: ldc.i4.4 + IL_00bb: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00c0: ldloc.0 + IL_00c1: ldloc.s V_4 + IL_00c3: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00c8: br.s IL_00dc + + IL_00ca: ldloc.0 + IL_00cb: ldloc.s V_4 + IL_00cd: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00d2: br.s IL_00dc + + IL_00d4: ldloc.1 + IL_00d5: ldloc.s V_4 + IL_00d7: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00dc: ldloc.3 + IL_00dd: ldc.i4.1 + IL_00de: add + IL_00df: stloc.3 + IL_00e0: ldloc.3 + IL_00e1: ldloc.2 + IL_00e2: ldlen + IL_00e3: conv.i4 + IL_00e4: blt IL_0019 + + IL_00e9: ret + } // end of method Switch::SwitchOnStringInForLoop + + .method public hidebysig static void SwitchWithComplexCondition(string[] args) cil managed + { + // Code size 126 (0x7e) + .maxstack 2 + .locals init (string V_0) + IL_0000: ldarg.0 + IL_0001: ldlen + IL_0002: brfalse.s IL_0009 + + IL_0004: ldarg.0 + IL_0005: ldc.i4.0 + IL_0006: ldelem.ref + IL_0007: br.s IL_000e + + IL_0009: ldstr "dummy" + IL_000e: stloc.0 + IL_000f: ldloc.0 + IL_0010: ldstr "a" + IL_0015: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_001a: brtrue.s IL_0045 + + IL_001c: ldloc.0 + IL_001d: ldstr "b" + IL_0022: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0027: brtrue.s IL_0051 + + IL_0029: ldloc.0 + IL_002a: ldstr "c" + IL_002f: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0034: brtrue.s IL_005d + + IL_0036: ldloc.0 + IL_0037: ldstr "d" + IL_003c: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0041: brtrue.s IL_0069 + + IL_0043: br.s IL_0073 + + IL_0045: ldstr "a" + IL_004a: call void [mscorlib]System.Console::WriteLine(string) + IL_004f: br.s IL_0073 + + IL_0051: ldstr "b" + IL_0056: call void [mscorlib]System.Console::WriteLine(string) + IL_005b: br.s IL_0073 + + IL_005d: ldstr "c" + IL_0062: call void [mscorlib]System.Console::WriteLine(string) + IL_0067: br.s IL_0073 + + IL_0069: ldstr "d" + IL_006e: call void [mscorlib]System.Console::WriteLine(string) + IL_0073: ldstr "end" + IL_0078: call void [mscorlib]System.Console::WriteLine(string) + IL_007d: ret + } // end of method Switch::SwitchWithComplexCondition + + .method public hidebysig static void SwitchWithArray(string[] args) cil managed + { + // Code size 115 (0x73) + .maxstack 2 + .locals init (string V_0) + IL_0000: ldarg.0 + IL_0001: ldc.i4.0 + IL_0002: ldelem.ref + IL_0003: stloc.0 + IL_0004: ldloc.0 + IL_0005: ldstr "a" + IL_000a: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_000f: brtrue.s IL_003a + + IL_0011: ldloc.0 + IL_0012: ldstr "b" + IL_0017: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_001c: brtrue.s IL_0046 + + IL_001e: ldloc.0 + IL_001f: ldstr "c" + IL_0024: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0029: brtrue.s IL_0052 + + IL_002b: ldloc.0 + IL_002c: ldstr "d" + IL_0031: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0036: brtrue.s IL_005e + + IL_0038: br.s IL_0068 + + IL_003a: ldstr "a" + IL_003f: call void [mscorlib]System.Console::WriteLine(string) + IL_0044: br.s IL_0068 + + IL_0046: ldstr "b" + IL_004b: call void [mscorlib]System.Console::WriteLine(string) + IL_0050: br.s IL_0068 + + IL_0052: ldstr "c" + IL_0057: call void [mscorlib]System.Console::WriteLine(string) + IL_005c: br.s IL_0068 + + IL_005e: ldstr "d" + IL_0063: call void [mscorlib]System.Console::WriteLine(string) + IL_0068: ldstr "end" + IL_006d: call void [mscorlib]System.Console::WriteLine(string) + IL_0072: ret + } // end of method Switch::SwitchWithArray + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch + +.class private auto ansi sealed '' + extends [mscorlib]System.Object +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly hidebysig static uint32 + ComputeStringHash(string s) cil managed + { + // Code size 44 (0x2c) + .maxstack 2 + .locals init (uint32 V_0, + int32 V_1) + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_002a + + IL_0003: ldc.i4 0x811c9dc5 + IL_0008: stloc.0 + IL_0009: ldc.i4.0 + IL_000a: stloc.1 + IL_000b: br.s IL_0021 + + IL_000d: ldarg.0 + IL_000e: ldloc.1 + IL_000f: callvirt instance char [mscorlib]System.String::get_Chars(int32) + IL_0014: ldloc.0 + IL_0015: xor + IL_0016: ldc.i4 0x1000193 + IL_001b: mul + IL_001c: stloc.0 + IL_001d: ldloc.1 + IL_001e: ldc.i4.1 + IL_001f: add + IL_0020: stloc.1 + IL_0021: ldloc.1 + IL_0022: ldarg.0 + IL_0023: callvirt instance int32 [mscorlib]System.String::get_Length() + IL_0028: blt.s IL_000d + + IL_002a: ldloc.0 + IL_002b: ret + } // end of method ''::ComputeStringHash + +} // end of class '' + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.roslyn.il new file mode 100644 index 000000000..ea25c483e --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.roslyn.il @@ -0,0 +1,1853 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 +// Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly Switch +{ + .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 Switch.dll +// MVID: {EF7D776C-0F54-445C-8A74-2D49ADE35F46} +.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: 0x00C40000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch + extends [mscorlib]System.Object +{ + .class auto ansi nested public beforefieldinit SetProperty + extends [mscorlib]System.Object + { + .field public initonly class [mscorlib]System.Reflection.PropertyInfo Property + .field private int32 'k__BackingField' + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .method public hidebysig specialname + instance int32 get_Set() cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::'k__BackingField' + IL_0006: ret + } // end of method SetProperty::get_Set + + .method public hidebysig specialname + instance void set_Set(int32 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::'k__BackingField' + IL_0007: ret + } // end of method SetProperty::set_Set + + .method public hidebysig specialname rtspecialname + instance void .ctor(class [mscorlib]System.Reflection.PropertyInfo 'property') cil managed + { + // Code size 16 (0x10) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: nop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld class [mscorlib]System.Reflection.PropertyInfo ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::Property + IL_000f: ret + } // end of method SetProperty::.ctor + + .property instance int32 Set() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::get_Set() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + } // end of property SetProperty::Set + } // end of class SetProperty + + .class auto ansi sealed nested public State + extends [mscorlib]System.Enum + { + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State False = int32(0x00000000) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State True = int32(0x00000001) + .field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State Null = int32(0x00000002) + } // end of class State + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State + SwitchOverNullableBool(valuetype [mscorlib]System.Nullable`1 'value') cil managed + { + // Code size 53 (0x35) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + bool V_2, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State V_3) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: stloc.0 + IL_0005: ldloca.s V_0 + IL_0007: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000c: brfalse.s IL_0029 + + IL_000e: ldloca.s V_0 + IL_0010: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0015: stloc.2 + IL_0016: ldloc.2 + IL_0017: brfalse.s IL_0021 + + IL_0019: br.s IL_001b + + IL_001b: ldloc.2 + IL_001c: ldc.i4.1 + IL_001d: beq.s IL_0025 + + IL_001f: br.s IL_002d + + IL_0021: ldc.i4.0 + IL_0022: stloc.3 + IL_0023: br.s IL_0033 + + IL_0025: ldc.i4.1 + IL_0026: stloc.3 + IL_0027: br.s IL_0033 + + IL_0029: ldc.i4.2 + IL_002a: stloc.3 + IL_002b: br.s IL_0033 + + IL_002d: newobj instance void [mscorlib]System.InvalidOperationException::.ctor() + IL_0032: throw + + IL_0033: ldloc.3 + IL_0034: ret + } // end of method Switch::SwitchOverNullableBool + + .method public hidebysig static valuetype [mscorlib]System.Nullable`1 + SwitchOverNullableEnum(valuetype [mscorlib]System.Nullable`1 state) cil managed + { + // Code size 81 (0x51) + .maxstack 1 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/State V_2, + valuetype [mscorlib]System.Nullable`1 V_3, + valuetype [mscorlib]System.Nullable`1 V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: stloc.0 + IL_0005: ldloca.s V_0 + IL_0007: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000c: brfalse.s IL_0049 + + IL_000e: ldloca.s V_0 + IL_0010: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0015: stloc.2 + IL_0016: ldloc.2 + IL_0017: switch ( + IL_002a, + IL_0033, + IL_003c) + IL_0028: br.s IL_0049 + + IL_002a: ldc.i4.0 + IL_002b: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0030: stloc.3 + IL_0031: br.s IL_004f + + IL_0033: ldc.i4.1 + IL_0034: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0039: stloc.3 + IL_003a: br.s IL_004f + + IL_003c: ldloca.s V_4 + IL_003e: initobj valuetype [mscorlib]System.Nullable`1 + IL_0044: ldloc.s V_4 + IL_0046: stloc.3 + IL_0047: br.s IL_004f + + IL_0049: newobj instance void [mscorlib]System.InvalidOperationException::.ctor() + IL_004e: throw + + IL_004f: ldloc.3 + IL_0050: ret + } // end of method Switch::SwitchOverNullableEnum + + .method public hidebysig static string + SparseIntegerSwitch(int32 i) cil managed + { + // Code size 226 (0xe2) + .maxstack 2 + .locals init (int32 V_0, + string V_1) + IL_0000: nop + IL_0001: ldstr "SparseIntegerSwitch: " + IL_0006: ldarg.0 + IL_0007: box [mscorlib]System.Int32 + IL_000c: call string [mscorlib]System.String::Concat(object, + object) + IL_0011: call void [mscorlib]System.Console::WriteLine(string) + IL_0016: nop + IL_0017: ldarg.0 + IL_0018: stloc.0 + IL_0019: ldloc.0 + IL_001a: ldc.i4.4 + IL_001b: bgt.s IL_0053 + + IL_001d: ldloc.0 + IL_001e: ldc.i4 0xff676980 + IL_0023: beq.s IL_0080 + + IL_0025: br.s IL_0027 + + IL_0027: ldloc.0 + IL_0028: ldc.i4.s -100 + IL_002a: beq.s IL_0088 + + IL_002c: br.s IL_002e + + IL_002e: ldloc.0 + IL_002f: ldc.i4.m1 + IL_0030: sub + IL_0031: switch ( + IL_0090, + IL_0098, + IL_00a0, + IL_00a8, + IL_00d8, + IL_00b0) + IL_004e: br IL_00d8 + + IL_0053: ldloc.0 + IL_0054: ldc.i4 0x2710 + IL_0059: bgt.s IL_006c + + IL_005b: ldloc.0 + IL_005c: ldc.i4.s 100 + IL_005e: beq.s IL_00b8 + + IL_0060: br.s IL_0062 + + IL_0062: ldloc.0 + IL_0063: ldc.i4 0x2710 + IL_0068: beq.s IL_00c0 + + IL_006a: br.s IL_00d8 + + IL_006c: ldloc.0 + IL_006d: ldc.i4 0x2711 + IL_0072: beq.s IL_00c8 + + IL_0074: br.s IL_0076 + + IL_0076: ldloc.0 + IL_0077: ldc.i4 0x7fffffff + IL_007c: beq.s IL_00d0 + + IL_007e: br.s IL_00d8 + + IL_0080: ldstr "-10 mln" + IL_0085: stloc.1 + IL_0086: br.s IL_00e0 + + IL_0088: ldstr "-hundred" + IL_008d: stloc.1 + IL_008e: br.s IL_00e0 + + IL_0090: ldstr "-1" + IL_0095: stloc.1 + IL_0096: br.s IL_00e0 + + IL_0098: ldstr "0" + IL_009d: stloc.1 + IL_009e: br.s IL_00e0 + + IL_00a0: ldstr "1" + IL_00a5: stloc.1 + IL_00a6: br.s IL_00e0 + + IL_00a8: ldstr "2" + IL_00ad: stloc.1 + IL_00ae: br.s IL_00e0 + + IL_00b0: ldstr "4" + IL_00b5: stloc.1 + IL_00b6: br.s IL_00e0 + + IL_00b8: ldstr "hundred" + IL_00bd: stloc.1 + IL_00be: br.s IL_00e0 + + IL_00c0: ldstr "ten thousand" + IL_00c5: stloc.1 + IL_00c6: br.s IL_00e0 + + IL_00c8: ldstr "ten thousand and one" + IL_00cd: stloc.1 + IL_00ce: br.s IL_00e0 + + IL_00d0: ldstr "int.MaxValue" + IL_00d5: stloc.1 + IL_00d6: br.s IL_00e0 + + IL_00d8: ldstr "something else" + IL_00dd: stloc.1 + IL_00de: br.s IL_00e0 + + IL_00e0: ldloc.1 + IL_00e1: ret + } // end of method Switch::SparseIntegerSwitch + + .method public hidebysig static string + SwitchOverNullableInt(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 82 (0x52) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + int32 V_2, + string V_3) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: stloc.0 + IL_0005: ldloca.s V_0 + IL_0007: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000c: brfalse.s IL_0028 + + IL_000e: ldloca.s V_0 + IL_0010: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0015: stloc.2 + IL_0016: ldloc.2 + IL_0017: brfalse.s IL_0030 + + IL_0019: br.s IL_001b + + IL_001b: ldloc.2 + IL_001c: ldc.i4.5 + IL_001d: beq.s IL_0038 + + IL_001f: br.s IL_0021 + + IL_0021: ldloc.2 + IL_0022: ldc.i4.s 10 + IL_0024: beq.s IL_0040 + + IL_0026: br.s IL_0048 + + IL_0028: ldstr "null" + IL_002d: stloc.3 + IL_002e: br.s IL_0050 + + IL_0030: ldstr "zero" + IL_0035: stloc.3 + IL_0036: br.s IL_0050 + + IL_0038: ldstr "five" + IL_003d: stloc.3 + IL_003e: br.s IL_0050 + + IL_0040: ldstr "ten" + IL_0045: stloc.3 + IL_0046: br.s IL_0050 + + IL_0048: ldstr "large" + IL_004d: stloc.3 + IL_004e: br.s IL_0050 + + IL_0050: ldloc.3 + IL_0051: ret + } // end of method Switch::SwitchOverNullableInt + + .method public hidebysig static string + SwitchOverNullableIntNullCaseCombined(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 74 (0x4a) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + int32 V_2, + string V_3) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: stloc.0 + IL_0005: ldloca.s V_0 + IL_0007: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000c: brfalse.s IL_0028 + + IL_000e: ldloca.s V_0 + IL_0010: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0015: stloc.2 + IL_0016: ldloc.2 + IL_0017: brfalse.s IL_0028 + + IL_0019: br.s IL_001b + + IL_001b: ldloc.2 + IL_001c: ldc.i4.5 + IL_001d: beq.s IL_0030 + + IL_001f: br.s IL_0021 + + IL_0021: ldloc.2 + IL_0022: ldc.i4.s 10 + IL_0024: beq.s IL_0038 + + IL_0026: br.s IL_0040 + + IL_0028: ldstr "zero" + IL_002d: stloc.3 + IL_002e: br.s IL_0048 + + IL_0030: ldstr "five" + IL_0035: stloc.3 + IL_0036: br.s IL_0048 + + IL_0038: ldstr "ten" + IL_003d: stloc.3 + IL_003e: br.s IL_0048 + + IL_0040: ldstr "large" + IL_0045: stloc.3 + IL_0046: br.s IL_0048 + + IL_0048: ldloc.3 + IL_0049: ret + } // end of method Switch::SwitchOverNullableIntNullCaseCombined + + .method public hidebysig static string + SwitchOverNullableIntShifted(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 127 (0x7f) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype [mscorlib]System.Nullable`1 V_2, + valuetype [mscorlib]System.Nullable`1 V_3, + int32 V_4, + string V_5) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.2 + IL_0003: ldloca.s V_2 + IL_0005: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000a: brtrue.s IL_0017 + + IL_000c: ldloca.s V_3 + IL_000e: initobj valuetype [mscorlib]System.Nullable`1 + IL_0014: ldloc.3 + IL_0015: br.s IL_0025 + + IL_0017: ldloca.s V_2 + IL_0019: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_001e: ldc.i4.5 + IL_001f: add + IL_0020: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0025: stloc.1 + IL_0026: ldloc.1 + IL_0027: stloc.0 + IL_0028: ldloca.s V_0 + IL_002a: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_002f: brfalse.s IL_004f + + IL_0031: ldloca.s V_0 + IL_0033: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0038: stloc.s V_4 + IL_003a: ldloc.s V_4 + IL_003c: brfalse.s IL_0058 + + IL_003e: br.s IL_0040 + + IL_0040: ldloc.s V_4 + IL_0042: ldc.i4.5 + IL_0043: beq.s IL_0061 + + IL_0045: br.s IL_0047 + + IL_0047: ldloc.s V_4 + IL_0049: ldc.i4.s 10 + IL_004b: beq.s IL_006a + + IL_004d: br.s IL_0073 + + IL_004f: ldstr "null" + IL_0054: stloc.s V_5 + IL_0056: br.s IL_007c + + IL_0058: ldstr "zero" + IL_005d: stloc.s V_5 + IL_005f: br.s IL_007c + + IL_0061: ldstr "five" + IL_0066: stloc.s V_5 + IL_0068: br.s IL_007c + + IL_006a: ldstr "ten" + IL_006f: stloc.s V_5 + IL_0071: br.s IL_007c + + IL_0073: ldstr "large" + IL_0078: stloc.s V_5 + IL_007a: br.s IL_007c + + IL_007c: ldloc.s V_5 + IL_007e: ret + } // end of method Switch::SwitchOverNullableIntShifted + + .method public hidebysig static string + SwitchOverNullableIntShiftedNullCaseCombined(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 118 (0x76) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype [mscorlib]System.Nullable`1 V_2, + valuetype [mscorlib]System.Nullable`1 V_3, + int32 V_4, + string V_5) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.2 + IL_0003: ldloca.s V_2 + IL_0005: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000a: brtrue.s IL_0017 + + IL_000c: ldloca.s V_3 + IL_000e: initobj valuetype [mscorlib]System.Nullable`1 + IL_0014: ldloc.3 + IL_0015: br.s IL_0025 + + IL_0017: ldloca.s V_2 + IL_0019: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_001e: ldc.i4.5 + IL_001f: add + IL_0020: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0025: stloc.1 + IL_0026: ldloc.1 + IL_0027: stloc.0 + IL_0028: ldloca.s V_0 + IL_002a: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_002f: brfalse.s IL_004f + + IL_0031: ldloca.s V_0 + IL_0033: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0038: stloc.s V_4 + IL_003a: ldloc.s V_4 + IL_003c: brfalse.s IL_004f + + IL_003e: br.s IL_0040 + + IL_0040: ldloc.s V_4 + IL_0042: ldc.i4.5 + IL_0043: beq.s IL_0058 + + IL_0045: br.s IL_0047 + + IL_0047: ldloc.s V_4 + IL_0049: ldc.i4.s 10 + IL_004b: beq.s IL_0061 + + IL_004d: br.s IL_006a + + IL_004f: ldstr "zero" + IL_0054: stloc.s V_5 + IL_0056: br.s IL_0073 + + IL_0058: ldstr "five" + IL_005d: stloc.s V_5 + IL_005f: br.s IL_0073 + + IL_0061: ldstr "ten" + IL_0066: stloc.s V_5 + IL_0068: br.s IL_0073 + + IL_006a: ldstr "large" + IL_006f: stloc.s V_5 + IL_0071: br.s IL_0073 + + IL_0073: ldloc.s V_5 + IL_0075: ret + } // end of method Switch::SwitchOverNullableIntShiftedNullCaseCombined + + .method public hidebysig static string + SwitchOverNullableIntNoNullCase(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 74 (0x4a) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + int32 V_2, + string V_3) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: stloc.0 + IL_0005: ldloca.s V_0 + IL_0007: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000c: brfalse.s IL_0040 + + IL_000e: ldloca.s V_0 + IL_0010: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0015: stloc.2 + IL_0016: ldloc.2 + IL_0017: brfalse.s IL_0028 + + IL_0019: br.s IL_001b + + IL_001b: ldloc.2 + IL_001c: ldc.i4.5 + IL_001d: beq.s IL_0030 + + IL_001f: br.s IL_0021 + + IL_0021: ldloc.2 + IL_0022: ldc.i4.s 10 + IL_0024: beq.s IL_0038 + + IL_0026: br.s IL_0040 + + IL_0028: ldstr "zero" + IL_002d: stloc.3 + IL_002e: br.s IL_0048 + + IL_0030: ldstr "five" + IL_0035: stloc.3 + IL_0036: br.s IL_0048 + + IL_0038: ldstr "ten" + IL_003d: stloc.3 + IL_003e: br.s IL_0048 + + IL_0040: ldstr "other" + IL_0045: stloc.3 + IL_0046: br.s IL_0048 + + IL_0048: ldloc.3 + IL_0049: ret + } // end of method Switch::SwitchOverNullableIntNoNullCase + + .method public hidebysig static string + SwitchOverNullableIntNoNullCaseShifted(valuetype [mscorlib]System.Nullable`1 i) cil managed + { + // Code size 118 (0x76) + .maxstack 2 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0, + valuetype [mscorlib]System.Nullable`1 V_1, + valuetype [mscorlib]System.Nullable`1 V_2, + valuetype [mscorlib]System.Nullable`1 V_3, + int32 V_4, + string V_5) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.2 + IL_0003: ldloca.s V_2 + IL_0005: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_000a: brtrue.s IL_0017 + + IL_000c: ldloca.s V_3 + IL_000e: initobj valuetype [mscorlib]System.Nullable`1 + IL_0014: ldloc.3 + IL_0015: br.s IL_0025 + + IL_0017: ldloca.s V_2 + IL_0019: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_001e: ldc.i4.5 + IL_001f: add + IL_0020: newobj instance void valuetype [mscorlib]System.Nullable`1::.ctor(!0) + IL_0025: stloc.1 + IL_0026: ldloc.1 + IL_0027: stloc.0 + IL_0028: ldloca.s V_0 + IL_002a: call instance bool valuetype [mscorlib]System.Nullable`1::get_HasValue() + IL_002f: brfalse.s IL_006a + + IL_0031: ldloca.s V_0 + IL_0033: call instance !0 valuetype [mscorlib]System.Nullable`1::GetValueOrDefault() + IL_0038: stloc.s V_4 + IL_003a: ldloc.s V_4 + IL_003c: brfalse.s IL_004f + + IL_003e: br.s IL_0040 + + IL_0040: ldloc.s V_4 + IL_0042: ldc.i4.5 + IL_0043: beq.s IL_0058 + + IL_0045: br.s IL_0047 + + IL_0047: ldloc.s V_4 + IL_0049: ldc.i4.s 10 + IL_004b: beq.s IL_0061 + + IL_004d: br.s IL_006a + + IL_004f: ldstr "zero" + IL_0054: stloc.s V_5 + IL_0056: br.s IL_0073 + + IL_0058: ldstr "five" + IL_005d: stloc.s V_5 + IL_005f: br.s IL_0073 + + IL_0061: ldstr "ten" + IL_0066: stloc.s V_5 + IL_0068: br.s IL_0073 + + IL_006a: ldstr "other" + IL_006f: stloc.s V_5 + IL_0071: br.s IL_0073 + + IL_0073: ldloc.s V_5 + IL_0075: ret + } // end of method Switch::SwitchOverNullableIntNoNullCaseShifted + + .method public hidebysig static void SwitchOverInt(int32 i) cil managed + { + // Code size 151 (0x97) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.0 + IL_0003: ldloc.0 + IL_0004: ldc.i4.s 10 + IL_0006: bgt.s IL_001a + + IL_0008: ldloc.0 + IL_0009: brfalse.s IL_003b + + IL_000b: br.s IL_000d + + IL_000d: ldloc.0 + IL_000e: ldc.i4.5 + IL_000f: beq.s IL_0048 + + IL_0011: br.s IL_0013 + + IL_0013: ldloc.0 + IL_0014: ldc.i4.s 10 + IL_0016: beq.s IL_0055 + + IL_0018: br.s IL_0096 + + IL_001a: ldloc.0 + IL_001b: ldc.i4.s 20 + IL_001d: bgt.s IL_002d + + IL_001f: ldloc.0 + IL_0020: ldc.i4.s 15 + IL_0022: beq.s IL_0062 + + IL_0024: br.s IL_0026 + + IL_0026: ldloc.0 + IL_0027: ldc.i4.s 20 + IL_0029: beq.s IL_006f + + IL_002b: br.s IL_0096 + + IL_002d: ldloc.0 + IL_002e: ldc.i4.s 25 + IL_0030: beq.s IL_007c + + IL_0032: br.s IL_0034 + + IL_0034: ldloc.0 + IL_0035: ldc.i4.s 30 + IL_0037: beq.s IL_0089 + + IL_0039: br.s IL_0096 + + IL_003b: ldstr "zero" + IL_0040: call void [mscorlib]System.Console::WriteLine(string) + IL_0045: nop + IL_0046: br.s IL_0096 + + IL_0048: ldstr "five" + IL_004d: call void [mscorlib]System.Console::WriteLine(string) + IL_0052: nop + IL_0053: br.s IL_0096 + + IL_0055: ldstr "ten" + IL_005a: call void [mscorlib]System.Console::WriteLine(string) + IL_005f: nop + IL_0060: br.s IL_0096 + + IL_0062: ldstr "fifteen" + IL_0067: call void [mscorlib]System.Console::WriteLine(string) + IL_006c: nop + IL_006d: br.s IL_0096 + + IL_006f: ldstr "twenty" + IL_0074: call void [mscorlib]System.Console::WriteLine(string) + IL_0079: nop + IL_007a: br.s IL_0096 + + IL_007c: ldstr "twenty-five" + IL_0081: call void [mscorlib]System.Console::WriteLine(string) + IL_0086: nop + IL_0087: br.s IL_0096 + + IL_0089: ldstr "thirty" + IL_008e: call void [mscorlib]System.Console::WriteLine(string) + IL_0093: nop + IL_0094: br.s IL_0096 + + IL_0096: ret + } // end of method Switch::SwitchOverInt + + .method public hidebysig static string + ShortSwitchOverString(string text) cil managed + { + // Code size 95 (0x5f) + .maxstack 2 + .locals init (string V_0, + string V_1) + IL_0000: nop + IL_0001: ldstr "ShortSwitchOverString: " + IL_0006: ldarg.0 + IL_0007: call string [mscorlib]System.String::Concat(string, + string) + IL_000c: call void [mscorlib]System.Console::WriteLine(string) + IL_0011: nop + IL_0012: ldarg.0 + IL_0013: stloc.0 + IL_0014: ldloc.0 + IL_0015: ldstr "First case" + IL_001a: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_001f: brtrue.s IL_003d + + IL_0021: ldloc.0 + IL_0022: ldstr "Second case" + IL_0027: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002c: brtrue.s IL_0045 + + IL_002e: ldloc.0 + IL_002f: ldstr "Third case" + IL_0034: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0039: brtrue.s IL_004d + + IL_003b: br.s IL_0055 + + IL_003d: ldstr "Text1" + IL_0042: stloc.1 + IL_0043: br.s IL_005d + + IL_0045: ldstr "Text2" + IL_004a: stloc.1 + IL_004b: br.s IL_005d + + IL_004d: ldstr "Text3" + IL_0052: stloc.1 + IL_0053: br.s IL_005d + + IL_0055: ldstr "Default" + IL_005a: stloc.1 + IL_005b: br.s IL_005d + + IL_005d: ldloc.1 + IL_005e: ret + } // end of method Switch::ShortSwitchOverString + + .method public hidebysig static string + ShortSwitchOverStringWithNullCase(string text) cil managed + { + // Code size 85 (0x55) + .maxstack 2 + .locals init (string V_0, + string V_1) + IL_0000: nop + IL_0001: ldstr "ShortSwitchOverStringWithNullCase: " + IL_0006: ldarg.0 + IL_0007: call string [mscorlib]System.String::Concat(string, + string) + IL_000c: call void [mscorlib]System.Console::WriteLine(string) + IL_0011: nop + IL_0012: ldarg.0 + IL_0013: stloc.0 + IL_0014: ldloc.0 + IL_0015: ldstr "First case" + IL_001a: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_001f: brtrue.s IL_0033 + + IL_0021: ldloc.0 + IL_0022: ldstr "Second case" + IL_0027: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002c: brtrue.s IL_003b + + IL_002e: ldloc.0 + IL_002f: brfalse.s IL_0043 + + IL_0031: br.s IL_004b + + IL_0033: ldstr "Text1" + IL_0038: stloc.1 + IL_0039: br.s IL_0053 + + IL_003b: ldstr "Text2" + IL_0040: stloc.1 + IL_0041: br.s IL_0053 + + IL_0043: ldstr "null" + IL_0048: stloc.1 + IL_0049: br.s IL_0053 + + IL_004b: ldstr "Default" + IL_0050: stloc.1 + IL_0051: br.s IL_0053 + + IL_0053: ldloc.1 + IL_0054: ret + } // end of method Switch::ShortSwitchOverStringWithNullCase + + .method public hidebysig static string + SwitchOverString1(string text) cil managed + { + // Code size 325 (0x145) + .maxstack 2 + .locals init (string V_0, + uint32 V_1, + string V_2) + IL_0000: nop + IL_0001: ldstr "SwitchOverString1: " + IL_0006: ldarg.0 + IL_0007: call string [mscorlib]System.String::Concat(string, + string) + IL_000c: call void [mscorlib]System.Console::WriteLine(string) + IL_0011: nop + IL_0012: ldarg.0 + IL_0013: stloc.0 + IL_0014: ldloc.0 + IL_0015: call uint32 ''::ComputeStringHash(string) + IL_001a: stloc.1 + IL_001b: ldloc.1 + IL_001c: ldc.i4 0xf3d44a6 + IL_0021: bgt.un.s IL_005a + + IL_0023: ldloc.1 + IL_0024: ldc.i4 0x8861b86 + IL_0029: bgt.un.s IL_0043 + + IL_002b: ldloc.1 + IL_002c: brfalse IL_0102 + + IL_0031: br.s IL_0033 + + IL_0033: ldloc.1 + IL_0034: ldc.i4 0x8861b86 + IL_0039: beq IL_00e4 + + IL_003e: br IL_013b + + IL_0043: ldloc.1 + IL_0044: ldc.i4 0xc9a8f4f + IL_0049: beq.s IL_0093 + + IL_004b: br.s IL_004d + + IL_004d: ldloc.1 + IL_004e: ldc.i4 0xf3d44a6 + IL_0053: beq.s IL_00c6 + + IL_0055: br IL_013b + + IL_005a: ldloc.1 + IL_005b: ldc.i4 0x652a1179 + IL_0060: bgt.un.s IL_007c + + IL_0062: ldloc.1 + IL_0063: ldc.i4 0x51650fb9 + IL_0068: beq IL_00f3 + + IL_006d: br.s IL_006f + + IL_006f: ldloc.1 + IL_0070: ldc.i4 0x652a1179 + IL_0075: beq.s IL_00b7 + + IL_0077: br IL_013b + + IL_007c: ldloc.1 + IL_007d: ldc.i4 0xea3d096b + IL_0082: beq.s IL_00a5 + + IL_0084: br.s IL_0086 + + IL_0086: ldloc.1 + IL_0087: ldc.i4 0xf701cc7f + IL_008c: beq.s IL_00d5 + + IL_008e: br IL_013b + + IL_0093: ldloc.0 + IL_0094: ldstr "First case" + IL_0099: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_009e: brtrue.s IL_0107 + + IL_00a0: br IL_013b + + IL_00a5: ldloc.0 + IL_00a6: ldstr "Second case" + IL_00ab: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00b0: brtrue.s IL_010f + + IL_00b2: br IL_013b + + IL_00b7: ldloc.0 + IL_00b8: ldstr "2nd case" + IL_00bd: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00c2: brtrue.s IL_010f + + IL_00c4: br.s IL_013b + + IL_00c6: ldloc.0 + IL_00c7: ldstr "Third case" + IL_00cc: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00d1: brtrue.s IL_0117 + + IL_00d3: br.s IL_013b + + IL_00d5: ldloc.0 + IL_00d6: ldstr "Fourth case" + IL_00db: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00e0: brtrue.s IL_011f + + IL_00e2: br.s IL_013b + + IL_00e4: ldloc.0 + IL_00e5: ldstr "Fifth case" + IL_00ea: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00ef: brtrue.s IL_0127 + + IL_00f1: br.s IL_013b + + IL_00f3: ldloc.0 + IL_00f4: ldstr "Sixth case" + IL_00f9: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00fe: brtrue.s IL_012f + + IL_0100: br.s IL_013b + + IL_0102: ldloc.0 + IL_0103: brfalse.s IL_0137 + + IL_0105: br.s IL_013b + + IL_0107: ldstr "Text1" + IL_010c: stloc.2 + IL_010d: br.s IL_0143 + + IL_010f: ldstr "Text2" + IL_0114: stloc.2 + IL_0115: br.s IL_0143 + + IL_0117: ldstr "Text3" + IL_011c: stloc.2 + IL_011d: br.s IL_0143 + + IL_011f: ldstr "Text4" + IL_0124: stloc.2 + IL_0125: br.s IL_0143 + + IL_0127: ldstr "Text5" + IL_012c: stloc.2 + IL_012d: br.s IL_0143 + + IL_012f: ldstr "Text6" + IL_0134: stloc.2 + IL_0135: br.s IL_0143 + + IL_0137: ldnull + IL_0138: stloc.2 + IL_0139: br.s IL_0143 + + IL_013b: ldstr "Default" + IL_0140: stloc.2 + IL_0141: br.s IL_0143 + + IL_0143: ldloc.2 + IL_0144: ret + } // end of method Switch::SwitchOverString1 + + .method public hidebysig static string + SwitchOverString2() cil managed + { + // Code size 500 (0x1f4) + .maxstack 2 + .locals init (string V_0, + uint32 V_1, + string V_2) + IL_0000: nop + IL_0001: ldstr "SwitchOverString2:" + IL_0006: call void [mscorlib]System.Console::WriteLine(string) + IL_000b: nop + IL_000c: call string [mscorlib]System.Environment::get_UserName() + IL_0011: stloc.0 + IL_0012: ldloc.0 + IL_0013: call uint32 ''::ComputeStringHash(string) + IL_0018: stloc.1 + IL_0019: ldloc.1 + IL_001a: ldc.i4 0x4c7c71f6 + IL_001f: bgt.un.s IL_0070 + + IL_0021: ldloc.1 + IL_0022: ldc.i4 0xc9a8f4f + IL_0027: bgt.un.s IL_0046 + + IL_0029: ldloc.1 + IL_002a: ldc.i4 0x8861b86 + IL_002f: beq IL_011a + + IL_0034: br.s IL_0036 + + IL_0036: ldloc.1 + IL_0037: ldc.i4 0xc9a8f4f + IL_003c: beq IL_00c6 + + IL_0041: br IL_01ea + + IL_0046: ldloc.1 + IL_0047: ldc.i4 0xf3d44a6 + IL_004c: beq IL_00f0 + + IL_0051: br.s IL_0053 + + IL_0053: ldloc.1 + IL_0054: ldc.i4 0x20289804 + IL_0059: beq IL_0153 + + IL_005e: br.s IL_0060 + + IL_0060: ldloc.1 + IL_0061: ldc.i4 0x4c7c71f6 + IL_0066: beq IL_0165 + + IL_006b: br IL_01ea + + IL_0070: ldloc.1 + IL_0071: ldc.i4 0xa151b28a + IL_0076: bgt.un.s IL_00a2 + + IL_0078: ldloc.1 + IL_0079: ldc.i4 0x4d0cea48 + IL_007e: beq IL_0183 + + IL_0083: br.s IL_0085 + + IL_0085: ldloc.1 + IL_0086: ldc.i4 0x51650fb9 + IL_008b: beq IL_012f + + IL_0090: br.s IL_0092 + + IL_0092: ldloc.1 + IL_0093: ldc.i4 0xa151b28a + IL_0098: beq IL_0141 + + IL_009d: br IL_01ea + + IL_00a2: ldloc.1 + IL_00a3: ldc.i4 0xea3d096b + IL_00a8: beq.s IL_00db + + IL_00aa: br.s IL_00ac + + IL_00ac: ldloc.1 + IL_00ad: ldc.i4 0xed5134d4 + IL_00b2: beq IL_0174 + + IL_00b7: br.s IL_00b9 + + IL_00b9: ldloc.1 + IL_00ba: ldc.i4 0xf701cc7f + IL_00bf: beq.s IL_0105 + + IL_00c1: br IL_01ea + + IL_00c6: ldloc.0 + IL_00c7: ldstr "First case" + IL_00cc: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00d1: brtrue IL_0192 + + IL_00d6: br IL_01ea + + IL_00db: ldloc.0 + IL_00dc: ldstr "Second case" + IL_00e1: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00e6: brtrue IL_019a + + IL_00eb: br IL_01ea + + IL_00f0: ldloc.0 + IL_00f1: ldstr "Third case" + IL_00f6: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_00fb: brtrue IL_01a2 + + IL_0100: br IL_01ea + + IL_0105: ldloc.0 + IL_0106: ldstr "Fourth case" + IL_010b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0110: brtrue IL_01aa + + IL_0115: br IL_01ea + + IL_011a: ldloc.0 + IL_011b: ldstr "Fifth case" + IL_0120: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0125: brtrue IL_01b2 + + IL_012a: br IL_01ea + + IL_012f: ldloc.0 + IL_0130: ldstr "Sixth case" + IL_0135: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_013a: brtrue.s IL_01ba + + IL_013c: br IL_01ea + + IL_0141: ldloc.0 + IL_0142: ldstr "Seventh case" + IL_0147: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_014c: brtrue.s IL_01c2 + + IL_014e: br IL_01ea + + IL_0153: ldloc.0 + IL_0154: ldstr "Eighth case" + IL_0159: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_015e: brtrue.s IL_01ca + + IL_0160: br IL_01ea + + IL_0165: ldloc.0 + IL_0166: ldstr "Ninth case" + IL_016b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0170: brtrue.s IL_01d2 + + IL_0172: br.s IL_01ea + + IL_0174: ldloc.0 + IL_0175: ldstr "Tenth case" + IL_017a: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_017f: brtrue.s IL_01da + + IL_0181: br.s IL_01ea + + IL_0183: ldloc.0 + IL_0184: ldstr "Eleventh case" + IL_0189: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_018e: brtrue.s IL_01e2 + + IL_0190: br.s IL_01ea + + IL_0192: ldstr "Text1" + IL_0197: stloc.2 + IL_0198: br.s IL_01f2 + + IL_019a: ldstr "Text2" + IL_019f: stloc.2 + IL_01a0: br.s IL_01f2 + + IL_01a2: ldstr "Text3" + IL_01a7: stloc.2 + IL_01a8: br.s IL_01f2 + + IL_01aa: ldstr "Text4" + IL_01af: stloc.2 + IL_01b0: br.s IL_01f2 + + IL_01b2: ldstr "Text5" + IL_01b7: stloc.2 + IL_01b8: br.s IL_01f2 + + IL_01ba: ldstr "Text6" + IL_01bf: stloc.2 + IL_01c0: br.s IL_01f2 + + IL_01c2: ldstr "Text7" + IL_01c7: stloc.2 + IL_01c8: br.s IL_01f2 + + IL_01ca: ldstr "Text8" + IL_01cf: stloc.2 + IL_01d0: br.s IL_01f2 + + IL_01d2: ldstr "Text9" + IL_01d7: stloc.2 + IL_01d8: br.s IL_01f2 + + IL_01da: ldstr "Text10" + IL_01df: stloc.2 + IL_01e0: br.s IL_01f2 + + IL_01e2: ldstr "Text11" + IL_01e7: stloc.2 + IL_01e8: br.s IL_01f2 + + IL_01ea: ldstr "Default" + IL_01ef: stloc.2 + IL_01f0: br.s IL_01f2 + + IL_01f2: ldloc.2 + IL_01f3: ret + } // end of method Switch::SwitchOverString2 + + .method public hidebysig static string + SwitchOverBool(bool b) cil managed + { + // Code size 59 (0x3b) + .maxstack 2 + .locals init (bool V_0, + string V_1) + IL_0000: nop + IL_0001: ldstr "SwitchOverBool: " + IL_0006: ldarga.s b + IL_0008: call instance string [mscorlib]System.Boolean::ToString() + IL_000d: call string [mscorlib]System.String::Concat(string, + string) + IL_0012: call void [mscorlib]System.Console::WriteLine(string) + IL_0017: nop + IL_0018: ldarg.0 + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: brfalse.s IL_002d + + IL_001d: br.s IL_001f + + IL_001f: ldloc.0 + IL_0020: ldc.i4.1 + IL_0021: beq.s IL_0025 + + IL_0023: br.s IL_0035 + + IL_0025: ldsfld string [mscorlib]System.Boolean::TrueString + IL_002a: stloc.1 + IL_002b: br.s IL_0039 + + IL_002d: ldsfld string [mscorlib]System.Boolean::FalseString + IL_0032: stloc.1 + IL_0033: br.s IL_0039 + + IL_0035: ldnull + IL_0036: stloc.1 + IL_0037: br.s IL_0039 + + IL_0039: ldloc.1 + IL_003a: ret + } // end of method Switch::SwitchOverBool + + .method public hidebysig static void SwitchInLoop(int32 i) cil managed + { + // Code size 128 (0x80) + .maxstack 2 + .locals init (int32 V_0, + bool V_1) + IL_0000: nop + IL_0001: ldstr "SwitchInLoop: " + IL_0006: ldarg.0 + IL_0007: box [mscorlib]System.Int32 + IL_000c: call string [mscorlib]System.String::Concat(object, + object) + IL_0011: call void [mscorlib]System.Console::WriteLine(string) + IL_0016: nop + IL_0017: br.s IL_007b + + IL_0019: nop + IL_001a: ldarg.0 + IL_001b: stloc.0 + IL_001c: ldloc.0 + IL_001d: ldc.i4.1 + IL_001e: sub + IL_001f: switch ( + IL_0036, + IL_0043, + IL_005d, + IL_0050) + IL_0034: br.s IL_005d + + IL_0036: ldstr "one" + IL_003b: call void [mscorlib]System.Console::WriteLine(string) + IL_0040: nop + IL_0041: br.s IL_0075 + + IL_0043: ldstr "two" + IL_0048: call void [mscorlib]System.Console::WriteLine(string) + IL_004d: nop + IL_004e: br.s IL_0075 + + IL_0050: ldstr "four" + IL_0055: call void [mscorlib]System.Console::WriteLine(string) + IL_005a: nop + IL_005b: br.s IL_007f + + IL_005d: ldstr "default" + IL_0062: call void [mscorlib]System.Console::WriteLine(string) + IL_0067: nop + IL_0068: ldstr "more code" + IL_006d: call void [mscorlib]System.Console::WriteLine(string) + IL_0072: nop + IL_0073: br.s IL_007f + + IL_0075: ldarg.0 + IL_0076: ldc.i4.1 + IL_0077: add + IL_0078: starg.s i + IL_007a: nop + IL_007b: ldc.i4.1 + IL_007c: stloc.1 + IL_007d: br.s IL_0019 + + IL_007f: ret + } // end of method Switch::SwitchInLoop + + .method public hidebysig static void SwitchWithGoto(int32 i) cil managed + { + // Code size 128 (0x80) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: nop + IL_0001: ldstr "SwitchWithGoto: " + IL_0006: ldarg.0 + IL_0007: box [mscorlib]System.Int32 + IL_000c: call string [mscorlib]System.String::Concat(object, + object) + IL_0011: call void [mscorlib]System.Console::WriteLine(string) + IL_0016: nop + IL_0017: ldarg.0 + IL_0018: stloc.0 + IL_0019: ldloc.0 + IL_001a: ldc.i4.1 + IL_001b: sub + IL_001c: switch ( + IL_0033, + IL_0040, + IL_004d, + IL_005a) + IL_0031: br.s IL_0067 + + IL_0033: ldstr "one" + IL_0038: call void [mscorlib]System.Console::WriteLine(string) + IL_003d: nop + IL_003e: br.s IL_0067 + + IL_0040: ldstr "two" + IL_0045: call void [mscorlib]System.Console::WriteLine(string) + IL_004a: nop + IL_004b: br.s IL_004d + + IL_004d: ldstr "three" + IL_0052: call void [mscorlib]System.Console::WriteLine(string) + IL_0057: nop + IL_0058: br.s IL_0074 + + IL_005a: ldstr "four" + IL_005f: call void [mscorlib]System.Console::WriteLine(string) + IL_0064: nop + IL_0065: br.s IL_007f + + IL_0067: ldstr "default" + IL_006c: call void [mscorlib]System.Console::WriteLine(string) + IL_0071: nop + IL_0072: br.s IL_0074 + + IL_0074: ldstr "End of method" + IL_0079: call void [mscorlib]System.Console::WriteLine(string) + IL_007e: nop + IL_007f: ret + } // end of method Switch::SwitchWithGoto + + .method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] + GetProperties() cil managed + { + // Code size 12 (0xc) + .maxstack 1 + .locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] V_0) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: newarr ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty + IL_0007: stloc.0 + IL_0008: br.s IL_000a + + IL_000a: ldloc.0 + IL_000b: ret + } // end of method Switch::GetProperties + + .method public hidebysig static void SwitchOnStringInForLoop() cil managed + { + // Code size 255 (0xff) + .maxstack 2 + .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0, + class [mscorlib]System.Collections.Generic.List`1 V_1, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] V_2, + int32 V_3, + class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty V_4, + string V_5, + bool V_6) + IL_0000: nop + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_0006: stloc.0 + IL_0007: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() + IL_000c: stloc.1 + IL_000d: call class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch::GetProperties() + IL_0012: stloc.2 + IL_0013: ldc.i4.0 + IL_0014: stloc.3 + IL_0015: br IL_00ef + + IL_001a: nop + IL_001b: ldloc.2 + IL_001c: ldloc.3 + IL_001d: ldelem.ref + IL_001e: stloc.s V_4 + IL_0020: ldloc.s V_4 + IL_0022: ldfld class [mscorlib]System.Reflection.PropertyInfo ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::Property + IL_0027: callvirt instance string [mscorlib]System.Reflection.MemberInfo::get_Name() + IL_002c: stloc.s V_5 + IL_002e: ldloc.s V_5 + IL_0030: ldstr "Name1" + IL_0035: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_003a: brtrue.s IL_0084 + + IL_003c: ldloc.s V_5 + IL_003e: ldstr "Name2" + IL_0043: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0048: brtrue.s IL_0098 + + IL_004a: ldloc.s V_5 + IL_004c: ldstr "Name3" + IL_0051: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0056: brtrue.s IL_00ac + + IL_0058: ldloc.s V_5 + IL_005a: ldstr "Name4" + IL_005f: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0064: brtrue.s IL_00c0 + + IL_0066: ldloc.s V_5 + IL_0068: ldstr "Name5" + IL_006d: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0072: brtrue.s IL_00d4 + + IL_0074: ldloc.s V_5 + IL_0076: ldstr "Name6" + IL_007b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0080: brtrue.s IL_00d4 + + IL_0082: br.s IL_00df + + IL_0084: ldloc.s V_4 + IL_0086: ldc.i4.1 + IL_0087: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_008c: nop + IL_008d: ldloc.0 + IL_008e: ldloc.s V_4 + IL_0090: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0095: nop + IL_0096: br.s IL_00ea + + IL_0098: ldloc.s V_4 + IL_009a: ldc.i4.2 + IL_009b: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00a0: nop + IL_00a1: ldloc.0 + IL_00a2: ldloc.s V_4 + IL_00a4: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00a9: nop + IL_00aa: br.s IL_00ea + + IL_00ac: ldloc.s V_4 + IL_00ae: ldc.i4.3 + IL_00af: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00b4: nop + IL_00b5: ldloc.0 + IL_00b6: ldloc.s V_4 + IL_00b8: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00bd: nop + IL_00be: br.s IL_00ea + + IL_00c0: ldloc.s V_4 + IL_00c2: ldc.i4.4 + IL_00c3: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00c8: nop + IL_00c9: ldloc.0 + IL_00ca: ldloc.s V_4 + IL_00cc: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00d1: nop + IL_00d2: br.s IL_00ea + + IL_00d4: ldloc.0 + IL_00d5: ldloc.s V_4 + IL_00d7: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00dc: nop + IL_00dd: br.s IL_00ea + + IL_00df: ldloc.1 + IL_00e0: ldloc.s V_4 + IL_00e2: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00e7: nop + IL_00e8: br.s IL_00ea + + IL_00ea: nop + IL_00eb: ldloc.3 + IL_00ec: ldc.i4.1 + IL_00ed: add + IL_00ee: stloc.3 + IL_00ef: ldloc.3 + IL_00f0: ldloc.2 + IL_00f1: ldlen + IL_00f2: conv.i4 + IL_00f3: clt + IL_00f5: stloc.s V_6 + IL_00f7: ldloc.s V_6 + IL_00f9: brtrue IL_001a + + IL_00fe: ret + } // end of method Switch::SwitchOnStringInForLoop + + .method public hidebysig static void SwitchWithComplexCondition(string[] args) cil managed + { + // Code size 134 (0x86) + .maxstack 2 + .locals init (string V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldlen + IL_0003: brfalse.s IL_000a + + IL_0005: ldarg.0 + IL_0006: ldc.i4.0 + IL_0007: ldelem.ref + IL_0008: br.s IL_000f + + IL_000a: ldstr "dummy" + IL_000f: stloc.0 + IL_0010: ldloc.0 + IL_0011: ldstr "a" + IL_0016: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_001b: brtrue.s IL_0046 + + IL_001d: ldloc.0 + IL_001e: ldstr "b" + IL_0023: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0028: brtrue.s IL_0053 + + IL_002a: ldloc.0 + IL_002b: ldstr "c" + IL_0030: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0035: brtrue.s IL_0060 + + IL_0037: ldloc.0 + IL_0038: ldstr "d" + IL_003d: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0042: brtrue.s IL_006d + + IL_0044: br.s IL_007a + + IL_0046: ldstr "a" + IL_004b: call void [mscorlib]System.Console::WriteLine(string) + IL_0050: nop + IL_0051: br.s IL_007a + + IL_0053: ldstr "b" + IL_0058: call void [mscorlib]System.Console::WriteLine(string) + IL_005d: nop + IL_005e: br.s IL_007a + + IL_0060: ldstr "c" + IL_0065: call void [mscorlib]System.Console::WriteLine(string) + IL_006a: nop + IL_006b: br.s IL_007a + + IL_006d: ldstr "d" + IL_0072: call void [mscorlib]System.Console::WriteLine(string) + IL_0077: nop + IL_0078: br.s IL_007a + + IL_007a: ldstr "end" + IL_007f: call void [mscorlib]System.Console::WriteLine(string) + IL_0084: nop + IL_0085: ret + } // end of method Switch::SwitchWithComplexCondition + + .method public hidebysig static void SwitchWithArray(string[] args) cil managed + { + // Code size 123 (0x7b) + .maxstack 2 + .locals init (string V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldc.i4.0 + IL_0003: ldelem.ref + IL_0004: stloc.0 + IL_0005: ldloc.0 + IL_0006: ldstr "a" + IL_000b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0010: brtrue.s IL_003b + + IL_0012: ldloc.0 + IL_0013: ldstr "b" + IL_0018: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_001d: brtrue.s IL_0048 + + IL_001f: ldloc.0 + IL_0020: ldstr "c" + IL_0025: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002a: brtrue.s IL_0055 + + IL_002c: ldloc.0 + IL_002d: ldstr "d" + IL_0032: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0037: brtrue.s IL_0062 + + IL_0039: br.s IL_006f + + IL_003b: ldstr "a" + IL_0040: call void [mscorlib]System.Console::WriteLine(string) + IL_0045: nop + IL_0046: br.s IL_006f + + IL_0048: ldstr "b" + IL_004d: call void [mscorlib]System.Console::WriteLine(string) + IL_0052: nop + IL_0053: br.s IL_006f + + IL_0055: ldstr "c" + IL_005a: call void [mscorlib]System.Console::WriteLine(string) + IL_005f: nop + IL_0060: br.s IL_006f + + IL_0062: ldstr "d" + IL_0067: call void [mscorlib]System.Console::WriteLine(string) + IL_006c: nop + IL_006d: br.s IL_006f + + IL_006f: ldstr "end" + IL_0074: call void [mscorlib]System.Console::WriteLine(string) + IL_0079: nop + IL_007a: ret + } // end of method Switch::SwitchWithArray + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch + +.class private auto ansi sealed '' + extends [mscorlib]System.Object +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly hidebysig static uint32 + ComputeStringHash(string s) cil managed + { + // Code size 46 (0x2e) + .maxstack 2 + .locals init (uint32 V_0, + int32 V_1) + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_002c + + IL_0003: ldc.i4 0x811c9dc5 + IL_0008: stloc.0 + IL_0009: ldc.i4.0 + IL_000a: stloc.1 + IL_000b: br.s IL_0021 + + IL_000d: ldarg.0 + IL_000e: ldloc.1 + IL_000f: callvirt instance char [mscorlib]System.String::get_Chars(int32) + IL_0014: ldloc.0 + IL_0015: xor + IL_0016: ldc.i4 0x1000193 + IL_001b: mul + IL_001c: stloc.0 + IL_001d: ldloc.1 + IL_001e: ldc.i4.1 + IL_001f: add + IL_0020: stloc.1 + IL_0021: ldloc.1 + IL_0022: ldarg.0 + IL_0023: callvirt instance int32 [mscorlib]System.String::get_Length() + IL_0028: bge.s IL_002c + + IL_002a: br.s IL_000d + + IL_002c: ldloc.0 + IL_002d: ret + } // end of method ''::ComputeStringHash + +} // end of class '' + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.cs index 853b19653..72db78dfb 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.cs @@ -199,5 +199,20 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty { return Math.Abs(a - b); } + + public bool CompareDelegatesByValue(Action a, Action b) + { + return a == b; + } + + public bool CompareDelegatesByReference(Action a, Action b) + { + return (object)a == b; + } + + public bool CompareDelegateWithNull(Action a) + { + return a == null; + } } } diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.il index acd241b96..0eab76d08 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.il @@ -1,5 +1,5 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.18020 +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 // Copyright (c) Microsoft Corporation. All rights reserved. @@ -10,7 +10,7 @@ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 4:0:0:0 } -.assembly q5z5ui4l +.assembly ph2u0axx { .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 @@ -20,15 +20,15 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 } -.module q5z5ui4l.dll -// MVID: {E0E1769A-5636-428C-B7CE-29408F5D108F} +.module ph2u0axx.dll +// MVID: {8F821F70-8053-4F18-BDF7-88A43880B754} .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: 0x024D0000 +// Image base: 0x00D70000 // =============== CLASS MEMBERS DECLARATION =================== @@ -681,6 +681,60 @@ IL_000d: ret } // end of method TypeAnalysisTests::EnumDiff + .method public hidebysig instance bool + CompareDelegatesByValue(class [mscorlib]System.Action a, + class [mscorlib]System.Action b) cil managed + { + // Code size 13 (0xd) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call bool [mscorlib]System.Delegate::op_Equality(class [mscorlib]System.Delegate, + class [mscorlib]System.Delegate) + IL_0008: stloc.0 + IL_0009: br.s IL_000b + + IL_000b: ldloc.0 + IL_000c: ret + } // end of method TypeAnalysisTests::CompareDelegatesByValue + + .method public hidebysig instance bool + CompareDelegatesByReference(class [mscorlib]System.Action a, + class [mscorlib]System.Action b) cil managed + { + // Code size 10 (0xa) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: ceq + IL_0005: stloc.0 + IL_0006: br.s IL_0008 + + IL_0008: ldloc.0 + IL_0009: ret + } // end of method TypeAnalysisTests::CompareDelegatesByReference + + .method public hidebysig instance bool + CompareDelegateWithNull(class [mscorlib]System.Action a) cil managed + { + // Code size 10 (0xa) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldnull + IL_0003: ceq + IL_0005: stloc.0 + IL_0006: br.s IL_0008 + + IL_0008: ldloc.0 + IL_0009: ret + } // end of method TypeAnalysisTests::CompareDelegateWithNull + .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.il index 25071943f..c5c37d26a 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.il @@ -1,5 +1,5 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.18020 +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 // Copyright (c) Microsoft Corporation. All rights reserved. @@ -10,7 +10,7 @@ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 4:0:0:0 } -.assembly '5lntuoy2' +.assembly frnxitb5 { .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 @@ -20,15 +20,15 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 } -.module '5lntuoy2.dll' -// MVID: {85A70DA1-7D32-4ED1-89B1-4720D974D969} +.module frnxitb5.dll +// MVID: {DC6B1392-D29F-44A5-97D6-0C026DCD3A00} .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: 0x05730000 +// Image base: 0x00D50000 // =============== CLASS MEMBERS DECLARATION =================== @@ -474,6 +474,42 @@ IL_0008: ret } // end of method TypeAnalysisTests::EnumDiff + .method public hidebysig instance bool + CompareDelegatesByValue(class [mscorlib]System.Action a, + class [mscorlib]System.Action b) cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: call bool [mscorlib]System.Delegate::op_Equality(class [mscorlib]System.Delegate, + class [mscorlib]System.Delegate) + IL_0007: ret + } // end of method TypeAnalysisTests::CompareDelegatesByValue + + .method public hidebysig instance bool + CompareDelegatesByReference(class [mscorlib]System.Action a, + class [mscorlib]System.Action b) cil managed + { + // Code size 5 (0x5) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: ceq + IL_0004: ret + } // end of method TypeAnalysisTests::CompareDelegatesByReference + + .method public hidebysig instance bool + CompareDelegateWithNull(class [mscorlib]System.Action a) cil managed + { + // Code size 5 (0x5) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldnull + IL_0002: ceq + IL_0004: ret + } // end of method TypeAnalysisTests::CompareDelegateWithNull + .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.roslyn.il index 2644fb9ba..0a09fe8f2 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.roslyn.il @@ -1,5 +1,5 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.18020 +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 // Copyright (c) Microsoft Corporation. All rights reserved. @@ -25,14 +25,14 @@ .ver 0:0:0:0 } .module TypeAnalysisTests.dll -// MVID: {60E6985E-8E86-4693-9F02-AD3FF7341588} +// MVID: {B6659F2C-8CAA-447B-9D1D-D59D8C40C6D7} .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: 0x02440000 +// Image base: 0x003E0000 // =============== CLASS MEMBERS DECLARATION =================== @@ -476,6 +476,42 @@ IL_0008: ret } // end of method TypeAnalysisTests::EnumDiff + .method public hidebysig instance bool + CompareDelegatesByValue(class [mscorlib]System.Action a, + class [mscorlib]System.Action b) cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: call bool [mscorlib]System.Delegate::op_Equality(class [mscorlib]System.Delegate, + class [mscorlib]System.Delegate) + IL_0007: ret + } // end of method TypeAnalysisTests::CompareDelegatesByValue + + .method public hidebysig instance bool + CompareDelegatesByReference(class [mscorlib]System.Action a, + class [mscorlib]System.Action b) cil managed + { + // Code size 5 (0x5) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: ceq + IL_0004: ret + } // end of method TypeAnalysisTests::CompareDelegatesByReference + + .method public hidebysig instance bool + CompareDelegateWithNull(class [mscorlib]System.Action a) cil managed + { + // Code size 5 (0x5) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldnull + IL_0002: ceq + IL_0004: ret + } // end of method TypeAnalysisTests::CompareDelegateWithNull + .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.roslyn.il index e18c1015f..f12c3a17a 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.roslyn.il @@ -1,5 +1,5 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.18020 +// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 // Copyright (c) Microsoft Corporation. All rights reserved. @@ -25,14 +25,14 @@ .ver 0:0:0:0 } .module TypeAnalysisTests.dll -// MVID: {389E1347-98C0-49C1-B484-EDF5FFA1CD16} +// MVID: {E25A3961-A07D-4220-AB6C-FE5B1624514C} .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: 0x027F0000 +// Image base: 0x00D80000 // =============== CLASS MEMBERS DECLARATION =================== @@ -680,6 +680,60 @@ IL_000d: ret } // end of method TypeAnalysisTests::EnumDiff + .method public hidebysig instance bool + CompareDelegatesByValue(class [mscorlib]System.Action a, + class [mscorlib]System.Action b) cil managed + { + // Code size 13 (0xd) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call bool [mscorlib]System.Delegate::op_Equality(class [mscorlib]System.Delegate, + class [mscorlib]System.Delegate) + IL_0008: stloc.0 + IL_0009: br.s IL_000b + + IL_000b: ldloc.0 + IL_000c: ret + } // end of method TypeAnalysisTests::CompareDelegatesByValue + + .method public hidebysig instance bool + CompareDelegatesByReference(class [mscorlib]System.Action a, + class [mscorlib]System.Action b) cil managed + { + // Code size 10 (0xa) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: ceq + IL_0005: stloc.0 + IL_0006: br.s IL_0008 + + IL_0008: ldloc.0 + IL_0009: ret + } // end of method TypeAnalysisTests::CompareDelegatesByReference + + .method public hidebysig instance bool + CompareDelegateWithNull(class [mscorlib]System.Action a) cil managed + { + // Code size 10 (0xa) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldnull + IL_0003: ceq + IL_0005: stloc.0 + IL_0006: br.s IL_0008 + + IL_0008: ldloc.0 + IL_0009: ret + } // end of method TypeAnalysisTests::CompareDelegateWithNull + .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Using.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Using.cs index 3f615c56b..a531888f0 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Using.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Using.cs @@ -58,7 +58,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public void SimpleUsingExpressionStatementWithDeclaration() { using (MemoryStream memoryStream = new MemoryStream()) { - memoryStream.WriteByte((byte)42); + memoryStream.WriteByte(42); Console.WriteLine("using-body: " + memoryStream.Position); } } diff --git a/ICSharpCode.Decompiler/CSharp/Annotations.cs b/ICSharpCode.Decompiler/CSharp/Annotations.cs index dde037429..40d1b5f93 100644 --- a/ICSharpCode.Decompiler/CSharp/Annotations.cs +++ b/ICSharpCode.Decompiler/CSharp/Annotations.cs @@ -164,4 +164,18 @@ namespace ICSharpCode.Decompiler.CSharp this.Variable = v; } } + + public class ForeachAnnotation + { + public readonly ILInstruction GetEnumeratorCall; + public readonly ILInstruction MoveNextCall; + public readonly ILInstruction GetCurrentCall; + + public ForeachAnnotation(ILInstruction getEnumeratorCall, ILInstruction moveNextCall, ILInstruction getCurrentCall) + { + GetEnumeratorCall = getEnumeratorCall; + MoveNextCall = moveNextCall; + GetCurrentCall = getCurrentCall; + } + } } diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs index 1d3990401..1bba92164 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs @@ -30,6 +30,7 @@ using ICSharpCode.Decompiler.IL; using ICSharpCode.Decompiler.IL.ControlFlow; using ICSharpCode.Decompiler.IL.Transforms; using ICSharpCode.Decompiler.TypeSystem; +using ICSharpCode.Decompiler.Util; namespace ICSharpCode.Decompiler.CSharp { @@ -71,6 +72,7 @@ namespace ICSharpCode.Decompiler.CSharp new SplitVariables(), new ILInlining(), new DetectPinnedRegions(), // must run after inlining but before non-critical control flow transforms + new InlineReturnTransform(), new YieldReturnDecompiler(), // must run after inlining but before loop detection new AsyncAwaitDecompiler(), // must run after inlining but before loop detection new DetectCatchWhenConditionBlocks(), // must run after inlining but before loop detection @@ -81,6 +83,9 @@ namespace ICSharpCode.Decompiler.CSharp new RemoveDeadVariableInit(), new SplitVariables(), // split variables once again, because the stobj(ldloca V, ...) may open up new replacements new SwitchDetection(), + new SwitchOnStringTransform(), + new SwitchOnNullableTransform(), + new SplitVariables(), // split variables once again, because SwitchOnNullableTransform eliminates ldloca new BlockILTransform { // per-block transforms PostOrderTransforms = { // Even though it's a post-order block-transform as most other transforms, @@ -121,8 +126,9 @@ namespace ICSharpCode.Decompiler.CSharp ) } }, + new ProxyCallReplacer(), new DelegateConstruction(), - new AssignVariableNames() + new AssignVariableNames(), }; } @@ -139,7 +145,7 @@ namespace ICSharpCode.Decompiler.CSharp new IntroduceExtensionMethods(), // must run after IntroduceUsingDeclarations new IntroduceQueryExpressions(), // must run after IntroduceExtensionMethods new CombineQueryExpressions(), - //new FlattenSwitchBlocks(), + new FlattenSwitchBlocks(), new FixNameCollisions(), new AddXmlDocumentationTransform(), }; @@ -196,8 +202,8 @@ namespace ICSharpCode.Decompiler.CSharp if (settings.AsyncAwait && AsyncAwaitDecompiler.IsCompilerGeneratedStateMachine(type)) return true; } else if (type.IsCompilerGenerated()) { -// if (type.Name.StartsWith("", StringComparison.Ordinal)) -// return true; + if (type.Name.StartsWith("", StringComparison.Ordinal)) + return true; if (settings.AnonymousTypes && type.IsAnonymousType()) return true; } @@ -210,8 +216,8 @@ namespace ICSharpCode.Decompiler.CSharp return true; if (settings.AutomaticProperties && IsAutomaticPropertyBackingField(field)) return true; -// if (settings.SwitchStatementOnString && IsSwitchOnStringCache(field)) -// return true; + if (settings.SwitchStatementOnString && IsSwitchOnStringCache(field)) + return true; } // event-fields are not [CompilerGenerated] if (settings.AutomaticEvents && field.DeclaringType.Events.Any(ev => ev.Name == field.Name)) @@ -977,6 +983,19 @@ namespace ICSharpCode.Decompiler.CSharp } #endregion + #region Sequence Points + /// + /// Creates sequence points for the given syntax tree. + /// + /// This only works correctly when the nodes in the syntax tree have line/column information. + /// + public Dictionary> CreateSequencePoints(SyntaxTree syntaxTree) + { + SequencePointBuilder spb = new SequencePointBuilder(); + syntaxTree.AcceptVisitor(spb); + return spb.GetSequencePoints(); + } + #endregion } [Flags] diff --git a/ICSharpCode.Decompiler/CSharp/CallBuilder.cs b/ICSharpCode.Decompiler/CSharp/CallBuilder.cs index b50676a44..525758a73 100644 --- a/ICSharpCode.Decompiler/CSharp/CallBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/CallBuilder.cs @@ -22,16 +22,11 @@ using System.Diagnostics; using System.Linq; using ICSharpCode.Decompiler.CSharp.Resolver; using ICSharpCode.Decompiler.CSharp.Syntax; -using ICSharpCode.Decompiler.CSharp.Transforms; -using ICSharpCode.Decompiler.CSharp.TypeSystem; using ICSharpCode.Decompiler.IL; using ICSharpCode.Decompiler.Semantics; using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem.Implementation; using ICSharpCode.Decompiler.Util; -using ExpressionType = System.Linq.Expressions.ExpressionType; -using PrimitiveType = ICSharpCode.Decompiler.CSharp.Syntax.PrimitiveType; -using System.Threading; namespace ICSharpCode.Decompiler.CSharp { @@ -140,7 +135,7 @@ namespace ICSharpCode.Decompiler.CSharp atce.Initializers.Add( new NamedExpression { Name = expectedParameters[i].Name, - Expression = argumentExpressions[i] + Expression = arguments[i].ConvertTo(expectedParameters[i].Type, expressionBuilder) }); } } @@ -148,10 +143,16 @@ namespace ICSharpCode.Decompiler.CSharp .WithILInstruction(inst) .WithRR(rr); } else { + if (IsUnambiguousCall(inst, target, method, Array.Empty(), arguments) != OverloadResolutionErrors.None) { for (int i = 0; i < arguments.Count; i++) { - if (!settings.AnonymousTypes || !expectedParameters[i].Type.ContainsAnonymousType()) + if (settings.AnonymousTypes && expectedParameters[i].Type.ContainsAnonymousType()) { + if (arguments[i].Expression is LambdaExpression lambda) { + ModifyReturnTypeOfLambda(lambda); + } + } else { arguments[i] = arguments[i].ConvertTo(expectedParameters[i].Type, expressionBuilder); + } } } return new ObjectCreateExpression(expressionBuilder.ConvertType(inst.Method.DeclaringType), arguments.SelectArray(arg => arg.Expression)) @@ -163,6 +164,9 @@ namespace ICSharpCode.Decompiler.CSharp return HandleAccessorCall(inst, target, method, arguments.ToList()); } else if (method.Name == "Invoke" && method.DeclaringType.Kind == TypeKind.Delegate) { return new InvocationExpression(target, arguments.Select(arg => arg.Expression)).WithILInstruction(inst).WithRR(rr); + } else if (IsDelegateEqualityComparison(method, arguments)) { + return HandleDelegateEqualityComparison(method, arguments) + .WithILInstruction(inst).WithRR(rr); } else { bool requireTypeArguments = false; bool targetCasted = false; @@ -182,8 +186,13 @@ namespace ICSharpCode.Decompiler.CSharp if (!argumentsCasted) { argumentsCasted = true; for (int i = 0; i < arguments.Count; i++) { - if (!settings.AnonymousTypes || !expectedParameters[i].Type.ContainsAnonymousType()) + if (settings.AnonymousTypes && expectedParameters[i].Type.ContainsAnonymousType()) { + if (arguments[i].Expression is LambdaExpression lambda) { + ModifyReturnTypeOfLambda(lambda); + } + } else { arguments[i] = arguments[i].ConvertTo(expectedParameters[i].Type, expressionBuilder); + } } } else if (!targetCasted) { targetCasted = true; @@ -215,6 +224,51 @@ namespace ICSharpCode.Decompiler.CSharp } } + private void ModifyReturnTypeOfLambda(LambdaExpression lambda) + { + var resolveResult = (DecompiledLambdaResolveResult)lambda.GetResolveResult(); + if (lambda.Body is Expression exprBody) + lambda.Body = new TranslatedExpression(exprBody.Detach()).ConvertTo(resolveResult.ReturnType, expressionBuilder); + else + ModifyReturnStatementInsideLambda(resolveResult.ReturnType, lambda); + resolveResult.InferredReturnType = resolveResult.ReturnType; + } + + private void ModifyReturnStatementInsideLambda(IType returnType, AstNode parent) + { + foreach (var child in parent.Children) { + if (child is LambdaExpression || child is AnonymousMethodExpression) + continue; + if (child is ReturnStatement ret) { + ret.Expression = new TranslatedExpression(ret.Expression.Detach()).ConvertTo(returnType, expressionBuilder); + continue; + } + ModifyReturnStatementInsideLambda(returnType, child); + } + } + + private bool IsDelegateEqualityComparison(IMethod method, IList arguments) + { + // Comparison on a delegate type is a C# builtin operator + // that compiles down to a Delegate.op_Equality call. + // We handle this as a special case to avoid inserting a cast to System.Delegate. + return method.IsOperator + && method.DeclaringType.IsKnownType(KnownTypeCode.Delegate) + && (method.Name == "op_Equality" || method.Name == "op_Inequality") + && arguments.Count == 2 + && arguments[0].Type.Kind == TypeKind.Delegate + && arguments[1].Type.Equals(arguments[0].Type); + } + + private Expression HandleDelegateEqualityComparison(IMethod method, IList arguments) + { + return new BinaryOperatorExpression( + arguments[0], + method.Name == "op_Equality" ? BinaryOperatorType.Equality : BinaryOperatorType.InEquality, + arguments[1] + ); + } + OverloadResolutionErrors IsUnambiguousCall(ILInstruction inst, TranslatedExpression target, IMethod method, IType[] typeArguments, IList arguments) { var lookup = new MemberLookup(resolver.CurrentTypeDefinition, resolver.CurrentTypeDefinition.ParentAssembly); @@ -321,39 +375,47 @@ namespace ICSharpCode.Decompiler.CSharp case OpCode.LdVirtFtn: method = ((LdVirtFtn)func).Method; break; + case OpCode.ILFunction: + method = ((ILFunction)func).Method; + return expressionBuilder.TranslateFunction(inst.Method.DeclaringType, (ILFunction)func) + .WithILInstruction(inst); default: - method = (IMethod)typeSystem.Resolve(((ILFunction)func).Method); - break; + throw new ArgumentException($"Unknown instruction type: {func.OpCode}"); + } + var invokeMethod = inst.Method.DeclaringType.GetDelegateInvokeMethod(); + TranslatedExpression target; + IType targetType; + if (method.IsExtensionMethod && invokeMethod != null && method.Parameters.Count - 1 == invokeMethod.Parameters.Count) { + target = expressionBuilder.Translate(inst.Arguments[0]); + targetType = method.Parameters[0].Type; + } else { + target = expressionBuilder.TranslateTarget(method, inst.Arguments[0], func.OpCode == OpCode.LdFtn); + targetType = method.DeclaringType; } - var target = expressionBuilder.TranslateTarget(method, inst.Arguments[0], func.OpCode == OpCode.LdFtn); var lookup = new MemberLookup(resolver.CurrentTypeDefinition, resolver.CurrentTypeDefinition.ParentAssembly); var or = new OverloadResolution(resolver.Compilation, method.Parameters.SelectArray(p => new TypeResolveResult(p.Type))); - var result = lookup.Lookup(target.ResolveResult, method.Name, method.TypeArguments, true) as MethodGroupResolveResult; + var result = lookup.Lookup(target.ResolveResult, method.Name, method.TypeArguments, false); - if (result == null) { - target = target.ConvertTo(method.DeclaringType, expressionBuilder); - } else { - or.AddMethodLists(result.MethodsGroupedByDeclaringType.ToArray()); - if (or.BestCandidateErrors != OverloadResolutionErrors.None || !IsAppropriateCallTarget(method, or.BestCandidate, func.OpCode == OpCode.LdVirtFtn)) - target = target.ConvertTo(method.DeclaringType, expressionBuilder); + bool needsCast = true; + if (result is MethodGroupResolveResult mgrr) { + or.AddMethodLists(mgrr.MethodsGroupedByDeclaringType.ToArray()); + needsCast = (or.BestCandidateErrors != OverloadResolutionErrors.None || !IsAppropriateCallTarget(method, or.BestCandidate, func.OpCode == OpCode.LdVirtFtn)); + } + if (needsCast) { + target = target.ConvertTo(targetType, expressionBuilder); + result = lookup.Lookup(target.ResolveResult, method.Name, method.TypeArguments, false); } var mre = new MemberReferenceExpression(target, method.Name); mre.TypeArguments.AddRange(method.TypeArguments.Select(expressionBuilder.ConvertType)); + mre.WithRR(result); var oce = new ObjectCreateExpression(expressionBuilder.ConvertType(inst.Method.DeclaringType), mre) - // .WithAnnotation(new DelegateConstruction.Annotation(func.OpCode == OpCode.LdVirtFtn, target, method.Name)) .WithILInstruction(inst) .WithRR(new ConversionResolveResult( inst.Method.DeclaringType, new MemberResolveResult(target.ResolveResult, method), - // TODO handle extension methods capturing the first argument Conversion.MethodGroupConversion(method, func.OpCode == OpCode.LdVirtFtn, false))); - - if (func is ILFunction) { - return expressionBuilder.TranslateFunction(oce, target, (ILFunction)func); - } else { - return oce; - } + return oce; } } } \ No newline at end of file diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs index 4528bece8..8c5e3ea8c 100644 --- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs @@ -69,7 +69,7 @@ namespace ICSharpCode.Decompiler.CSharp internal readonly ICompilation compilation; internal readonly CSharpResolver resolver; readonly TypeSystemAstBuilder astBuilder; - readonly DecompilerSettings settings; + internal readonly DecompilerSettings settings; readonly CancellationToken cancellationToken; public ExpressionBuilder(IDecompilerTypeSystem typeSystem, ITypeResolveContext decompilationContext, DecompilerSettings settings, CancellationToken cancellationToken) @@ -93,19 +93,21 @@ namespace ICSharpCode.Decompiler.CSharp return astType; } - public ExpressionWithResolveResult ConvertConstantValue(ResolveResult rr) + public ExpressionWithResolveResult ConvertConstantValue(ResolveResult rr, bool allowImplicitConversion = false) { var expr = astBuilder.ConvertConstantValue(rr); - if (expr is NullReferenceExpression && rr.Type.Kind != TypeKind.Null) { - expr = new CastExpression(ConvertType(rr.Type), expr); - } else { - switch (rr.Type.GetDefinition()?.KnownTypeCode) { - case KnownTypeCode.SByte: - case KnownTypeCode.Byte: - case KnownTypeCode.Int16: - case KnownTypeCode.UInt16: - expr = new CastExpression(new PrimitiveType(KnownTypeReference.GetCSharpNameByTypeCode(rr.Type.GetDefinition().KnownTypeCode)), expr); - break; + if (!allowImplicitConversion) { + if (expr is NullReferenceExpression && rr.Type.Kind != TypeKind.Null) { + expr = new CastExpression(ConvertType(rr.Type), expr); + } else { + switch (rr.Type.GetDefinition()?.KnownTypeCode) { + case KnownTypeCode.SByte: + case KnownTypeCode.Byte: + case KnownTypeCode.Int16: + case KnownTypeCode.UInt16: + expr = new CastExpression(new PrimitiveType(KnownTypeReference.GetCSharpNameByTypeCode(rr.Type.GetDefinition().KnownTypeCode)), expr); + break; + } } } var exprRR = expr.Annotation(); @@ -310,12 +312,12 @@ namespace ICSharpCode.Decompiler.CSharp .WithILInstruction(inst) .WithRR(new ConstantResolveResult(compilation.FindType(KnownTypeCode.String), inst.Value)); } - + protected internal override TranslatedExpression VisitLdNull(LdNull inst, TranslationContext context) { return GetDefaultValueExpression(SpecialType.NullType).WithILInstruction(inst); } - + protected internal override TranslatedExpression VisitDefaultValue(DefaultValue inst, TranslationContext context) { return GetDefaultValueExpression(inst.Type).WithILInstruction(inst); @@ -323,8 +325,15 @@ namespace ICSharpCode.Decompiler.CSharp internal ExpressionWithResolveResult GetDefaultValueExpression(IType type) { - var expr = type.IsReferenceType == true ? (Expression)new NullReferenceExpression() : new DefaultValueExpression(ConvertType(type)); - var constantType = type.IsReferenceType == true ? SpecialType.NullType : type; + Expression expr; + IType constantType; + if (type.IsReferenceType == true || type.IsKnownType(KnownTypeCode.NullableOfT)) { + expr = new NullReferenceExpression(); + constantType = SpecialType.NullType; + } else { + expr = new DefaultValueExpression(ConvertType(type)); + constantType = type; + } return expr.WithRR(new ConstantResolveResult(constantType, null)); } @@ -490,6 +499,19 @@ namespace ICSharpCode.Decompiler.CSharp left = AdjustConstantExpressionToType(left, right.Type); right = AdjustConstantExpressionToType(right, left.Type); + if (left.Type.Kind == TypeKind.Delegate && right.Type.Kind == TypeKind.Null + || left.Type.Kind == TypeKind.Null && right.Type.Kind == TypeKind.Delegate) + { + // When comparing a delegate with null, the C# compiler generates a reference comparison. + negateOutput = false; + return new BinaryOperatorExpression(left.Expression, inst.Kind.ToBinaryOperatorType(), right.Expression) + .WithILInstruction(inst) + .WithRR(new OperatorResolveResult( + compilation.FindType(KnownTypeCode.Boolean), + inst.Kind == ComparisonKind.Equality ? ExpressionType.Equal : ExpressionType.NotEqual, + left.ResolveResult, right.ResolveResult)); + } + var rr = resolver.ResolveBinaryOperator(inst.Kind.ToBinaryOperatorType(), left.ResolveResult, right.ResolveResult) as OperatorResolveResult; if (rr == null || rr.IsError || rr.UserDefinedOperatorMethod != null @@ -672,6 +694,12 @@ namespace ICSharpCode.Decompiler.CSharp } } + if ((op == BinaryOperatorType.BitwiseAnd || op == BinaryOperatorType.BitwiseOr || op == BinaryOperatorType.ExclusiveOr) + && (left.Type.Kind == TypeKind.Enum || right.Type.Kind == TypeKind.Enum)) { + left = AdjustConstantExpressionToType(left, right.Type); + right = AdjustConstantExpressionToType(right, left.Type); + } + var rr = resolverWithOverflowCheck.ResolveBinaryOperator(op, left.ResolveResult, right.ResolveResult); if (rr.IsError || NullableType.GetUnderlyingType(rr.Type).GetStackType() != inst.UnderlyingResultType || !IsCompatibleWithSign(left.Type, inst.Sign) || !IsCompatibleWithSign(right.Type, inst.Sign)) @@ -1024,31 +1052,30 @@ namespace ICSharpCode.Decompiler.CSharp return new CallBuilder(this, typeSystem, settings).Build(inst); } - internal TranslatedExpression TranslateFunction(TranslatedExpression objectCreateExpression, TranslatedExpression target, ILFunction function) + internal ExpressionWithResolveResult TranslateFunction(IType delegateType, ILFunction function) { - var method = typeSystem.Resolve(function.Method)?.MemberDefinition as IMethod; + var method = function.Method.MemberDefinition as IMethod; Debug.Assert(method != null); // Create AnonymousMethodExpression and prepare parameters AnonymousMethodExpression ame = new AnonymousMethodExpression(); ame.IsAsync = function.IsAsync; ame.Parameters.AddRange(MakeParameters(method, function)); - ame.HasParameterList = true; + ame.HasParameterList = ame.Parameters.Count > 0; StatementBuilder builder = new StatementBuilder(typeSystem.GetSpecializingTypeSystem(new SimpleTypeResolveContext(method)), this.decompilationContext, method, function, settings, cancellationToken); var body = builder.ConvertAsBlock(function.Body); - bool isLambda = false; - bool isMultiLineLambda = false; Comment prev = null; foreach (string warning in function.Warnings) { body.InsertChildAfter(prev, prev = new Comment(warning), Roles.Comment); } - // if there is an anonymous type involved, we are forced to use a lambda expression. + bool isLambda = false; if (ame.Parameters.Any(p => p.Type.IsNull)) { + // if there is an anonymous type involved, we are forced to use a lambda expression. isLambda = true; - isMultiLineLambda = body.Statements.Count > 1; } else if (ame.Parameters.All(p => p.ParameterModifier == ParameterModifier.None)) { + // otherwise use lambda only if an expression lambda is possible isLambda = (body.Statements.Count == 1 && body.Statements.Single() is ReturnStatement); } // Remove the parameter list from an AnonymousMethodExpression if the original method had no names, @@ -1064,39 +1091,81 @@ namespace ICSharpCode.Decompiler.CSharp ame.HasParameterList = false; } } - + Expression replacement; + IType inferredReturnType; if (isLambda) { LambdaExpression lambda = new LambdaExpression(); + lambda.IsAsync = ame.IsAsync; lambda.CopyAnnotationsFrom(ame); ame.Parameters.MoveTo(lambda.Parameters); - if (isMultiLineLambda) { - lambda.Body = body; + if (body.Statements.Count == 1 && body.Statements.Single() is ReturnStatement returnStmt) { + lambda.Body = returnStmt.Expression.Detach(); + inferredReturnType = lambda.Body.GetResolveResult().Type; } else { - Expression returnExpr = ((ReturnStatement)body.Statements.Single()).Expression; - returnExpr.Remove(); - lambda.Body = returnExpr; + lambda.Body = body; + inferredReturnType = InferReturnType(body); } replacement = lambda; } else { ame.Body = body; + inferredReturnType = InferReturnType(body); replacement = ame; } - var expectedType = objectCreateExpression.ResolveResult.Type; - var expectedTypeDefinition = expectedType.GetDefinition(); - if (expectedTypeDefinition != null && expectedTypeDefinition.Kind != TypeKind.Delegate) { - var simplifiedDelegateCreation = (ObjectCreateExpression)objectCreateExpression.Expression.Clone(); - simplifiedDelegateCreation.Arguments.Clear(); - simplifiedDelegateCreation.Arguments.Add(replacement); - replacement = simplifiedDelegateCreation; - } else if (!settings.AnonymousTypes || !expectedType.ContainsAnonymousType()) { - replacement = new CastExpression(ConvertType(expectedType), replacement); + if (ame.IsAsync) { + inferredReturnType = GetTaskType(inferredReturnType); } - return replacement - .WithILInstruction(function) - .WithRR(objectCreateExpression.ResolveResult); + + var rr = new DecompiledLambdaResolveResult( + function, delegateType, inferredReturnType, + hasParameterList: ame.HasParameterList, + isAnonymousMethod: !isLambda, + isImplicitlyTyped: ame.Parameters.Any(p => p.Type.IsNull)); + + TranslatedExpression translatedLambda = replacement.WithILInstruction(function).WithRR(rr); + return new CastExpression(ConvertType(delegateType), translatedLambda) + .WithRR(new ConversionResolveResult(delegateType, rr, LambdaConversion.Instance)); } - + + IType InferReturnType(BlockStatement body) + { + var returnExpressions = new List(); + CollectReturnExpressions(body); + var ti = new TypeInference(compilation, resolver.conversions); + return ti.GetBestCommonType(returnExpressions, out _); + // Failure to infer a return type does not make the lambda invalid, + // so we can ignore the 'success' value + + void CollectReturnExpressions(AstNode node) + { + if (node is ReturnStatement ret) { + if (!ret.Expression.IsNull) { + returnExpressions.Add(ret.Expression.GetResolveResult()); + } + } else if (node is LambdaExpression || node is AnonymousMethodExpression) { + // do not recurse into nested lambdas + return; + } + foreach (var child in node.Children) { + CollectReturnExpressions(child); + } + } + } + + IType GetTaskType(IType resultType) + { + if (resultType.Kind == TypeKind.Unknown) + return SpecialType.UnknownType; + if (resultType.Kind == TypeKind.Void) + return compilation.FindType(KnownTypeCode.Task); + + ITypeDefinition def = compilation.FindType(KnownTypeCode.TaskOfT).GetDefinition(); + if (def != null) + return new ParameterizedType(def, new[] { resultType }); + else + return SpecialType.UnknownType; + } + IEnumerable MakeParameters(IMethod method, ILFunction function) { var variables = function.Variables.Where(v => v.Kind == VariableKind.Parameter).ToDictionary(v => v.Index); @@ -1384,11 +1453,10 @@ namespace ICSharpCode.Decompiler.CSharp if (currentPath == null) { currentPath = info.Path; } else { - int firstDifferenceIndex = Math.Min(currentPath.Count, info.Path.Count); - int index = 0; - while (index < firstDifferenceIndex && info.Path[index] == currentPath[index]) - index++; - firstDifferenceIndex = index; + int minLen = Math.Min(currentPath.Count, info.Path.Count); + int firstDifferenceIndex = 0; + while (firstDifferenceIndex < minLen && info.Path[firstDifferenceIndex] == currentPath[firstDifferenceIndex]) + firstDifferenceIndex++; while (elementsStack.Count - 1 > firstDifferenceIndex) { var methodElement = currentPath[elementsStack.Count - 1]; var pathElement = currentPath[elementsStack.Count - 2]; diff --git a/ICSharpCode.Decompiler/CSharp/NRefactoryExtensions.cs b/ICSharpCode.Decompiler/CSharp/NRefactoryExtensions.cs index af2cce2b5..a1f3bb3d2 100644 --- a/ICSharpCode.Decompiler/CSharp/NRefactoryExtensions.cs +++ b/ICSharpCode.Decompiler/CSharp/NRefactoryExtensions.cs @@ -17,8 +17,10 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Linq; using ICSharpCode.Decompiler.CSharp.Syntax; using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching; +using ICSharpCode.Decompiler.IL; namespace ICSharpCode.Decompiler.CSharp { @@ -31,7 +33,7 @@ namespace ICSharpCode.Decompiler.CSharp node.AddAnnotation(annotation); return node; } - + public static T CopyAnnotationsFrom(this T node, AstNode other) where T : AstNode { foreach (object annotation in other.Annotations) { @@ -39,7 +41,15 @@ namespace ICSharpCode.Decompiler.CSharp } return node; } - + + public static T CopyInstructionsFrom(this T node, AstNode other) where T : AstNode + { + foreach (object annotation in other.Annotations.OfType()) { + node.AddAnnotation(annotation); + } + return node; + } + public static T Detach(this T node) where T : AstNode { node.Remove(); diff --git a/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs b/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs index 076ae703b..cc3708c81 100644 --- a/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs +++ b/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs @@ -90,6 +90,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor Space(policy.SpaceBeforeBracketComma); // TODO: Comma policy has changed. writer.WriteToken(Roles.Comma, ","); + isAfterSpace = false; Space(!noSpaceAfterComma && policy.SpaceAfterBracketComma); // TODO: Comma policy has changed. } @@ -194,6 +195,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor #region Write tokens protected bool isAtStartOfLine = true; + protected bool isAfterSpace; /// /// Writes a keyword, and all specials up to @@ -207,18 +209,21 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor { writer.WriteKeyword(tokenRole, token); isAtStartOfLine = false; + isAfterSpace = false; } protected virtual void WriteIdentifier(Identifier identifier) { writer.WriteIdentifier(identifier); isAtStartOfLine = false; + isAfterSpace = false; } protected virtual void WriteIdentifier(string identifier) { AstType.Create(identifier).AcceptVisitor(this); isAtStartOfLine = false; + isAfterSpace = false; } protected virtual void WriteToken(TokenRole tokenRole) @@ -230,6 +235,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor { writer.WriteToken(tokenRole, token); isAtStartOfLine = false; + isAfterSpace = false; } protected virtual void LPar() @@ -260,8 +266,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor /// protected virtual void Space(bool addSpace = true) { - if (addSpace) { + if (addSpace && !isAfterSpace) { writer.Space(); + isAfterSpace = true; } } @@ -269,6 +276,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor { writer.NewLine(); isAtStartOfLine = true; + isAfterSpace = false; } protected virtual void OpenBrace(BraceStyle style) @@ -278,7 +286,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor case BraceStyle.EndOfLine: case BraceStyle.BannerStyle: if (!isAtStartOfLine) - writer.Space(); + Space(); writer.WriteToken(Roles.LBrace, "{"); break; case BraceStyle.EndOfLineWithoutSpace: @@ -882,6 +890,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor { StartNode(nullReferenceExpression); writer.WritePrimitiveValue(null); + isAfterSpace = false; EndNode(nullReferenceExpression); } @@ -937,6 +946,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor { StartNode(primitiveExpression); writer.WritePrimitiveValue(primitiveExpression.Value, primitiveExpression.UnsafeLiteralValue); + isAfterSpace = false; EndNode(primitiveExpression); } #endregion diff --git a/ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertMissingTokensDecorator.cs b/ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertMissingTokensDecorator.cs index 203e29c43..8748eff1b 100644 --- a/ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertMissingTokensDecorator.cs +++ b/ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertMissingTokensDecorator.cs @@ -88,7 +88,10 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor if (node != null) node.Location = start; } - if (t != null) currentList.Add(t); + if (t != null) { + currentList.Add(t); + t.Role = role; + } base.WriteKeyword(role, keyword); } @@ -103,13 +106,14 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor public override void WritePrimitiveValue(object value, string literalValue = null) { Expression node = nodes.Peek().LastOrDefault() as Expression; + var startLocation = locationProvider.Location; + base.WritePrimitiveValue(value, literalValue); if (node is PrimitiveExpression) { - ((PrimitiveExpression)node).SetStartLocation(locationProvider.Location); + ((PrimitiveExpression)node).SetLocation(startLocation, locationProvider.Location); } if (node is NullReferenceExpression) { - ((NullReferenceExpression)node).SetStartLocation(locationProvider.Location); + ((NullReferenceExpression)node).SetStartLocation(startLocation); } - base.WritePrimitiveValue(value, literalValue); } public override void WritePrimitiveType(string type) diff --git a/ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterOutputFormatter.cs b/ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterOutputFormatter.cs index 8d93ada89..a0f37ff74 100644 --- a/ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterOutputFormatter.cs +++ b/ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterOutputFormatter.cs @@ -128,7 +128,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor case CommentType.SingleLine: textWriter.Write("//"); textWriter.WriteLine(content); - column += 2 + content.Length; + column = 1; + line++; needsIndent = true; isAtStartOfLine = true; break; @@ -144,7 +145,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor case CommentType.Documentation: textWriter.Write("///"); textWriter.WriteLine(content); - column += 3 + content.Length; + column = 1; + line++; needsIndent = true; isAtStartOfLine = true; break; diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/LambdaResolveResult.cs b/ICSharpCode.Decompiler/CSharp/Resolver/LambdaResolveResult.cs index 73f431953..eb6e33475 100644 --- a/ICSharpCode.Decompiler/CSharp/Resolver/LambdaResolveResult.cs +++ b/ICSharpCode.Decompiler/CSharp/Resolver/LambdaResolveResult.cs @@ -16,6 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +using System; using System.Collections.Generic; using ICSharpCode.Decompiler.Semantics; using ICSharpCode.Decompiler.TypeSystem; @@ -97,4 +98,80 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver return new [] { this.Body }; } } + + sealed class DecompiledLambdaResolveResult : LambdaResolveResult + { + readonly IL.ILFunction function; + public readonly IType DelegateType; + + /// + /// The inferred return type. + /// Can differ from ReturnType if a return statement + /// performs an implicit conversion. + /// + public IType InferredReturnType; + + public DecompiledLambdaResolveResult(IL.ILFunction function, + IType delegateType, + IType inferredReturnType, + bool hasParameterList, + bool isAnonymousMethod, + bool isImplicitlyTyped) + { + this.function = function ?? throw new ArgumentNullException(nameof(function)); + this.DelegateType = delegateType ?? throw new ArgumentNullException(nameof(delegateType)); + this.InferredReturnType = inferredReturnType ?? throw new ArgumentNullException(nameof(inferredReturnType)); + this.HasParameterList = hasParameterList; + this.IsAnonymousMethod = isAnonymousMethod; + this.IsImplicitlyTyped = isImplicitlyTyped; + this.Body = new ResolveResult(SpecialType.UnknownType); + } + + public override bool HasParameterList { get; } + public override bool IsAnonymousMethod { get; } + public override bool IsImplicitlyTyped { get; } + public override bool IsAsync => function.IsAsync; + + public override IList Parameters => function.Method.Parameters; + public override IType ReturnType => function.Method.ReturnType; + + public override ResolveResult Body { get; } + + public override IType GetInferredReturnType(IType[] parameterTypes) + { + // We don't know how to compute which type would be inferred if + // given other parameter types. + // Let's hope this is good enough: + return InferredReturnType; + } + + public override Conversion IsValid(IType[] parameterTypes, IType returnType, CSharpConversions conversions) + { + if (this.Parameters.Count != parameterTypes.Length) + return Conversion.None; + for (int i = 0; i < parameterTypes.Length; ++i) { + if (!parameterTypes[i].Equals(this.Parameters[i].Type)) { + if (IsImplicitlyTyped) { + // it's possible that different parameter types also lead to a valid conversion + return LambdaConversion.Instance; + } else { + return Conversion.None; + } + } + } + if (returnType.Equals(this.ReturnType)) { + return LambdaConversion.Instance; + } else { + return Conversion.None; + } + } + } + + class LambdaConversion : Conversion + { + public static readonly LambdaConversion Instance = new LambdaConversion(); + + public override bool IsAnonymousFunctionConversion => true; + public override bool IsImplicit => true; + } } diff --git a/ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs b/ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs new file mode 100644 index 000000000..0daf76ab6 --- /dev/null +++ b/ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs @@ -0,0 +1,329 @@ +// Copyright (c) 2017 Daniel Grunwald +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using ICSharpCode.Decompiler.CSharp.Syntax; +using ICSharpCode.Decompiler.IL; +using ICSharpCode.Decompiler.Util; + +namespace ICSharpCode.Decompiler.CSharp +{ + /// + /// Given a SyntaxTree that was output from the decompiler, constructs the list of sequence points. + /// + class SequencePointBuilder : DepthFirstAstVisitor + { + struct StatePerSequencePoint + { + /// + /// Main AST node associated with this sequence point. + /// + internal readonly AstNode PrimaryNode; + + /// + /// List of IL intervals that are associated with this sequence point. + /// + internal readonly List Intervals; + + /// + /// The function containing this sequence point. + /// + internal ILFunction Function; + + public StatePerSequencePoint(AstNode primaryNode) + { + this.PrimaryNode = primaryNode; + this.Intervals = new List(); + this.Function = null; + } + } + + readonly List<(ILFunction, SequencePoint)> sequencePoints = new List<(ILFunction, SequencePoint)>(); + readonly HashSet mappedInstructions = new HashSet(); + + // Stack holding information for outer statements. + readonly Stack outerStates = new Stack(); + + // Collects information for the current sequence point. + StatePerSequencePoint current; + + void VisitAsSequencePoint(AstNode node) + { + if (node.IsNull) return; + StartSequencePoint(node); + node.AcceptVisitor(this); + EndSequencePoint(node.StartLocation, node.EndLocation); + } + + protected override void VisitChildren(AstNode node) + { + base.VisitChildren(node); + AddToSequencePoint(node); + } + + public override void VisitBlockStatement(BlockStatement blockStatement) + { + foreach (var stmt in blockStatement.Statements) { + VisitAsSequencePoint(stmt); + } + } + + public override void VisitForStatement(ForStatement forStatement) + { + // Every element of a for-statement is it's own sequence point. + foreach (var init in forStatement.Initializers) { + VisitAsSequencePoint(init); + } + VisitAsSequencePoint(forStatement.Condition); + foreach (var inc in forStatement.Iterators) { + VisitAsSequencePoint(inc); + } + VisitAsSequencePoint(forStatement.EmbeddedStatement); + } + + public override void VisitSwitchStatement(SwitchStatement switchStatement) + { + StartSequencePoint(switchStatement); + switchStatement.Expression.AcceptVisitor(this); + foreach (var section in switchStatement.SwitchSections) { + // note: sections will not contribute to the current sequence point + section.AcceptVisitor(this); + } + // add switch statement itself to sequence point + // (call only after the sections are visited) + AddToSequencePoint(switchStatement); + EndSequencePoint(switchStatement.StartLocation, switchStatement.RParToken.EndLocation); + } + + public override void VisitSwitchSection(Syntax.SwitchSection switchSection) + { + // every statement in the switch section is its own sequence point + foreach (var stmt in switchSection.Statements) { + VisitAsSequencePoint(stmt); + } + } + + public override void VisitLambdaExpression(LambdaExpression lambdaExpression) + { + AddToSequencePoint(lambdaExpression); + VisitAsSequencePoint(lambdaExpression.Body); + } + + public override void VisitUsingStatement(UsingStatement usingStatement) + { + StartSequencePoint(usingStatement); + usingStatement.ResourceAcquisition.AcceptVisitor(this); + VisitAsSequencePoint(usingStatement.EmbeddedStatement); + AddToSequencePoint(usingStatement); + EndSequencePoint(usingStatement.StartLocation, usingStatement.RParToken.EndLocation); + } + + public override void VisitForeachStatement(ForeachStatement foreachStatement) + { + var foreachInfo = foreachStatement.Annotation(); + if (foreachInfo == null) { + base.VisitForeachStatement(foreachStatement); + return; + } + // TODO : Add a sequence point on foreach token (mapped to nop before using instruction). + StartSequencePoint(foreachStatement); + foreachStatement.InExpression.AcceptVisitor(this); + AddToSequencePoint(foreachInfo.GetEnumeratorCall); + EndSequencePoint(foreachStatement.InExpression.StartLocation, foreachStatement.InExpression.EndLocation); + StartSequencePoint(foreachStatement); + AddToSequencePoint(foreachInfo.MoveNextCall); + EndSequencePoint(foreachStatement.InToken.StartLocation, foreachStatement.InToken.EndLocation); + StartSequencePoint(foreachStatement); + AddToSequencePoint(foreachInfo.GetCurrentCall); + EndSequencePoint(foreachStatement.VariableType.StartLocation, foreachStatement.VariableNameToken.EndLocation); + VisitAsSequencePoint(foreachStatement.EmbeddedStatement); + } + + public override void VisitLockStatement(LockStatement lockStatement) + { + StartSequencePoint(lockStatement); + lockStatement.Expression.AcceptVisitor(this); + VisitAsSequencePoint(lockStatement.EmbeddedStatement); + AddToSequencePoint(lockStatement); + EndSequencePoint(lockStatement.StartLocation, lockStatement.RParToken.EndLocation); + } + + public override void VisitIfElseStatement(IfElseStatement ifElseStatement) + { + StartSequencePoint(ifElseStatement); + ifElseStatement.Condition.AcceptVisitor(this); + VisitAsSequencePoint(ifElseStatement.TrueStatement); + VisitAsSequencePoint(ifElseStatement.FalseStatement); + AddToSequencePoint(ifElseStatement); + EndSequencePoint(ifElseStatement.StartLocation, ifElseStatement.RParToken.EndLocation); + } + + public override void VisitWhileStatement(WhileStatement whileStatement) + { + StartSequencePoint(whileStatement); + whileStatement.Condition.AcceptVisitor(this); + VisitAsSequencePoint(whileStatement.EmbeddedStatement); + AddToSequencePoint(whileStatement); + EndSequencePoint(whileStatement.StartLocation, whileStatement.RParToken.EndLocation); + } + + public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement) + { + StartSequencePoint(doWhileStatement); + VisitAsSequencePoint(doWhileStatement.EmbeddedStatement); + doWhileStatement.Condition.AcceptVisitor(this); + AddToSequencePoint(doWhileStatement); + EndSequencePoint(doWhileStatement.WhileToken.StartLocation, doWhileStatement.RParToken.EndLocation); + } + + public override void VisitFixedStatement(FixedStatement fixedStatement) + { + foreach (var v in fixedStatement.Variables) { + VisitAsSequencePoint(v); + } + VisitAsSequencePoint(fixedStatement.EmbeddedStatement); + } + + /// + /// Start a new C# statement = new sequence point. + /// + void StartSequencePoint(AstNode primaryNode) + { + outerStates.Push(current); + current = new StatePerSequencePoint(primaryNode); + } + + void EndSequencePoint(TextLocation startLocation, TextLocation endLocation) + { + Debug.Assert(!startLocation.IsEmpty, "missing startLocation"); + Debug.Assert(!endLocation.IsEmpty, "missing endLocation"); + if (current.Intervals.Count > 0 && current.Function != null) { + // use LongSet to deduplicate and merge the intervals + var longSet = new LongSet(current.Intervals.Select(i => new LongInterval(i.Start, i.End))); + Debug.Assert(!longSet.IsEmpty); + sequencePoints.Add((current.Function, new SequencePoint { + Offset = (int)longSet.Intervals[0].Start, + EndOffset = (int)longSet.Intervals[0].End, + StartLine = startLocation.Line, + StartColumn = startLocation.Column, + EndLine = endLocation.Line, + EndColumn = endLocation.Column + })); + } + current = outerStates.Pop(); + } + + /// + /// Add the ILAst instruction associated with the AstNode to the sequence point. + /// Also add all its ILAst sub-instructions (unless they were already added to another sequence point). + /// + void AddToSequencePoint(AstNode node) + { + foreach (var inst in node.Annotations.OfType()) { + AddToSequencePoint(inst); + } + } + + void AddToSequencePoint(ILInstruction inst) + { + if (!mappedInstructions.Add(inst)) { + // inst was already used by a nested sequence point within this sequence point + return; + } + // Add the IL range associated with this instruction to the current sequence point. + if (HasUsableILRange(inst) && current.Intervals != null) { + current.Intervals.Add(inst.ILRange); + var function = inst.Parent.Ancestors.OfType().FirstOrDefault(); + Debug.Assert(current.Function == null || current.Function == function); + current.Function = function; + } + + // Do not add instructions of lambdas/delegates. + if (inst is ILFunction) + return; + + // Also add the child IL instructions, unless they were already processed by + // another C# expression. + foreach (var child in inst.Children) { + AddToSequencePoint(child); + } + } + + internal static bool HasUsableILRange(ILInstruction inst) + { + if (inst.ILRange.IsEmpty) + return false; + return !(inst is BlockContainer || inst is Block); + } + + /// + /// Called after the visitor is done to return the results. + /// + internal Dictionary> GetSequencePoints() + { + var dict = new Dictionary>(); + foreach (var (function, sequencePoint) in this.sequencePoints) { + if (!dict.TryGetValue(function, out var list)) { + dict.Add(function, list = new List()); + } + list.Add(sequencePoint); + } + foreach (var (function, list) in dict.ToList()) { + // For each function, sort sequence points and fix overlaps+gaps + var newList = new List(); + int pos = 0; + foreach (var sequencePoint in list.OrderBy(sp => sp.Offset).ThenBy(sp => sp.EndOffset)) { + if (sequencePoint.Offset < pos) { + // overlapping sequence point? + // delete previous sequence points that are after sequencePoint.Offset + while (newList.Count > 0 && newList.Last().EndOffset > pos) { + var last = newList.Last(); + if (last.Offset >= sequencePoint.Offset) { + newList.RemoveAt(newList.Count - 1); + } else { + last.EndOffset = sequencePoint.Offset; + newList[newList.Count - 1] = last; + } + } + } else if (sequencePoint.Offset > pos) { + // insert hidden sequence point in the gap. + var hidden = new SequencePoint(); + hidden.Offset = pos; + hidden.EndOffset = sequencePoint.Offset; + hidden.SetHidden(); + newList.Add(hidden); + } + newList.Add(sequencePoint); + pos = sequencePoint.EndOffset; + } + if (pos < function.CecilMethod.Body.CodeSize) { + var hidden = new SequencePoint(); + hidden.Offset = pos; + hidden.EndOffset = function.CecilMethod.Body.CodeSize; + hidden.SetHidden(); + newList.Add(hidden); + } + dict[function] = newList; + } + return dict; + } + } +} diff --git a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs index 8de9734cf..c537ccf89 100644 --- a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs @@ -83,42 +83,134 @@ namespace ICSharpCode.Decompiler.CSharp return new IfElseStatement(condition, trueStatement, falseStatement); } - CaseLabel CreateTypedCaseLabel(long i, IType type) + ConstantResolveResult CreateTypedCaseLabel(long i, IType type, string[] map = null) { object value; + // unpack nullable type, if necessary: + // we need to do this in all cases, because there are nullable bools and enum types as well. + type = NullableType.GetUnderlyingType(type); if (type.IsKnownType(KnownTypeCode.Boolean)) { value = i != 0; + } else if (type.IsKnownType(KnownTypeCode.String) && map != null) { + value = map[i]; } else if (type.Kind == TypeKind.Enum) { var enumType = type.GetDefinition().EnumUnderlyingType; value = CSharpPrimitiveCast.Cast(ReflectionHelper.GetTypeCode(enumType), i, false); } else { value = CSharpPrimitiveCast.Cast(ReflectionHelper.GetTypeCode(type), i, false); } - return new CaseLabel(exprBuilder.ConvertConstantValue(new ConstantResolveResult(type, value))); + return new ConstantResolveResult(type, value); } - + protected internal override Statement VisitSwitchInstruction(SwitchInstruction inst) { + return TranslateSwitch(null, inst); + } + + SwitchStatement TranslateSwitch(BlockContainer switchContainer, SwitchInstruction inst) + { + Debug.Assert(switchContainer.EntryPoint.IncomingEdgeCount == 1); var oldBreakTarget = breakTarget; - breakTarget = null; // 'break' within a switch would only leave the switch - - var value = exprBuilder.Translate(inst.Value); - var stmt = new SwitchStatement() { Expression = value }; + breakTarget = switchContainer; // 'break' within a switch would only leave the switch + var oldCaseLabelMapping = caseLabelMapping; + caseLabelMapping = new Dictionary(); + + TranslatedExpression value; + var strToInt = inst.Value as StringToInt; + if (strToInt != null) { + value = exprBuilder.Translate(strToInt.Argument); + } else { + value = exprBuilder.Translate(inst.Value); + } + + // Pick the section with the most labels as default section. + IL.SwitchSection defaultSection = inst.Sections.First(); foreach (var section in inst.Sections) { - var astSection = new Syntax.SwitchSection(); - astSection.CaseLabels.AddRange(section.Labels.Values.Select(i => CreateTypedCaseLabel(i, value.Type))); - ConvertSwitchSectionBody(astSection, section.Body); - stmt.SwitchSections.Add(astSection); + if (section.Labels.Count() > defaultSection.Labels.Count()) { + defaultSection = section; + } } - - if (inst.DefaultBody.OpCode != OpCode.Nop) { + + var stmt = new SwitchStatement() { Expression = value }; + Dictionary translationDictionary = new Dictionary(); + // initialize C# switch sections. + foreach (var section in inst.Sections) { + // This is used in the block-label mapping. + ConstantResolveResult firstValueResolveResult; var astSection = new Syntax.SwitchSection(); - astSection.CaseLabels.Add(new CaseLabel()); - ConvertSwitchSectionBody(astSection, inst.DefaultBody); + // Create case labels: + if (section == defaultSection) { + astSection.CaseLabels.Add(new CaseLabel()); + firstValueResolveResult = null; + } else { + var values = section.Labels.Values.Select(i => CreateTypedCaseLabel(i, value.Type, strToInt?.Map)).ToArray(); + if (section.HasNullLabel) { + astSection.CaseLabels.Add(new CaseLabel(new NullReferenceExpression())); + firstValueResolveResult = new ConstantResolveResult(SpecialType.NullType, null); + } else { + Debug.Assert(values.Length > 0); + firstValueResolveResult = values[0]; + } + astSection.CaseLabels.AddRange(values.Select(label => new CaseLabel(exprBuilder.ConvertConstantValue(label, allowImplicitConversion: true)))); + } + switch (section.Body) { + case Branch br: + // we can only inline the block, if all branches are in the switchContainer. + if (br.TargetBlock.Parent == switchContainer && switchContainer.Descendants.OfType().Where(b => b.TargetBlock == br.TargetBlock).All(b => BlockContainer.FindClosestSwitchContainer(b) == switchContainer)) + caseLabelMapping.Add(br.TargetBlock, firstValueResolveResult); + break; + default: + break; + } + translationDictionary.Add(section, astSection); stmt.SwitchSections.Add(astSection); } + foreach (var section in inst.Sections) { + var astSection = translationDictionary[section]; + switch (section.Body) { + case Branch br: + // we can only inline the block, if all branches are in the switchContainer. + if (br.TargetBlock.Parent == switchContainer && switchContainer.Descendants.OfType().Where(b => b.TargetBlock == br.TargetBlock).All(b => BlockContainer.FindClosestSwitchContainer(b) == switchContainer)) + ConvertSwitchSectionBody(astSection, br.TargetBlock); + else + ConvertSwitchSectionBody(astSection, section.Body); + break; + case Leave leave: + if (astSection.CaseLabels.Count == 1 && astSection.CaseLabels.First().Expression.IsNull && leave.TargetContainer == switchContainer) { + stmt.SwitchSections.Remove(astSection); + break; + } + goto default; + default: + ConvertSwitchSectionBody(astSection, section.Body); + break; + } + } + if (switchContainer != null) { + // Translate any remaining blocks: + var lastSectionStatements = stmt.SwitchSections.Last().Statements; + foreach (var block in switchContainer.Blocks.Skip(1)) { + if (caseLabelMapping.ContainsKey(block)) continue; + lastSectionStatements.Add(new LabelStatement { Label = block.Label }); + foreach (var nestedInst in block.Instructions) { + var nestedStmt = Convert(nestedInst); + if (nestedStmt is BlockStatement b) { + foreach (var nested in b.Statements) + lastSectionStatements.Add(nested.Detach()); + } else { + lastSectionStatements.Add(nestedStmt); + } + } + Debug.Assert(block.FinalInstruction.OpCode == OpCode.Nop); + } + if (endContainerLabels.TryGetValue(switchContainer, out string label)) { + lastSectionStatements.Add(new LabelStatement { Label = label }); + lastSectionStatements.Add(new BreakStatement()); + } + } breakTarget = oldBreakTarget; + caseLabelMapping = oldCaseLabelMapping; return stmt; } @@ -141,6 +233,8 @@ namespace ICSharpCode.Decompiler.CSharp Block continueTarget; /// Number of ContinueStatements that were created for the current continueTarget int continueCount; + /// Maps blocks to cases. + Dictionary caseLabelMapping; protected internal override Statement VisitBranch(Branch inst) { @@ -148,6 +242,11 @@ namespace ICSharpCode.Decompiler.CSharp continueCount++; return new ContinueStatement(); } + if (caseLabelMapping != null && caseLabelMapping.TryGetValue(inst.TargetBlock, out var label)) { + if (label == null) + return new GotoDefaultStatement(); + return new GotoCaseStatement() { LabelExpression = exprBuilder.ConvertConstantValue(label, allowImplicitConversion: true) }; + } return new GotoStatement(inst.TargetLabel); } @@ -407,6 +506,7 @@ namespace ICSharpCode.Decompiler.CSharp }; // Add the variable annotation for highlighting (TokenTextWriter expects it directly on the ForeachStatement). foreachStmt.AddAnnotation(new ILVariableResolveResult(foreachVariable, foreachVariable.Type)); + foreachStmt.AddAnnotation(new ForeachAnnotation(inst.ResourceExpression, loop.Conditions.Single(), singleGetter)); // If there was an optional return statement, return it as well. if (optionalReturnAfterLoop != null) { return new BlockStatement { @@ -608,8 +708,12 @@ namespace ICSharpCode.Decompiler.CSharp continueCount = oldContinueCount; breakTarget = oldBreakTarget; return loop; + } else if (container.EntryPoint.Instructions.Count == 1 && container.EntryPoint.Instructions[0] is SwitchInstruction switchInst) { + return TranslateSwitch(container, switchInst); } else { - return ConvertBlockContainer(container, false); + var blockStmt = ConvertBlockContainer(container, false); + blockStmt.AddAnnotation(container); + return blockStmt; } } @@ -757,5 +861,33 @@ namespace ICSharpCode.Decompiler.CSharp return block.ChildIndex == container.Blocks.Count - 1 && container == leave.TargetContainer; } + + protected internal override Statement VisitInitblk(Initblk inst) + { + var stmt = new ExpressionStatement(new InvocationExpression { + Target = new IdentifierExpression("memset"), + Arguments = { + exprBuilder.Translate(inst.Address), + exprBuilder.Translate(inst.Value), + exprBuilder.Translate(inst.Size) + } + }); + stmt.AddChild(new Comment(" IL initblk instruction"), Roles.Comment); + return stmt; + } + + protected internal override Statement VisitCpblk(Cpblk inst) + { + var stmt = new ExpressionStatement(new InvocationExpression { + Target = new IdentifierExpression("memcpy"), + Arguments = { + exprBuilder.Translate(inst.DestAddress), + exprBuilder.Translate(inst.SourceAddress), + exprBuilder.Translate(inst.Size) + } + }); + stmt.AddChild(new Comment(" IL cpblk instruction"), Roles.Comment); + return stmt; + } } } diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs index af3818269..3e6d49724 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs @@ -43,11 +43,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax } } - internal void SetStartLocation(TextLocation value) + internal void SetLocation(TextLocation startLocation, TextLocation endLocation) { ThrowIfFrozen(); - this.startLocation = value; - this.endLocation = null; + this.startLocation = startLocation; + this.endLocation = endLocation; } string literalValue; diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs b/ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs index 91386de38..d4959d99e 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs @@ -188,7 +188,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms #endregion #region FindInsertionPoints - List<(InsertionPoint InsertionPoint, BlockContainer Loop)> loopTracking = new List<(InsertionPoint, BlockContainer)>(); + List<(InsertionPoint InsertionPoint, BlockContainer Scope)> scopeTracking = new List<(InsertionPoint, BlockContainer)>(); /// /// Finds insertion points for all variables used within `node` @@ -202,25 +202,27 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms /// void FindInsertionPoints(AstNode node, int nodeLevel) { - BlockContainer loop = node.Annotation(); - if (loop != null) { - loopTracking.Add((new InsertionPoint { level = nodeLevel, nextNode = node }, loop)); + BlockContainer scope = node.Annotation(); + if (scope != null && (scope.EntryPoint.IncomingEdgeCount > 1 || scope.Parent is ILFunction)) { + // track loops and function bodies as scopes, for comparison with CaptureScope. + scopeTracking.Add((new InsertionPoint { level = nodeLevel, nextNode = node }, scope)); + } else { + scope = null; // don't remove a scope if we didn't add one } try { for (AstNode child = node.FirstChild; child != null; child = child.NextSibling) { FindInsertionPoints(child, nodeLevel + 1); } - var identExpr = node as IdentifierExpression; - if (identExpr != null) { + if (node is IdentifierExpression identExpr) { var rr = identExpr.GetResolveResult() as ILVariableResolveResult; if (rr != null && VariableNeedsDeclaration(rr.Variable.Kind)) { var variable = rr.Variable; InsertionPoint newPoint; - int startIndex = loopTracking.Count - 1; - if (variable.CaptureScope != null && startIndex > -1 && variable.CaptureScope != loopTracking[startIndex].Loop) { - while (startIndex > -1 && loopTracking[startIndex].Loop != variable.CaptureScope) + int startIndex = scopeTracking.Count - 1; + if (variable.CaptureScope != null && startIndex > 0 && variable.CaptureScope != scopeTracking[startIndex].Scope) { + while (startIndex > 0 && scopeTracking[startIndex].Scope != variable.CaptureScope) startIndex--; - newPoint = loopTracking[startIndex + 1].InsertionPoint; + newPoint = scopeTracking[startIndex + 1].InsertionPoint; } else { newPoint = new InsertionPoint { level = nodeLevel, nextNode = identExpr }; } @@ -236,8 +238,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms } } } finally { - if (loop != null) - loopTracking.RemoveAt(loopTracking.Count - 1); + if (scope != null) + scopeTracking.RemoveAt(scopeTracking.Count - 1); } } diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/FlattenSwitchBlocks.cs b/ICSharpCode.Decompiler/CSharp/Transforms/FlattenSwitchBlocks.cs index 4eed055f4..68bb7c47f 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/FlattenSwitchBlocks.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/FlattenSwitchBlocks.cs @@ -2,15 +2,15 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using ICSharpCode.NRefactory.CSharp; +using ICSharpCode.Decompiler.CSharp.Syntax; namespace ICSharpCode.Decompiler.CSharp.Transforms { class FlattenSwitchBlocks : IAstTransform { - public void Run(AstNode compilationUnit) + public void Run(AstNode rootNode, TransformContext context) { - foreach (var switchSection in compilationUnit.Descendants.OfType()) + foreach (var switchSection in rootNode.Descendants.OfType()) { if (switchSection.Statements.Count != 1) continue; diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs index 1ff8f83e3..53596faa9 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs @@ -43,15 +43,24 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms { this.context = context; this.usingScope = this.rootUsingScope = rootNode.Annotation(); + currentMember = context.DecompiledMember; + SetContext(); rootNode.AcceptVisitor(this); } void SetContext() { this.usingScope = rootUsingScope; - foreach (var name in currentMember.Namespace.Split('.')) - usingScope = new UsingScope(usingScope, name); - resolveContext = new CSharpTypeResolveContext(currentMember.ParentAssembly, usingScope.Resolve(context.TypeSystem.Compilation), currentMember.DeclaringTypeDefinition, currentMember); + string ns = currentMember?.Namespace ?? context.DecompiledTypeDefinition?.Namespace; + if (ns != null) { + foreach (var name in ns.Split('.')) + usingScope = new UsingScope(usingScope, name); + } + resolveContext = new CSharpTypeResolveContext( + context.DecompiledAssembly, + usingScope.Resolve(context.TypeSystem.Compilation), + currentMember?.DeclaringTypeDefinition ?? context.DecompiledTypeDefinition, + currentMember); resolver = new CSharpResolver(resolveContext); } diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs b/ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs index d0684ee4b..a8e29430e 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs @@ -96,11 +96,6 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms public override AstNode VisitIfElseStatement(IfElseStatement ifElseStatement) { - if (context.Settings.SwitchStatementOnString) { - AstNode result = TransformSwitchOnString(ifElseStatement); - if (result != null) - return result; - } AstNode simplifiedIfElse = SimplifyCascadingIfElseStatements(ifElseStatement); if (simplifiedIfElse != null) return simplifiedIfElse; @@ -256,174 +251,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms return null; } #endregion - - #region switch on strings - static readonly IfElseStatement switchOnStringPattern = new IfElseStatement { - Condition = new BinaryOperatorExpression { - Left = new AnyNode("switchExpr"), - Operator = BinaryOperatorType.InEquality, - Right = new NullReferenceExpression() - }, - TrueStatement = new BlockStatement { - new IfElseStatement { - Condition = new BinaryOperatorExpression { - Left = new AnyNode("cachedDict"), - Operator = BinaryOperatorType.Equality, - Right = new NullReferenceExpression() - }, - TrueStatement = new AnyNode("dictCreation") - }, - new IfElseStatement { - Condition = new InvocationExpression(new MemberReferenceExpression(new Backreference("cachedDict").ToExpression(), "TryGetValue"), - new NamedNode("switchVar", new IdentifierExpression(Pattern.AnyString)), - new DirectionExpression { - FieldDirection = FieldDirection.Out, - Expression = new IdentifierExpression(Pattern.AnyString).WithName("intVar") - }), - TrueStatement = new BlockStatement { - Statements = { - new NamedNode( - "switch", new SwitchStatement { - Expression = new IdentifierExpressionBackreference("intVar"), - SwitchSections = { new Repeat(new AnyNode()) } - }) - } - } - }, - new Repeat(new AnyNode("nonNullDefaultStmt")).ToStatement() - }, - FalseStatement = new OptionalNode("nullStmt", new BlockStatement { Statements = { new Repeat(new AnyNode()) } }) - }; - - public SwitchStatement TransformSwitchOnString(IfElseStatement node) - { - Match m = switchOnStringPattern.Match(node); - if (!m.Success) - return null; - // switchVar must be the same as switchExpr; or switchExpr must be an assignment and switchVar the left side of that assignment - if (!m.Get("switchVar").Single().IsMatch(m.Get("switchExpr").Single())) { - AssignmentExpression assign = m.Get("switchExpr").Single() as AssignmentExpression; - if (!(assign != null && m.Get("switchVar").Single().IsMatch(assign.Left))) - return null; - } - FieldReference cachedDictField = m.Get("cachedDict").Single().Annotation(); - if (cachedDictField == null) - return null; - List dictCreation = m.Get("dictCreation").Single().Statements.ToList(); - List> dict = BuildDictionary(dictCreation); - SwitchStatement sw = m.Get("switch").Single(); - sw.Expression = m.Get("switchExpr").Single().Detach(); - foreach (SwitchSection section in sw.SwitchSections) { - List labels = section.CaseLabels.ToList(); - section.CaseLabels.Clear(); - foreach (CaseLabel label in labels) { - PrimitiveExpression expr = label.Expression as PrimitiveExpression; - if (expr == null || !(expr.Value is int)) - continue; - int val = (int)expr.Value; - foreach (var pair in dict) { - if (pair.Value == val) - section.CaseLabels.Add(new CaseLabel { Expression = new PrimitiveExpression(pair.Key) }); - } - } - } - if (m.Has("nullStmt")) { - SwitchSection section = new SwitchSection(); - section.CaseLabels.Add(new CaseLabel { Expression = new NullReferenceExpression() }); - BlockStatement block = m.Get("nullStmt").Single(); - block.Statements.Add(new BreakStatement()); - section.Statements.Add(block.Detach()); - sw.SwitchSections.Add(section); - } else if (m.Has("nonNullDefaultStmt")) { - sw.SwitchSections.Add( - new SwitchSection { - CaseLabels = { new CaseLabel { Expression = new NullReferenceExpression() } }, - Statements = { new BlockStatement { new BreakStatement() } } - }); - } - if (m.Has("nonNullDefaultStmt")) { - SwitchSection section = new SwitchSection(); - section.CaseLabels.Add(new CaseLabel()); - BlockStatement block = new BlockStatement(); - block.Statements.AddRange(m.Get("nonNullDefaultStmt").Select(s => s.Detach())); - block.Add(new BreakStatement()); - section.Statements.Add(block); - sw.SwitchSections.Add(section); - } - node.ReplaceWith(sw); - return sw; - } - - List> BuildDictionary(List dictCreation) - { - if (context.Settings.ObjectOrCollectionInitializers && dictCreation.Count == 1) - return BuildDictionaryFromInitializer(dictCreation[0]); - return BuildDictionaryFromAddMethodCalls(dictCreation); - } - - static readonly Statement assignInitializedDictionary = new ExpressionStatement { - Expression = new AssignmentExpression { - Left = new AnyNode().ToExpression(), - Right = new ObjectCreateExpression { - Type = new AnyNode(), - Arguments = { new Repeat(new AnyNode()) }, - Initializer = new ArrayInitializerExpression { - Elements = { new Repeat(new AnyNode("dictJumpTable")) } - } - }, - }, - }; - - private List> BuildDictionaryFromInitializer(Statement statement) - { - List> dict = new List>(); - Match m = assignInitializedDictionary.Match(statement); - if (!m.Success) - return dict; - - foreach (ArrayInitializerExpression initializer in m.Get("dictJumpTable")) { - KeyValuePair pair; - if (TryGetPairFrom(initializer.Elements, out pair)) - dict.Add(pair); - } - - return dict; - } - - private static List> BuildDictionaryFromAddMethodCalls(List dictCreation) - { - List> dict = new List>(); - for (int i = 0; i < dictCreation.Count; i++) { - ExpressionStatement es = dictCreation[i] as ExpressionStatement; - if (es == null) - continue; - InvocationExpression ie = es.Expression as InvocationExpression; - if (ie == null) - continue; - - KeyValuePair pair; - if (TryGetPairFrom(ie.Arguments, out pair)) - dict.Add(pair); - } - return dict; - } - - private static bool TryGetPairFrom(AstNodeCollection expressions, out KeyValuePair pair) - { - PrimitiveExpression arg1 = expressions.ElementAtOrDefault(0) as PrimitiveExpression; - PrimitiveExpression arg2 = expressions.ElementAtOrDefault(1) as PrimitiveExpression; - if (arg1 != null && arg2 != null && arg1.Value is string && arg2.Value is int) { - pair = new KeyValuePair((string)arg1.Value, (int)arg2.Value); - return true; - } - - pair = default(KeyValuePair); - return false; - } - - #endregion - #region Automatic Properties static readonly PropertyDeclaration automaticPropertyPattern = new PropertyDeclaration { Attributes = { new Repeat(new AnyNode()) }, diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/ReplaceMethodCallsWithOperators.cs b/ICSharpCode.Decompiler/CSharp/Transforms/ReplaceMethodCallsWithOperators.cs index 96e9a9516..fa7001f30 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/ReplaceMethodCallsWithOperators.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/ReplaceMethodCallsWithOperators.cs @@ -69,7 +69,9 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms case "System.Type.GetTypeFromHandle": if (arguments.Length == 1) { if (typeHandleOnTypeOfPattern.IsMatch(arguments[0])) { - invocationExpression.ReplaceWith(((MemberReferenceExpression)arguments[0]).Target); + Expression target = ((MemberReferenceExpression)arguments[0]).Target; + target.CopyInstructionsFrom(invocationExpression); + invocationExpression.ReplaceWith(target); return; } } diff --git a/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs b/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs index 8d49ce4cd..34075fa46 100644 --- a/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs +++ b/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs @@ -172,10 +172,27 @@ namespace ICSharpCode.Decompiler.CSharp { var type = this.Type; if (type.Equals(targetType)) { - // Remove boxing conversion if possible - if (allowImplicitConversion && type.IsKnownType(KnownTypeCode.Object)) { - if (Expression is CastExpression cast && ResolveResult is ConversionResolveResult conversion && conversion.Conversion.IsBoxingConversion) { - return this.UnwrapChild(cast.Expression); + // Make explicit conversion implicit, if possible + if (allowImplicitConversion) { + switch (ResolveResult) { + case ConversionResolveResult conversion: { + if (Expression is CastExpression cast + && (type.IsKnownType(KnownTypeCode.Object) && conversion.Conversion.IsBoxingConversion + || type.Kind == TypeKind.Delegate && conversion.Conversion.IsAnonymousFunctionConversion + )) { + return this.UnwrapChild(cast.Expression); + } else if (Expression is ObjectCreateExpression oce && conversion.Conversion.IsMethodGroupConversion + && oce.Arguments.Count == 1 && expressionBuilder.settings.UseImplicitMethodGroupConversion) { + return this.UnwrapChild(oce.Arguments.Single()); + } + break; + } + case InvocationResolveResult invocation: { + if (Expression is ObjectCreateExpression oce && oce.Arguments.Count == 1 && invocation.Type.IsKnownType(KnownTypeCode.NullableOfT)) { + return this.UnwrapChild(oce.Arguments.Single()); + } + break; + } } } return this; @@ -296,7 +313,7 @@ namespace ICSharpCode.Decompiler.CSharp } var rr = expressionBuilder.resolver.WithCheckForOverflow(checkForOverflow).ResolveCast(targetType, ResolveResult); if (rr.IsCompileTimeConstant && !rr.IsError) { - return expressionBuilder.ConvertConstantValue(rr) + return expressionBuilder.ConvertConstantValue(rr, allowImplicitConversion) .WithILInstruction(this.ILInstructions); } if (targetType.Kind == TypeKind.Pointer && (0.Equals(ResolveResult.ConstantValue) || 0u.Equals(ResolveResult.ConstantValue))) { diff --git a/ICSharpCode.Decompiler/CSharp/WholeProjectDecompiler.cs b/ICSharpCode.Decompiler/CSharp/WholeProjectDecompiler.cs index 4b36a47db..a36ae5869 100644 --- a/ICSharpCode.Decompiler/CSharp/WholeProjectDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/WholeProjectDecompiler.cs @@ -283,8 +283,8 @@ namespace ICSharpCode.Decompiler.CSharp const string prop = "Properties"; if (directories.Add(prop)) Directory.CreateDirectory(Path.Combine(targetDirectory, prop)); - string assemblyInfo = Path.Combine(targetDirectory, prop, "AssemblyInfo.cs"); - using (StreamWriter w = new StreamWriter(assemblyInfo)) { + string assemblyInfo = Path.Combine(prop, "AssemblyInfo.cs"); + using (StreamWriter w = new StreamWriter(Path.Combine(targetDirectory, assemblyInfo))) { syntaxTree.AcceptVisitor(new CSharpOutputVisitor(w, settings.CSharpFormattingOptions)); } return new Tuple[] { Tuple.Create("Compile", assemblyInfo) }; diff --git a/ICSharpCode.Decompiler/DecompilerSettings.cs b/ICSharpCode.Decompiler/DecompilerSettings.cs index 18deb2e8a..6d6e16d21 100644 --- a/ICSharpCode.Decompiler/DecompilerSettings.cs +++ b/ICSharpCode.Decompiler/DecompilerSettings.cs @@ -228,7 +228,24 @@ namespace ICSharpCode.Decompiler } } } - + + bool useImplicitMethodGroupConversion = true; + + /// + /// Gets/Sets whether to use C# 2.0 method group conversions. + /// true: EventHandler h = this.OnClick; + /// false: EventHandler h = new EventHandler(this.OnClick); + /// + public bool UseImplicitMethodGroupConversion { + get { return useImplicitMethodGroupConversion; } + set { + if (useImplicitMethodGroupConversion != value) { + useImplicitMethodGroupConversion = value; + OnPropertyChanged(); + } + } + } + bool fullyQualifyAmbiguousTypeNames = true; public bool FullyQualifyAmbiguousTypeNames { @@ -343,8 +360,21 @@ namespace ICSharpCode.Decompiler } } } + + bool showDebugInfo; + + public bool ShowDebugInfo { + get { return showDebugInfo; } + set { + if (showDebugInfo != value) { + showDebugInfo = value; + OnPropertyChanged(); + } + } + } + #endregion - + CSharpFormattingOptions csharpFormattingOptions; public CSharpFormattingOptions CSharpFormattingOptions { @@ -365,7 +395,7 @@ namespace ICSharpCode.Decompiler } } } - + public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) diff --git a/ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs b/ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs index be7ed7dd8..ba895ed79 100644 --- a/ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs +++ b/ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs @@ -289,6 +289,19 @@ namespace ICSharpCode.Decompiler.Disassembler writer.Write(" modreq("); ((RequiredModifierType)type).ModifierType.WriteTo(writer, ILNameSyntax.TypeName); writer.Write(") "); + } else if (type is FunctionPointerType fpt) { + writer.Write("method "); + fpt.ReturnType.WriteTo(writer, syntax); + writer.Write(" *("); + bool first = true; + foreach (var p in fpt.Parameters) { + if (first) + first = false; + else + writer.Write(", "); + p.ParameterType.WriteTo(writer, syntax); + } + writer.Write(')'); } else if (type is SentinelType) { writer.Write("..., "); ((SentinelType)type).ElementType.WriteTo(writer, syntax); @@ -343,9 +356,10 @@ namespace ICSharpCode.Decompiler.Disassembler ParameterReference paramRef = operand as ParameterReference; if (paramRef != null) { - if (string.IsNullOrEmpty(paramRef.Name)) - writer.WriteReference(paramRef.Index.ToString(), paramRef); - else + if (string.IsNullOrEmpty(paramRef.Name)) { + var paramDef = paramRef.Resolve(); + writer.WriteReference((paramDef == null ? paramRef.Index : paramDef.Sequence).ToString(), paramRef); + } else writer.WriteReference(Escape(paramRef.Name), paramRef); return; } diff --git a/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs b/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs index a3f85c9a4..24a1fb3b8 100644 --- a/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs +++ b/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs @@ -21,28 +21,38 @@ using System.Collections.Generic; using System.Threading; using Mono.Cecil; using Mono.Cecil.Cil; +using Mono.Collections.Generic; namespace ICSharpCode.Decompiler.Disassembler { /// /// Disassembles a method body. /// - public sealed class MethodBodyDisassembler + public class MethodBodyDisassembler { readonly ITextOutput output; - readonly bool detectControlStructure; readonly CancellationToken cancellationToken; - public MethodBodyDisassembler(ITextOutput output, bool detectControlStructure, CancellationToken cancellationToken) + /// + /// Show .try/finally as blocks in IL code; indent loops. + /// + public bool DetectControlStructure { get; set; } = true; + + /// + /// Show sequence points if debug information is loaded in Cecil. + /// + public bool ShowSequencePoints { get; set; } + + Collection sequencePoints; + int nextSequencePointIndex; + + public MethodBodyDisassembler(ITextOutput output, CancellationToken cancellationToken) { - if (output == null) - throw new ArgumentNullException(nameof(output)); - this.output = output; - this.detectControlStructure = detectControlStructure; + this.output = output ?? throw new ArgumentNullException(nameof(output)); this.cancellationToken = cancellationToken; } - public void Disassemble(MethodBody body/*, MemberMapping methodMapping*/) + public virtual void Disassemble(MethodBody body) { // start writing IL code MethodDefinition method = body.Method; @@ -55,30 +65,20 @@ namespace ICSharpCode.Decompiler.Disassembler DisassembleLocalsBlock(body); output.WriteLine(); - if (detectControlStructure && body.Instructions.Count > 0) { + sequencePoints = method.DebugInformation?.SequencePoints; + nextSequencePointIndex = 0; + if (DetectControlStructure && body.Instructions.Count > 0) { Instruction inst = body.Instructions[0]; HashSet branchTargets = GetBranchTargets(body.Instructions); WriteStructureBody(new ILStructure(body), branchTargets, ref inst, method.Body.CodeSize); } else { foreach (var inst in method.Body.Instructions) { - //var startLocation = output.Location; - inst.WriteTo(output); - - /* - if (debugSymbols != null) { - // add IL code mappings - used in debugger - debugSymbols.SequencePoints.Add( - new SequencePoint() { - StartLocation = output.Location, - EndLocation = output.Location, - ILRanges = new ILRange[] { new ILRange(inst.Offset, inst.Next == null ? method.Body.CodeSize : inst.Next.Offset) } - }); - }*/ - + WriteInstruction(output, inst); output.WriteLine(); } WriteExceptionHandlers(body); } + sequencePoints = null; } private void DisassembleLocalsBlock(MethodBody body) @@ -191,19 +191,7 @@ namespace ICSharpCode.Decompiler.Disassembler if (!isFirstInstructionInStructure && (prevInstructionWasBranch || branchTargets.Contains(offset))) { output.WriteLine(); // put an empty line after branches, and in front of branch targets } - //var startLocation = output.Location; - inst.WriteTo(output); - - /*// add IL code mappings - used in debugger - if (debugSymbols != null) { - debugSymbols.SequencePoints.Add( - new SequencePoint() { - StartLocation = startLocation, - EndLocation = output.Location, - ILRanges = new ILRange[] { new ILRange(inst.Offset, inst.Next == null ? codeSize : inst.Next.Offset) } - }); - }*/ - + WriteInstruction(output, inst); output.WriteLine(); prevInstructionWasBranch = inst.OpCode.FlowControl == FlowControl.Branch @@ -237,5 +225,25 @@ namespace ICSharpCode.Decompiler.Disassembler throw new NotSupportedException(); } } + + protected virtual void WriteInstruction(ITextOutput output, Instruction instruction) + { + if (ShowSequencePoints && nextSequencePointIndex < sequencePoints?.Count) { + SequencePoint sp = sequencePoints[nextSequencePointIndex]; + if (sp.Offset <= instruction.Offset) { + output.Write("// sequence point: "); + if (sp.Offset != instruction.Offset) { + output.Write("!! at " + DisassemblerHelpers.OffsetToString(sp.Offset) + " !!"); + } + if (sp.IsHidden) { + output.WriteLine("hidden"); + } else { + output.WriteLine($"(line {sp.StartLine}, col {sp.StartColumn}) to (line {sp.EndLine}, col {sp.EndColumn}) in {sp.Document?.Url}"); + } + nextSequencePointIndex++; + } + } + instruction.WriteTo(output); + } } } diff --git a/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs b/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs index 7707f7791..851c47842 100644 --- a/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs +++ b/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs @@ -35,13 +35,28 @@ namespace ICSharpCode.Decompiler.Disassembler MethodBodyDisassembler methodBodyDisassembler; MemberReference currentMember; - public ReflectionDisassembler(ITextOutput output, bool detectControlStructure, CancellationToken cancellationToken) + public bool DetectControlStructure { + get => methodBodyDisassembler.DetectControlStructure; + set => methodBodyDisassembler.DetectControlStructure = value; + } + + public bool ShowSequencePoints { + get => methodBodyDisassembler.ShowSequencePoints; + set => methodBodyDisassembler.ShowSequencePoints = value; + } + + public ReflectionDisassembler(ITextOutput output, CancellationToken cancellationToken) + : this(output, new MethodBodyDisassembler(output, cancellationToken), cancellationToken) + { + } + + public ReflectionDisassembler(ITextOutput output, MethodBodyDisassembler methodBodyDisassembler, CancellationToken cancellationToken) { if (output == null) throw new ArgumentNullException(nameof(output)); this.output = output; this.cancellationToken = cancellationToken; - this.methodBodyDisassembler = new MethodBodyDisassembler(output, detectControlStructure, cancellationToken); + this.methodBodyDisassembler = methodBodyDisassembler; } #region Disassemble Method diff --git a/ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinder.cs b/ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinder.cs index 5d4478c34..01c54137d 100644 --- a/ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinder.cs +++ b/ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinder.cs @@ -52,7 +52,7 @@ namespace ICSharpCode.Decompiler var depsJsonFileName = Path.Combine(basePath, $"{assemblyName}.deps.json"); if (!File.Exists(depsJsonFileName)) { - loadInfo.AddMessage(assemblyName, MessageKind.Error, $"{assemblyName}.deps.json could not be found!"); + loadInfo.AddMessage(assemblyName, MessageKind.Warning, $"{assemblyName}.deps.json could not be found!"); return; } diff --git a/ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinderExtensions.cs b/ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinderExtensions.cs index ced78ebf2..0fe9b4d63 100644 --- a/ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinderExtensions.cs +++ b/ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinderExtensions.cs @@ -8,7 +8,6 @@ using Newtonsoft.Json.Linq; namespace ICSharpCode.Decompiler { - public static class DotNetCorePathFinderExtensions { public static string DetectTargetFrameworkId(this AssemblyDefinition assembly) diff --git a/ICSharpCode.Decompiler/FlowAnalysis/ControlFlowNode.cs b/ICSharpCode.Decompiler/FlowAnalysis/ControlFlowNode.cs index f9aaabb30..f0a72bf20 100644 --- a/ICSharpCode.Decompiler/FlowAnalysis/ControlFlowNode.cs +++ b/ICSharpCode.Decompiler/FlowAnalysis/ControlFlowNode.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using ICSharpCode.Decompiler.Util; namespace ICSharpCode.Decompiler.FlowAnalysis { @@ -118,35 +119,37 @@ namespace ICSharpCode.Decompiler.FlowAnalysis } return false; } - - //public static GraphVizGraph ExportGraph(IReadOnlyList nodes, Func labelFunc = null) - //{ - // if (labelFunc == null) { - // labelFunc = node => { - // var block = node.UserData as IL.Block; - // return block != null ? block.Label : node.UserData?.ToString(); - // }; - // } - // GraphVizGraph g = new GraphVizGraph(); - // GraphVizNode[] n = new GraphVizNode[nodes.Count]; - // for (int i = 0; i < n.Length; i++) { - // n[i] = new GraphVizNode(nodes[i].UserIndex); - // n[i].shape = "box"; - // n[i].label = labelFunc(nodes[i]); - // g.AddNode(n[i]); - // } - // foreach (var source in nodes) { - // foreach (var target in source.Successors) { - // g.AddEdge(new GraphVizEdge(source.UserIndex, target.UserIndex)); - // } - // if (source.ImmediateDominator != null) { - // g.AddEdge( - // new GraphVizEdge(source.ImmediateDominator.UserIndex, source.UserIndex) { - // color = "green" - // }); - // } - // } - // return g; - //} + +#if DEBUG + internal static GraphVizGraph ExportGraph(IReadOnlyList nodes, Func labelFunc = null) + { + if (labelFunc == null) { + labelFunc = node => { + var block = node.UserData as IL.Block; + return block != null ? block.Label : node.UserData?.ToString(); + }; + } + GraphVizGraph g = new GraphVizGraph(); + GraphVizNode[] n = new GraphVizNode[nodes.Count]; + for (int i = 0; i < n.Length; i++) { + n[i] = new GraphVizNode(nodes[i].UserIndex); + n[i].shape = "box"; + n[i].label = labelFunc(nodes[i]); + g.AddNode(n[i]); + } + foreach (var source in nodes) { + foreach (var target in source.Successors) { + g.AddEdge(new GraphVizEdge(source.UserIndex, target.UserIndex)); + } + if (source.ImmediateDominator != null) { + g.AddEdge( + new GraphVizEdge(source.ImmediateDominator.UserIndex, source.UserIndex) { + color = "green" + }); + } + } + return g; + } +#endif } } diff --git a/ICSharpCode.Decompiler/FlowAnalysis/DataFlowVisitor.cs b/ICSharpCode.Decompiler/FlowAnalysis/DataFlowVisitor.cs index 2ac18d313..034e33798 100644 --- a/ICSharpCode.Decompiler/FlowAnalysis/DataFlowVisitor.cs +++ b/ICSharpCode.Decompiler/FlowAnalysis/DataFlowVisitor.cs @@ -614,17 +614,17 @@ namespace ICSharpCode.Decompiler.FlowAnalysis DebugStartPoint(inst); inst.Value.AcceptVisitor(this); State beforeSections = state.Clone(); - inst.DefaultBody.AcceptVisitor(this); + inst.Sections[0].AcceptVisitor(this); State afterSections = state.Clone(); - foreach (var section in inst.Sections) { + for (int i = 1; i < inst.Sections.Count; ++i) { state.ReplaceWith(beforeSections); - section.AcceptVisitor(this); + inst.Sections[i].AcceptVisitor(this); afterSections.JoinWith(state); } state = afterSections; DebugEndPoint(inst); } - + protected internal override void VisitYieldReturn(YieldReturn inst) { DebugStartPoint(inst); diff --git a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj index b9320c5b4..1e02da7aa 100644 --- a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj +++ b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj @@ -24,21 +24,23 @@ true - true + true ICSharpCode.Decompiler.nuspec Configuration=$(Configuration) - full + portable true + true True $(DefineConstants);STEP - pdbonly + portable true + true @@ -60,6 +62,7 @@ + @@ -224,6 +227,7 @@ + @@ -272,7 +276,17 @@ + + + + + + + + + + @@ -294,6 +308,7 @@ + @@ -575,4 +590,11 @@ + + + + + + + \ No newline at end of file diff --git a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.nuspec b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.nuspec.template similarity index 71% rename from ICSharpCode.Decompiler/ICSharpCode.Decompiler.nuspec rename to ICSharpCode.Decompiler/ICSharpCode.Decompiler.nuspec.template index 93cd2f8fb..030ad559d 100644 --- a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.nuspec +++ b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.nuspec.template @@ -2,7 +2,7 @@ ICSharpCode.Decompiler - 3.0.0-alpha3 + $INSERTVERSION$$INSERTVERSIONNAMEPOSTFIX$ ILSpy Decompiler Engine Daniel Grunwald, David Srbecky, Ed Harvey, Siegfried Pammer Daniel Grunwald, SharpDevelop @@ -12,12 +12,13 @@ false ICSharpCode.Decompiler is the decompiler engine used in ILSpy. - Copyright 2011-2017 AlphaSierraPapa + Copyright 2011-$INSERTYEAR$ AlphaSierraPapa C# Decompiler ILSpy - - - + + + + @@ -30,9 +31,5 @@ - - - - \ No newline at end of file diff --git a/ICSharpCode.Decompiler/IL/BlockBuilder.cs b/ICSharpCode.Decompiler/IL/BlockBuilder.cs index 2ba957cb4..63d02a971 100644 --- a/ICSharpCode.Decompiler/IL/BlockBuilder.cs +++ b/ICSharpCode.Decompiler/IL/BlockBuilder.cs @@ -163,8 +163,15 @@ namespace ICSharpCode.Decompiler.IL if (currentBlock == null) return; currentBlock.ILRange = new Interval(currentBlock.ILRange.Start, currentILOffset); - if (fallthrough) - currentBlock.Instructions.Add(new Branch(currentILOffset)); + if (fallthrough) { + if (currentBlock.Instructions.LastOrDefault() is SwitchInstruction switchInst && switchInst.Sections.Last().Body.MatchNop()) { + // Instead of putting the default branch after the switch instruction + switchInst.Sections.Last().Body = new Branch(currentILOffset); + Debug.Assert(switchInst.HasFlag(InstructionFlags.EndPointUnreachable)); + } else { + currentBlock.Instructions.Add(new Branch(currentILOffset)); + } + } currentBlock = null; } @@ -175,6 +182,12 @@ namespace ICSharpCode.Decompiler.IL cancellationToken.ThrowIfCancellationRequested(); Debug.Assert(branch.TargetBlock == null); branch.TargetBlock = FindBranchTarget(branch.TargetILOffset); + if (branch.TargetBlock == null) { + branch.ReplaceWith(new InvalidBranch("Could not find block for branch target " + + Disassembler.DisassemblerHelpers.OffsetToString(branch.TargetILOffset)) { + ILRange = branch.ILRange + }); + } break; case Leave leave: // ret (in void method) = leave(mainContainer) @@ -210,7 +223,7 @@ namespace ICSharpCode.Decompiler.IL return block; } } - throw new InvalidOperationException("Could not find block for branch target"); + return null; } } } diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs b/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs index bc3a92038..bf83b4334 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs @@ -169,7 +169,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow return false; if (startCall.Method.Name != "Start") return false; - taskType = context.TypeSystem.Resolve(function.Method.ReturnType); + taskType = function.Method.ReturnType; builderType = startCall.Method.DeclaringTypeDefinition; const string ns = "System.Runtime.CompilerServices"; if (taskType.IsKnownType(KnownTypeCode.Void)) { @@ -774,17 +774,26 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow return false; if (!target.MatchLdThis()) return false; - if (field.MemberDefinition != awaiterField) + if (!field.Equals(awaiterField)) return false; pos++; // stfld awaiterField(ldloc this, default.value) if (block.Instructions[pos].MatchStFld(out target, out field, out value) && target.MatchLdThis() - && field.MemberDefinition == awaiterField + && field.Equals(awaiterField) && value.OpCode == OpCode.DefaultValue) { pos++; + } else { + // {stloc V_6(default.value System.Runtime.CompilerServices.TaskAwaiter)} + // {stobj System.Runtime.CompilerServices.TaskAwaiter`1[[System.Int32]](ldflda <>u__$awaiter4(ldloc this), ldloc V_6) at IL_0163} + if (block.Instructions[pos].MatchStLoc(out var variable, out value) && value.OpCode == OpCode.DefaultValue + && block.Instructions[pos + 1].MatchStFld(out target, out field, out value) + && field.Equals(awaiterField) + && value.MatchLdLoc(variable)) { + pos += 2; + } } // stloc S_28(ldc.i4 -1) @@ -804,7 +813,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow if (block.Instructions[pos].MatchStFld(out target, out field, out value)) { if (!target.MatchLdThis()) return false; - if (field.MemberDefinition != stateField) + if (!field.MemberDefinition.Equals(stateField.MemberDefinition)) return false; if (!(value.MatchLdcI4(initialState) || value.MatchLdLoc(m1Var))) return false; diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/ConditionDetection.cs b/ICSharpCode.Decompiler/IL/ControlFlow/ConditionDetection.cs index d93a5b58a..97f763426 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/ConditionDetection.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/ConditionDetection.cs @@ -63,18 +63,14 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow // Last instruction is one with unreachable endpoint // (guaranteed by combination of BlockContainer and Block invariants) Debug.Assert(block.Instructions.Last().HasFlag(InstructionFlags.EndPointUnreachable)); - ILInstruction exitInst = block.Instructions.Last(); + ILInstruction exitInst = block.Instructions.Last(); + // Previous-to-last instruction might have conditional control flow, // usually an IfInstruction with a branch: IfInstruction ifInst = block.Instructions.SecondToLastOrDefault() as IfInstruction; if (ifInst != null && ifInst.FalseInst.OpCode == OpCode.Nop) { HandleIfInstruction(cfgNode, block, ifInst, ref exitInst); - } else { - SwitchInstruction switchInst = block.Instructions.SecondToLastOrDefault() as SwitchInstruction; - if (switchInst != null) { - HandleSwitchInstruction(cfgNode, block, switchInst, ref exitInst); - } } if (IsUsableBranchToChild(cfgNode, exitInst)) { // "...; goto usableblock;" @@ -297,48 +293,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow && targetBlock.IncomingEdgeCount == 1 && targetBlock.FinalInstruction.OpCode == OpCode.Nop && cfgNode.Dominates(context.ControlFlowGraph.GetNode(targetBlock)); } - - private void HandleSwitchInstruction(ControlFlowNode cfgNode, Block block, SwitchInstruction sw, ref ILInstruction exitInst) - { - Debug.Assert(sw.DefaultBody is Nop); - // First, move blocks into the switch section - foreach (var section in sw.Sections) { - if (IsUsableBranchToChild(cfgNode, section.Body)) { - // case ...: goto targetBlock; - var targetBlock = ((Branch)section.Body).TargetBlock; - targetBlock.Remove(); - section.Body = targetBlock; - } - } - // Move the code following the switch into the default section - if (IsUsableBranchToChild(cfgNode, exitInst)) { - // switch(...){} goto targetBlock; - // ---> switch(..) { default: { targetBlock } } - var targetBlock = ((Branch)exitInst).TargetBlock; - targetBlock.Remove(); - sw.DefaultBody = targetBlock; - if (IsBranchOrLeave(targetBlock.Instructions.Last())) { - exitInst = block.Instructions[block.Instructions.Count - 1] = targetBlock.Instructions.Last(); - targetBlock.Instructions.RemoveAt(targetBlock.Instructions.Count - 1); - } else { - exitInst = null; - block.Instructions.RemoveAt(block.Instructions.Count - 1); - } - } - // Remove compatible exitInsts from switch sections: - foreach (var section in sw.Sections) { - Block sectionBlock = section.Body as Block; - if (sectionBlock != null && exitInst == null && IsBranchOrLeave(sectionBlock.Instructions.Last())) { - exitInst = sectionBlock.Instructions.Last(); - sectionBlock.Instructions.RemoveAt(sectionBlock.Instructions.Count - 1); - block.Instructions.Add(exitInst); - } else if (sectionBlock != null && DetectExitPoints.CompatibleExitInstruction(exitInst, sectionBlock.Instructions.Last())) { - sectionBlock.Instructions.RemoveAt(sectionBlock.Instructions.Count - 1); - } - } - sw.Sections.ReplaceList(sw.Sections.OrderBy(s => s.Body.ILRange.Start)); - } - + private bool IsBranchOrLeave(ILInstruction inst) { switch (inst) { diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs b/ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs index 695af22a4..6e336377e 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs @@ -19,6 +19,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using ICSharpCode.Decompiler.IL.Transforms; +using ICSharpCode.Decompiler.TypeSystem; namespace ICSharpCode.Decompiler.IL.ControlFlow { @@ -43,18 +44,30 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow foreach (var block in function.Descendants.OfType()) { context.CancellationToken.ThrowIfCancellationRequested(); - // Remove 'nop' instructions - block.Instructions.RemoveAll(inst => inst.OpCode == OpCode.Nop); - + RemoveNopInstructions(block); + InlineVariableInReturnBlock(block, context); // 1st pass SimplifySwitchInstruction before SimplifyBranchChains() // starts duplicating return instructions. SwitchDetection.SimplifySwitchInstruction(block); } SimplifyBranchChains(function, context); - CleanUpEmptyBlocks(function); + CleanUpEmptyBlocks(function, context); } - + + private static void RemoveNopInstructions(Block block) + { + // Move ILRanges of special nop instructions to the previous non-nop instruction. + for (int i = block.Instructions.Count - 1; i > 0; i--) { + if (block.Instructions[i] is Nop nop && nop.Kind == NopKind.Pop) { + block.Instructions[i - 1].AddILRange(nop.ILRange); + } + } + + // Remove 'nop' instructions + block.Instructions.RemoveAll(inst => inst.OpCode == OpCode.Nop); + } + void InlineVariableInReturnBlock(Block block, ILTransformContext context) { // In debug mode, the C#-compiler generates 'return blocks' that @@ -129,13 +142,13 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow } } - void CleanUpEmptyBlocks(ILFunction function) + void CleanUpEmptyBlocks(ILFunction function, ILTransformContext context) { foreach (var container in function.Descendants.OfType()) { foreach (var block in container.Blocks) { if (block.Instructions.Count == 0) continue; // block is already marked for deletion - while (CombineBlockWithNextBlock(container, block)) { + while (CombineBlockWithNextBlock(container, block, context)) { // repeat combining blocks until it is no longer possible // (this loop terminates because a block is deleted in every iteration) } @@ -153,7 +166,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow return targetBlock.Instructions[0].MatchReturn(out var value) && value is LdLoc; } - static bool CombineBlockWithNextBlock(BlockContainer container, Block block) + static bool CombineBlockWithNextBlock(BlockContainer container, Block block, ILTransformContext context) { Debug.Assert(container == block.Parent); // Ensure the block will stay a basic block -- we don't want extended basic blocks prior to LoopDetection. @@ -165,12 +178,31 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow return false; if (br.TargetBlock == block) return false; // don't inline block into itself + context.Step("CombineBlockWithNextBlock", br); var targetBlock = br.TargetBlock; + if (targetBlock.ILRange.Start < block.ILRange.Start && IsDeadTrueStore(block)) { + // The C# compiler generates a dead store for the condition of while (true) loops. + block.Instructions.RemoveRange(block.Instructions.Count - 3, 2); + } block.Instructions.Remove(br); block.Instructions.AddRange(targetBlock.Instructions); targetBlock.Instructions.Clear(); // mark targetBlock for deletion return true; } - + + /// + /// Returns true if the last two instructions before the branch are storing the value 'true' into an unused variable. + /// + private static bool IsDeadTrueStore(Block block) + { + if (block.Instructions.Count < 3) return false; + if (!(block.Instructions.SecondToLastOrDefault() is StLoc deadStore && block.Instructions[block.Instructions.Count - 3] is StLoc tempStore)) + return false; + if (!(deadStore.Variable.LoadCount == 0 && deadStore.Variable.AddressCount == 0)) + return false; + if (!(deadStore.Value.MatchLdLoc(tempStore.Variable) && tempStore.Variable.IsSingleDefinition && tempStore.Variable.LoadCount == 1)) + return false; + return tempStore.Value.MatchLdcI4(1) && deadStore.Variable.Type.IsKnownType(KnownTypeCode.Boolean); + } } } diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs b/ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs index b8086bee0..ce3d0f43d 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs @@ -16,6 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -57,6 +58,11 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow // Because this is a post-order block transform, we can assume that // any nested loops within this loop have already been constructed. + if (block.Instructions.Last() is SwitchInstruction switchInst) { + // Switch instructions support "break;" just like loops + DetectSwitchBody(block, switchInst); + } + ControlFlowNode h = context.ControlFlowNode; // CFG node for our potential loop head Debug.Assert(h.UserData == block); Debug.Assert(!TreeTraversal.PreOrder(h, n => n.DominatorTreeChildren).Any(n => n.Visited)); @@ -101,7 +107,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow ConstructLoop(loop, exitPoint); } } - + /// /// Recurse into the dominator tree and find back edges/natural loops. /// @@ -202,9 +208,9 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow /// /// Precondition: Requires that a node is marked as visited iff it is contained in the loop. /// - void ExtendLoop(ControlFlowNode loopHead, List loop, out ControlFlowNode exitPoint) + void ExtendLoop(ControlFlowNode loopHead, List loop, out ControlFlowNode exitPoint, bool isSwitch=false) { - exitPoint = FindExitPoint(loopHead, loop); + exitPoint = FindExitPoint(loopHead, loop, isSwitch); Debug.Assert(!loop.Contains(exitPoint), "Cannot pick an exit point that is part of the natural loop"); if (exitPoint != null) { // Either we are in case 1 and just picked an exit that maximizes the amount of code @@ -227,9 +233,15 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow /// Finds a suitable single exit point for the specified loop. /// /// This method must not write to the Visited flags on the CFG. - ControlFlowNode FindExitPoint(ControlFlowNode loopHead, IReadOnlyList naturalLoop) + ControlFlowNode FindExitPoint(ControlFlowNode loopHead, IReadOnlyList naturalLoop, bool treatBackEdgesAsExits) { - if (!context.ControlFlowGraph.HasReachableExit(loopHead)) { + bool hasReachableExit = context.ControlFlowGraph.HasReachableExit(loopHead); + if (!hasReachableExit && treatBackEdgesAsExits) { + // If we're analyzing the switch, there's no reachable exit, but the loopHead (=switchHead) block + // is also a loop head, we consider the back-edge a reachable exit for the switch. + hasReachableExit = loopHead.Predecessors.Any(p => loopHead.Dominates(p)); + } + if (!hasReachableExit) { // Case 1: // There are no nodes n so that loopHead dominates a predecessor of n but not n itself // -> we could build a loop with zero exit points. @@ -244,7 +256,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow // We need to pick our exit point so that all paths from the loop head // to the reachable exits run through that exit point. var cfg = context.ControlFlowGraph.cfg; - var revCfg = PrepareReverseCFG(loopHead); + var revCfg = PrepareReverseCFG(loopHead, treatBackEdgesAsExits); //ControlFlowNode.ExportGraph(cfg).Show("cfg"); //ControlFlowNode.ExportGraph(revCfg).Show("rev"); ControlFlowNode commonAncestor = revCfg[loopHead.UserIndex]; @@ -255,22 +267,63 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow commonAncestor = Dominance.FindCommonDominator(commonAncestor, revNode); } } + // All paths from within the loop to a reachable exit run through 'commonAncestor'. + // However, this doesn't mean that 'commonAncestor' is valid as an exit point. + // We walk up the post-dominator tree until we've got a valid exit point: ControlFlowNode exitPoint; while (commonAncestor.UserIndex >= 0) { exitPoint = cfg[commonAncestor.UserIndex]; Debug.Assert(exitPoint.Visited == naturalLoop.Contains(exitPoint)); - if (exitPoint.Visited) { - commonAncestor = commonAncestor.ImmediateDominator; - continue; - } else { + // It's possible that 'commonAncestor' is itself part of the natural loop. + // If so, it's not a valid exit point. + if (!exitPoint.Visited && ValidateExitPoint(loopHead, exitPoint)) { + // we found an exit point return exitPoint; } + commonAncestor = commonAncestor.ImmediateDominator; } - // least common dominator is the artificial exit node + // least common post-dominator is the artificial exit node return null; } } + /// + /// Validates an exit point. + /// + /// An exit point is invalid iff there is a node reachable from the exit point that + /// is dominated by the loop head, but not by the exit point. + /// (i.e. this method returns false iff the exit point's dominance frontier contains + /// a node dominated by the loop head. but we implement this the slow way because + /// we don't have dominance frontiers precomputed) + /// + /// + /// We need this because it's possible that there's a return block (thus reverse-unreachable node ignored by post-dominance) + /// that is reachable both directly from the loop, and from the exit point. + /// + bool ValidateExitPoint(ControlFlowNode loopHead, ControlFlowNode exitPoint) + { + var cfg = context.ControlFlowGraph; + return IsValid(exitPoint); + + bool IsValid(ControlFlowNode node) + { + if (!cfg.HasReachableExit(node)) { + // Optimization: if the dominance frontier is empty, we don't need + // to check every node. + return true; + } + foreach (var succ in node.Successors) { + if (loopHead != succ && loopHead.Dominates(succ) && !exitPoint.Dominates(succ)) + return false; + } + foreach (var child in node.DominatorTreeChildren) { + if (!IsValid(child)) + return false; + } + return true; + } + } + /// /// Pick exit point by picking any node that has no reachable exits. /// @@ -308,7 +361,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow } } - ControlFlowNode[] PrepareReverseCFG(ControlFlowNode loopHead) + ControlFlowNode[] PrepareReverseCFG(ControlFlowNode loopHead, bool treatBackEdgesAsExits) { ControlFlowNode[] cfg = context.ControlFlowGraph.cfg; ControlFlowNode[] rev = new ControlFlowNode[cfg.Length + 1]; @@ -322,7 +375,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow continue; // Add reverse edges for all edges in cfg foreach (var succ in cfg[i].Successors) { - if (loopHead.Dominates(succ)) { + if (loopHead.Dominates(succ) && (!treatBackEdgesAsExits || loopHead != succ)) { rev[succ.UserIndex].AddEdgeTo(rev[i]); } else { exitNode.AddEdgeTo(rev[i]); @@ -412,13 +465,25 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow // Move contents of oldEntryPoint to newEntryPoint // (we can't move the block itself because it might be the target of branch instructions outside the loop) newEntryPoint.Instructions.ReplaceList(oldEntryPoint.Instructions); - newEntryPoint.FinalInstruction = oldEntryPoint.FinalInstruction; newEntryPoint.ILRange = oldEntryPoint.ILRange; oldEntryPoint.Instructions.ReplaceList(new[] { loopContainer }); if (exitTargetBlock != null) oldEntryPoint.Instructions.Add(new Branch(exitTargetBlock)); - oldEntryPoint.FinalInstruction = new Nop(); - + + MoveBlocksIntoContainer(loop, loopContainer); + + // Rewrite branches within the loop from oldEntryPoint to newEntryPoint: + foreach (var branch in loopContainer.Descendants.OfType()) { + if (branch.TargetBlock == oldEntryPoint) { + branch.TargetBlock = newEntryPoint; + } else if (branch.TargetBlock == exitTargetBlock) { + branch.ReplaceWith(new Leave(loopContainer) { ILRange = branch.ILRange }); + } + } + } + + private void MoveBlocksIntoContainer(List loop, BlockContainer loopContainer) + { // Move other blocks into the loop body: they're all dominated by the loop header, // and thus cannot be the target of branch instructions outside the loop. for (int i = 1; i < loop.Count; i++) { @@ -440,12 +505,56 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow Block block = (Block)loop[i].UserData; Debug.Assert(block.IsDescendantOf(loopContainer)); } + } + + private void DetectSwitchBody(Block block, SwitchInstruction switchInst) + { + Debug.Assert(block.Instructions.Last() == switchInst); + ControlFlowNode h = context.ControlFlowNode; // CFG node for our switch head + Debug.Assert(h.UserData == block); + Debug.Assert(!TreeTraversal.PreOrder(h, n => n.DominatorTreeChildren).Any(n => n.Visited)); + + var nodesInSwitch = new List(); + nodesInSwitch.Add(h); + h.Visited = true; + ExtendLoop(h, nodesInSwitch, out var exitPoint, isSwitch: true); + if (exitPoint != null && exitPoint.Predecessors.Count == 1 && !context.ControlFlowGraph.HasReachableExit(exitPoint)) { + // If the exit point is reachable from just one single "break;", + // it's better to move the code into the switch. + // (unlike loops which should not be nested unless necessary, + // nesting switches makes it clearer in which cases a piece of code is reachable) + nodesInSwitch.AddRange(TreeTraversal.PreOrder(exitPoint, p => p.DominatorTreeChildren)); + exitPoint = null; + } + + context.Step("Create BlockContainer for switch", switchInst); + // Sort blocks in the loop in reverse post-order to make the output look a bit nicer. + // (if the loop doesn't contain nested loops, this is a topological sort) + nodesInSwitch.Sort((a, b) => b.PostOrderNumber.CompareTo(a.PostOrderNumber)); + Debug.Assert(nodesInSwitch[0] == h); + foreach (var node in nodesInSwitch) { + node.Visited = false; // reset visited flag so that we can find outer loops + Debug.Assert(h.Dominates(node) || !node.IsReachable, "The switch body must be dominated by the switch head"); + } + + BlockContainer switchContainer = new BlockContainer(); + Block newEntryPoint = new Block(); + newEntryPoint.ILRange = switchInst.ILRange; + switchContainer.Blocks.Add(newEntryPoint); + newEntryPoint.Instructions.Add(switchInst); + block.Instructions[block.Instructions.Count - 1] = switchContainer; + + Block exitTargetBlock = (Block)exitPoint?.UserData; + if (exitTargetBlock != null) { + block.Instructions.Add(new Branch(exitTargetBlock)); + } + + MoveBlocksIntoContainer(nodesInSwitch, switchContainer); + // Rewrite branches within the loop from oldEntryPoint to newEntryPoint: - foreach (var branch in loopContainer.Descendants.OfType()) { - if (branch.TargetBlock == oldEntryPoint) { - branch.TargetBlock = newEntryPoint; - } else if (branch.TargetBlock == exitTargetBlock) { - branch.ReplaceWith(new Leave(loopContainer) { ILRange = branch.ILRange }); + foreach (var branch in switchContainer.Descendants.OfType()) { + if (branch.TargetBlock == exitTargetBlock) { + branch.ReplaceWith(new Leave(switchContainer) { ILRange = branch.ILRange }); } } } diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/StateRangeAnalysis.cs b/ICSharpCode.Decompiler/IL/ControlFlow/StateRangeAnalysis.cs index fa4fa097c..9ef815526 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/StateRangeAnalysis.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/StateRangeAnalysis.cs @@ -140,7 +140,6 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow SymbolicValue val = evalContext.Eval(switchInst.Value); if (val.Type != SymbolicValueType.State) goto default; - List allSectionLabels = new List(); List exitIntervals = new List(); foreach (var section in switchInst.Sections) { // switch (state + Constant) @@ -148,12 +147,9 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow // iff (state + Constant == value) // iff (state == value - Constant) var effectiveLabels = section.Labels.AddOffset(unchecked(-val.Constant)); - allSectionLabels.AddRange(effectiveLabels.Intervals); var result = AssignStateRanges(section.Body, stateRange.IntersectWith(effectiveLabels)); exitIntervals.AddRange(result.Intervals); } - var defaultSectionLabels = stateRange.ExceptWith(new LongSet(allSectionLabels)); - exitIntervals.AddRange(AssignStateRanges(switchInst.DefaultBody, defaultSectionLabels).Intervals); // exitIntervals = union of exits of all sections return new LongSet(exitIntervals); case IfInstruction ifInst: diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/SwitchAnalysis.cs b/ICSharpCode.Decompiler/IL/ControlFlow/SwitchAnalysis.cs index 928b934c6..20767b136 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/SwitchAnalysis.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/SwitchAnalysis.cs @@ -42,8 +42,18 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow /// public readonly List> Sections = new List>(); + /// + /// Used to de-duplicate sections with a branch instruction. + /// Invariant: (Sections[targetBlockToSectionIndex[branch.TargetBlock]].Instruction as Branch).TargetBlock == branch.TargetBlock + /// readonly Dictionary targetBlockToSectionIndex = new Dictionary(); + /// + /// Used to de-duplicate sections with a value-less leave instruction. + /// Invariant: (Sections[targetBlockToSectionIndex[leave.TargetContainer]].Instruction as Leave).TargetContainer == leave.TargetContainer + /// + readonly Dictionary targetContainerToSectionIndex = new Dictionary(); + /// /// Blocks that can be deleted if the tail of the initial block is replaced with a switch instruction. /// @@ -61,6 +71,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow switchVar = null; rootBlock = block; targetBlockToSectionIndex.Clear(); + targetContainerToSectionIndex.Clear(); Sections.Clear(); InnerBlocks.Clear(); ContainsILSwitch = false; @@ -83,25 +94,26 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow /// If false, analyze the whole block. bool AnalyzeBlock(Block block, LongSet inputValues, bool tailOnly = false) { + if (block.Instructions.Count == 0) { + // might happen if the block was already marked for deletion in SwitchDetection + return false; + } if (tailOnly) { Debug.Assert(block == rootBlock); - if (block.Instructions.Count < 2) - return false; } else { Debug.Assert(switchVar != null); // switchVar should always be determined by the top-level call if (block.IncomingEdgeCount != 1 || block == rootBlock) return false; // for now, let's only consider if-structures that form a tree - if (block.Instructions.Count != 2) - return false; if (block.Parent != rootBlock.Parent) return false; // all blocks should belong to the same container } - var inst = block.Instructions[block.Instructions.Count - 2]; - ILInstruction condition, trueInst; LongSet trueValues; - if (inst.MatchIfInstruction(out condition, out trueInst) + if (block.Instructions.Count >= 2 + && block.Instructions[block.Instructions.Count - 2].MatchIfInstruction(out var condition, out var trueInst) && AnalyzeCondition(condition, out trueValues) ) { + if (!(tailOnly || block.Instructions.Count == 2)) + return false; trueValues = trueValues.IntersectWith(inputValues); Block trueBlock; if (trueInst.MatchBranch(out trueBlock) && AnalyzeBlock(trueBlock, trueValues)) { @@ -111,9 +123,12 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow // Create switch section for trueInst. AddSection(trueValues, trueInst); } - } else if (inst.OpCode == OpCode.SwitchInstruction) { - if (AnalyzeSwitch((SwitchInstruction)inst, inputValues, out trueValues)) { + } else if (block.Instructions.Last() is SwitchInstruction switchInst) { + if (!(tailOnly || block.Instructions.Count == 1)) + return false; + if (AnalyzeSwitch(switchInst, inputValues)) { ContainsILSwitch = true; // OK + return true; } else { // switch analysis failed (e.g. switchVar mismatch) return false; } @@ -134,10 +149,9 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow return true; } - private bool AnalyzeSwitch(SwitchInstruction inst, LongSet inputValues, out LongSet anyMatchValues) + private bool AnalyzeSwitch(SwitchInstruction inst, LongSet inputValues) { - Debug.Assert(inst.DefaultBody is Nop); - anyMatchValues = LongSet.Empty; + Debug.Assert(!inst.IsLifted); long offset; if (MatchSwitchVar(inst.Value)) { offset = 0; @@ -163,8 +177,11 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow } foreach (var section in inst.Sections) { var matchValues = section.Labels.AddOffset(offset).IntersectWith(inputValues); - AddSection(matchValues, section.Body); - anyMatchValues = anyMatchValues.UnionWith(matchValues); + if (matchValues.Count() > 1 && section.Body.MatchBranch(out var targetBlock) && AnalyzeBlock(targetBlock, matchValues)) { + InnerBlocks.Add(targetBlock); + } else { + AddSection(matchValues, section.Body); + } } return true; } @@ -180,10 +197,8 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow if (values.IsEmpty) { return; } - Block targetBlock; - if (inst.MatchBranch(out targetBlock)) { - int index; - if (targetBlockToSectionIndex.TryGetValue(targetBlock, out index)) { + if (inst.MatchBranch(out Block targetBlock)) { + if (targetBlockToSectionIndex.TryGetValue(targetBlock, out int index)) { Sections[index] = new KeyValuePair( Sections[index].Key.UnionWith(values), inst @@ -192,6 +207,16 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow targetBlockToSectionIndex.Add(targetBlock, Sections.Count); Sections.Add(new KeyValuePair(values, inst)); } + } else if (inst.MatchLeave(out BlockContainer targetContainer)) { + if (targetContainerToSectionIndex.TryGetValue(targetContainer, out int index)) { + Sections[index] = new KeyValuePair( + Sections[index].Key.UnionWith(values), + inst + ); + } else { + targetContainerToSectionIndex.Add(targetContainer, Sections.Count); + Sections.Add(new KeyValuePair(values, inst)); + } } else { Sections.Add(new KeyValuePair(values, inst)); } diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs b/ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs index 897d41e7e..8473c17bf 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs @@ -60,16 +60,20 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow var sw = new SwitchInstruction(new LdLoc(analysis.SwitchVariable)); foreach (var section in analysis.Sections) { - if (!section.Key.SetEquals(defaultSection.Key)) { - sw.Sections.Add(new SwitchSection - { - Labels = section.Key, - Body = section.Value - }); - } + sw.Sections.Add(new SwitchSection { + Labels = section.Key, + Body = section.Value + }); + } + if (block.Instructions.Last() is SwitchInstruction) { + // we'll replace the switch + } else { + Debug.Assert(block.Instructions.SecondToLastOrDefault() is IfInstruction); + // Remove branch/leave after if; it's getting moved into a section. + block.Instructions.RemoveAt(block.Instructions.Count - 1); } - block.Instructions[block.Instructions.Count - 2] = sw; - block.Instructions[block.Instructions.Count - 1] = defaultSection.Value; + block.Instructions[block.Instructions.Count - 1] = sw; + // mark all inner blocks that were converted to the switch statement for deletion foreach (var innerBlock in analysis.InnerBlocks) { Debug.Assert(innerBlock.Parent == block.Parent); @@ -77,6 +81,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow innerBlock.Instructions.Clear(); } blockContainerNeedsCleanup = true; + SortSwitchSections(sw); } else { // 2nd pass of SimplifySwitchInstruction (after duplicating return blocks), // (1st pass was in ControlFlowSimplification) @@ -87,8 +92,8 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow internal static void SimplifySwitchInstruction(Block block) { // due to our of of basic blocks at this point, - // switch instructions can only appear as second-to-last insturction - var sw = block.Instructions.SecondToLastOrDefault() as SwitchInstruction; + // switch instructions can only appear as last insturction + var sw = block.Instructions.LastOrDefault() as SwitchInstruction; if (sw == null) return; @@ -96,19 +101,13 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow // Any switch instructions will only have branch instructions in the sections. // Combine sections with identical branch target: - block.Instructions.Last().MatchBranch(out Block defaultTarget); var dict = new Dictionary(); // branch target -> switch section sw.Sections.RemoveAll( section => { - Block target; - if (section.Body.MatchBranch(out target)) { - SwitchSection primarySection; - if (target == defaultTarget) { - // This section is just an alternative for 'default'. - Debug.Assert(sw.DefaultBody is Nop); - return true; // remove this section - } else if (dict.TryGetValue(target, out primarySection)) { + if (section.Body.MatchBranch(out Block target)) { + if (dict.TryGetValue(target, out SwitchSection primarySection)) { primarySection.Labels = primarySection.Labels.UnionWith(section.Labels); + primarySection.HasNullLabel |= section.HasNullLabel; return true; // remove this section } else { dict.Add(target, section); @@ -117,6 +116,12 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow return false; }); AdjustLabels(sw); + SortSwitchSections(sw); + } + + static void SortSwitchSections(SwitchInstruction sw) + { + sw.Sections.ReplaceList(sw.Sections.OrderBy(s => (s.Body as Branch)?.TargetILOffset).ThenBy(s => s.Labels.Values.FirstOrDefault())); } static void AdjustLabels(SwitchInstruction sw) diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs b/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs index b9273a821..16e545250 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs @@ -105,7 +105,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow if (!context.Settings.YieldReturn) return; // abort if enumerator decompilation is disabled this.context = context; - this.currentType = function.Method.DeclaringType; + this.currentType = function.CecilMethod.DeclaringType; this.enumeratorType = null; this.enumeratorCtor = null; this.stateField = null; diff --git a/ICSharpCode.Decompiler/IL/DetectedLoop.cs b/ICSharpCode.Decompiler/IL/DetectedLoop.cs index 276ca2657..4d234be29 100644 --- a/ICSharpCode.Decompiler/IL/DetectedLoop.cs +++ b/ICSharpCode.Decompiler/IL/DetectedLoop.cs @@ -76,7 +76,7 @@ namespace ICSharpCode.Decompiler.IL conditions.Add(ifInst.Condition); i--; } - if (i == -1) { + if (i == -1 && conditions.Any()) { return b; } } @@ -116,10 +116,10 @@ namespace ICSharpCode.Decompiler.IL AdditionalBlocks = Container.Blocks.Skip(1).Where(b => b != IncrementBlock).ToArray(); return this; } else if (trueInst is Block block) { - var variable = GetVariableFromCondition(conditionInst); var last = block.Instructions.LastOrDefault(); var secondToLast = block.Instructions.SecondToLastOrDefault(); - if (variable != null && last != null && secondToLast != null && last.MatchBranch(Container.EntryPoint) && MatchIncrement(secondToLast, variable)) { + if (last != null && secondToLast != null && last.MatchBranch(Container.EntryPoint) && + MatchIncrement(secondToLast, out var variable) && conditionInst.Children.Any(c => c.MatchLdLoc(variable))) { Kind = LoopKind.For; IncrementTarget = variable; AdditionalBlocks = Container.Blocks.Skip(1).ToArray(); @@ -144,22 +144,16 @@ namespace ICSharpCode.Decompiler.IL return this; } - static ILVariable GetVariableFromCondition(ILInstruction conditionInst) + static bool MatchIncrement(ILInstruction inst, out ILVariable variable) { - var ldLocs = conditionInst.Children.OfType().ToArray(); - if (ldLocs.Length == 1) - return ldLocs[0].Variable; - else - return null; - } - - static bool MatchIncrement(ILInstruction inst, ILVariable variable) - { - if (!inst.MatchStLoc(variable, out var value)) + if (!inst.MatchStLoc(out variable, out var value)) return false; - if (!value.MatchBinaryNumericInstruction(BinaryNumericOperator.Add, out var left, out var right)) - return false; - return left.MatchLdLoc(variable) && right.MatchLdcI(out var val) && val == 1; + if (!value.MatchBinaryNumericInstruction(BinaryNumericOperator.Add, out var left, out var right)) { + if (value is CompoundAssignmentInstruction cai) { + left = cai.Target; + } else return false; + } + return left.MatchLdLoc(variable); } } } diff --git a/ICSharpCode.Decompiler/IL/ILAstWritingOptions.cs b/ICSharpCode.Decompiler/IL/ILAstWritingOptions.cs new file mode 100644 index 000000000..3b6098d1c --- /dev/null +++ b/ICSharpCode.Decompiler/IL/ILAstWritingOptions.cs @@ -0,0 +1,81 @@ +// Copyright (c) 2017 Daniel Grunwald +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace ICSharpCode.Decompiler.IL +{ + public class ILAstWritingOptions : INotifyPropertyChanged + { + private bool useLogicOperationSugar; + private bool useFieldSugar; + private bool showILRanges; + + /// + /// Sugar for logic.not/and/or. + /// + public bool UseLogicOperationSugar { + get { return useLogicOperationSugar; } + set { + if (useLogicOperationSugar != value) { + useLogicOperationSugar = value; + OnPropertyChanged(); + } + } + } + + /// + /// Sugar for ldfld/stfld. + /// + public bool UseFieldSugar { + get { return useFieldSugar; } + set { + if (useFieldSugar != value) { + useFieldSugar = value; + OnPropertyChanged(); + } + } + } + + /// + /// Show IL ranges in ILAst output. + /// + public bool ShowILRanges { + get { return showILRanges; } + set { + if (showILRanges != value) { + showILRanges = value; + OnPropertyChanged(); + } + } + } + + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); + } + + protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) + { + PropertyChanged?.Invoke(this, e); + } + + public event PropertyChangedEventHandler PropertyChanged; + } +} diff --git a/ICSharpCode.Decompiler/IL/ILReader.cs b/ICSharpCode.Decompiler/IL/ILReader.cs index b401f5c5d..440595904 100644 --- a/ICSharpCode.Decompiler/IL/ILReader.cs +++ b/ICSharpCode.Decompiler/IL/ILReader.cs @@ -304,7 +304,8 @@ namespace ICSharpCode.Decompiler.IL inst.WriteTo(output, new ILAstWritingOptions()); output.WriteLine(); } - new Disassembler.MethodBodyDisassembler(output, false, cancellationToken).WriteExceptionHandlers(body); + new Disassembler.MethodBodyDisassembler(output, cancellationToken) { DetectControlStructure = false } + .WriteExceptionHandlers(body); } /// @@ -317,7 +318,8 @@ namespace ICSharpCode.Decompiler.IL ReadInstructions(cancellationToken); var blockBuilder = new BlockBuilder(body, typeSystem, variableByExceptionHandler); blockBuilder.CreateBlocks(mainContainer, instructionBuilder, isBranchTarget, cancellationToken); - var function = new ILFunction(body.Method, mainContainer); + var method = typeSystem.Resolve(body.Method); + var function = new ILFunction(method, body.Method, mainContainer); CollectionExtensions.AddRange(function.Variables, parameterVariables); CollectionExtensions.AddRange(function.Variables, localVariables); CollectionExtensions.AddRange(function.Variables, stackVariables); @@ -443,7 +445,7 @@ namespace ICSharpCode.Decompiler.IL case Cil.Code.Callvirt: return DecodeCall(OpCode.CallVirt); case Cil.Code.Calli: - throw new NotImplementedException(); + return DecodeCallIndirect(); case Cil.Code.Ceq: return Push(Comparison(ComparisonKind.Equality)); case Cil.Code.Cgt: @@ -523,7 +525,7 @@ namespace ICSharpCode.Decompiler.IL case Cil.Code.Conv_Ovf_U_Un: return Push(new Conv(Pop(), PrimitiveType.U, true, Sign.Unsigned)); case Cil.Code.Cpblk: - throw new NotImplementedException(); + return new Cpblk(size: Pop(StackType.I4), sourceAddress: PopPointer(), destAddress: PopPointer()); case Cil.Code.Div: return BinaryNumeric(BinaryNumericOperator.Div, false, Sign.Signed); case Cil.Code.Div_Un: @@ -535,9 +537,9 @@ namespace ICSharpCode.Decompiler.IL case Cil.Code.Endfinally: return new Leave(null); case Cil.Code.Initblk: - throw new NotImplementedException(); + return new Initblk(size: Pop(StackType.I4), value: Pop(StackType.I4), address: PopPointer()); case Cil.Code.Jmp: - throw new NotImplementedException(); + return DecodeJmp(); case Cil.Code.Ldarg: case Cil.Code.Ldarg_S: return Push(Ldarg(((ParameterDefinition)cecilInst.Operand).Sequence)); @@ -648,7 +650,7 @@ namespace ICSharpCode.Decompiler.IL return BinaryNumeric(BinaryNumericOperator.BitOr); case Cil.Code.Pop: Pop(); - return new Nop(); + return new Nop() { Kind = NopKind.Pop }; case Cil.Code.Rem: return BinaryNumeric(BinaryNumericOperator.Rem, false, Sign.Signed); case Cil.Code.Rem_Un: @@ -916,9 +918,16 @@ namespace ICSharpCode.Decompiler.IL ILInstruction inst = Pop(); if (expectedType != inst.ResultType) { if (expectedType == StackType.I && inst.ResultType == StackType.I4) { + // IL allows implicit I4->I conversions inst = new Conv(inst, PrimitiveType.I, false, Sign.None); + } else if (expectedType == StackType.I4 && inst.ResultType == StackType.I) { + // C++/CLI also sometimes implicitly converts in the other direction: + inst = new Conv(inst, PrimitiveType.I4, false, Sign.None); } else if (expectedType == StackType.Ref && inst.ResultType == StackType.I) { // implicitly start GC tracking + } else if (expectedType == StackType.I && inst.ResultType == StackType.Ref) { + // Implicitly stop GC tracking; this occurs when passing the result of 'ldloca' or 'ldsflda' + // to a method expecting a native pointer. } else if (inst is InvalidExpression) { ((InvalidExpression)inst).ExpectedResultType = expectedType; } else { @@ -1002,7 +1011,9 @@ namespace ICSharpCode.Decompiler.IL ILInstruction InitObj(ILInstruction target, IType type) { - return new StObj(target, new DefaultValue(type), type); + var value = new DefaultValue(type); + value.ILStackWasEmpty = currentStack.IsEmpty; + return new StObj(target, value, type); } private ILInstruction DecodeConstrainedCall() @@ -1105,7 +1116,31 @@ namespace ICSharpCode.Decompiler.IL return call; } } - + + ILInstruction DecodeCallIndirect() + { + var functionPointer = Pop(StackType.I); + var signature = (CallSite)currentInstruction.Operand; + Debug.Assert(!signature.HasThis); + var parameterTypes = new IType[signature.Parameters.Count]; + var arguments = new ILInstruction[parameterTypes.Length]; + for (int i = signature.Parameters.Count - 1; i >= 0; i--) { + parameterTypes[i] = typeSystem.Resolve(signature.Parameters[i].ParameterType); + arguments[i] = Pop(parameterTypes[i].GetStackType()); + } + var call = new CallIndirect( + signature.CallingConvention, + typeSystem.Resolve(signature.ReturnType), + parameterTypes.ToImmutableArray(), + arguments, + functionPointer + ); + if (call.ResultType != StackType.Void) + return Push(call); + else + return call; + } + static int GetPopCount(OpCode callCode, MethodReference methodReference) { int popCount = methodReference.Parameters.Count; @@ -1232,7 +1267,10 @@ namespace ICSharpCode.Decompiler.IL section.Body = new Branch(target); instr.Sections.Add(section); } - + var defaultSection = new SwitchSection(); + defaultSection.Labels = new LongSet(new LongInterval(0, labels.Length)).Invert(); + defaultSection.Body = new Nop(); + instr.Sections.Add(defaultSection); return instr; } @@ -1251,6 +1289,22 @@ namespace ICSharpCode.Decompiler.IL return Push(new BinaryNumericInstruction(@operator, left, right, checkForOverflow, sign)); } + ILInstruction DecodeJmp() + { + IMethod method = ReadAndDecodeMethodReference(); + // Translate jmp into tail call: + Call call = new Call(method); + call.IsTail = true; + call.ILStackWasEmpty = true; + if (!method.IsStatic) { + call.Arguments.Add(Ldarg(0)); + } + foreach (var p in method.Parameters) { + call.Arguments.Add(Ldarg(call.Arguments.Count)); + } + return new Leave(mainContainer, call); + } + ILInstruction LdToken(IMetadataTokenProvider token) { if (token is TypeReference) diff --git a/ICSharpCode.Decompiler/IL/InstructionOutputExtensions.cs b/ICSharpCode.Decompiler/IL/InstructionOutputExtensions.cs index 1bc8681ca..33b5cbc88 100644 --- a/ICSharpCode.Decompiler/IL/InstructionOutputExtensions.cs +++ b/ICSharpCode.Decompiler/IL/InstructionOutputExtensions.cs @@ -18,6 +18,7 @@ using ICSharpCode.Decompiler.Disassembler; using ICSharpCode.Decompiler.TypeSystem; +using ICSharpCode.Decompiler.Util; namespace ICSharpCode.Decompiler.IL { @@ -50,5 +51,15 @@ namespace ICSharpCode.Decompiler.IL else output.WriteReference(symbol.Name, symbol); } + + public static void WriteTo(this Interval interval, ITextOutput output, ILAstWritingOptions options) + { + if (!options.ShowILRanges) + return; + if (interval.IsEmpty) + output.Write("[empty] "); + else + output.Write($"[{interval.Start:x4}..{interval.InclusiveEnd:x4}] "); + } } } diff --git a/ICSharpCode.Decompiler/IL/Instructions.cs b/ICSharpCode.Decompiler/IL/Instructions.cs index 015b312b7..cf68e4446 100644 --- a/ICSharpCode.Decompiler/IL/Instructions.cs +++ b/ICSharpCode.Decompiler/IL/Instructions.cs @@ -83,6 +83,8 @@ namespace ICSharpCode.Decompiler.IL Call, /// Virtual method call. CallVirt, + /// Unsafe function pointer call. + CallIndirect, /// Checks that the input float is not NaN or infinite. Ckfinite, /// Numeric cast. @@ -121,6 +123,10 @@ namespace ICSharpCode.Decompiler.IL LdMemberToken, /// Allocates space in the stack frame LocAlloc, + /// memcpy(destAddress, sourceAddress, size); + Cpblk, + /// memset(address, value, size) + Initblk, /// Load address of instance field LdFlda, /// Load static field address @@ -158,6 +164,8 @@ namespace ICSharpCode.Decompiler.IL /// Converts an array pointer (O) to a reference to the first element, or to a null reference if the array is null or empty. /// Also used to convert a string to a reference to the first character. ArrayToPointer, + /// Maps a string value to an integer. This is used in switch(string). + StringToInt, /// Push a typed reference of type class onto the stack. MakeRefAny, /// Push the type token stored in a typed reference. @@ -289,6 +297,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write('('); this.argument.WriteTo(output, options); @@ -381,6 +390,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write('('); this.left.WriteTo(output, options); @@ -808,6 +818,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); variable.WriteTo(output); @@ -1012,6 +1023,15 @@ namespace ICSharpCode.Decompiler.IL public sealed partial class Branch : SimpleInstruction { public override StackType ResultType { get { return StackType.Void; } } + protected override InstructionFlags ComputeFlags() + { + return InstructionFlags.EndPointUnreachable | InstructionFlags.MayBranch; + } + public override InstructionFlags DirectFlags { + get { + return InstructionFlags.EndPointUnreachable | InstructionFlags.MayBranch; + } + } public override void AcceptVisitor(ILVisitor visitor) { visitor.VisitBranch(this); @@ -1317,7 +1337,7 @@ namespace ICSharpCode.Decompiler.IL protected internal override bool PerformMatch(ILInstruction other, ref Patterns.Match match) { var o = other as SwitchInstruction; - return o != null && Value.PerformMatch(o.Value, ref match) && DefaultBody.PerformMatch(o.DefaultBody, ref match) && Patterns.ListMatch.DoMatch(this.Sections, o.Sections, ref match); + return o != null && IsLifted == o.IsLifted && Value.PerformMatch(o.Value, ref match) && Patterns.ListMatch.DoMatch(this.Sections, o.Sections, ref match); } } } @@ -1389,7 +1409,7 @@ namespace ICSharpCode.Decompiler.IL protected internal override bool PerformMatch(ILInstruction other, ref Patterns.Match match) { var o = other as SwitchSection; - return o != null && this.body.PerformMatch(o.body, ref match) && this.Labels.Intervals.SequenceEqual(o.Labels.Intervals); + return o != null && this.body.PerformMatch(o.body, ref match) && this.Labels.SetEquals(o.Labels) && this.HasNullLabel == o.HasNullLabel; } } } @@ -1950,6 +1970,31 @@ namespace ICSharpCode.Decompiler.IL } } namespace ICSharpCode.Decompiler.IL +{ + /// Unsafe function pointer call. + public sealed partial class CallIndirect : ILInstruction + { + + public override void AcceptVisitor(ILVisitor visitor) + { + visitor.VisitCallIndirect(this); + } + public override T AcceptVisitor(ILVisitor visitor) + { + return visitor.VisitCallIndirect(this); + } + public override T AcceptVisitor(ILVisitor visitor, C context) + { + return visitor.VisitCallIndirect(this, context); + } + protected internal override bool PerformMatch(ILInstruction other, ref Patterns.Match match) + { + var o = other as CallIndirect; + return o != null && EqualSignature(o) && Patterns.ListMatch.DoMatch(this.Arguments, o.Arguments, ref match) && this.FunctionPointer.PerformMatch(o.FunctionPointer, ref match); + } + } +} +namespace ICSharpCode.Decompiler.IL { /// Checks that the input float is not NaN or infinite. public sealed partial class Ckfinite : UnaryInstruction @@ -2071,6 +2116,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); variable.WriteTo(output); @@ -2145,6 +2191,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); variable.WriteTo(output); @@ -2276,6 +2323,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); variable.WriteTo(output); @@ -2370,6 +2418,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write('('); this.value.WriteTo(output, options); @@ -2463,6 +2512,7 @@ namespace ICSharpCode.Decompiler.IL public override StackType ResultType { get { return StackType.O; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); Disassembler.DisassemblerHelpers.WriteOperand(output, Value); @@ -2499,6 +2549,7 @@ namespace ICSharpCode.Decompiler.IL public override StackType ResultType { get { return StackType.I4; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); Disassembler.DisassemblerHelpers.WriteOperand(output, Value); @@ -2535,6 +2586,7 @@ namespace ICSharpCode.Decompiler.IL public override StackType ResultType { get { return StackType.I8; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); Disassembler.DisassemblerHelpers.WriteOperand(output, Value); @@ -2571,6 +2623,7 @@ namespace ICSharpCode.Decompiler.IL public override StackType ResultType { get { return StackType.F; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); Disassembler.DisassemblerHelpers.WriteOperand(output, Value); @@ -2607,6 +2660,7 @@ namespace ICSharpCode.Decompiler.IL public override StackType ResultType { get { return StackType.O; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); Disassembler.DisassemblerHelpers.WriteOperand(output, Value); @@ -2673,6 +2727,7 @@ namespace ICSharpCode.Decompiler.IL public override StackType ResultType { get { return StackType.I; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); method.WriteTo(output); @@ -2720,6 +2775,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); method.WriteTo(output); @@ -2761,6 +2817,7 @@ namespace ICSharpCode.Decompiler.IL public override StackType ResultType { get { return StackType.O; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); type.WriteTo(output); @@ -2799,6 +2856,7 @@ namespace ICSharpCode.Decompiler.IL public override StackType ResultType { get { return StackType.O; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); member.WriteTo(output); @@ -2860,6 +2918,288 @@ namespace ICSharpCode.Decompiler.IL } } namespace ICSharpCode.Decompiler.IL +{ + /// memcpy(destAddress, sourceAddress, size); + public sealed partial class Cpblk : ILInstruction, ISupportsVolatilePrefix, ISupportsUnalignedPrefix + { + public Cpblk(ILInstruction destAddress, ILInstruction sourceAddress, ILInstruction size) : base(OpCode.Cpblk) + { + this.DestAddress = destAddress; + this.SourceAddress = sourceAddress; + this.Size = size; + } + public static readonly SlotInfo DestAddressSlot = new SlotInfo("DestAddress", canInlineInto: true); + ILInstruction destAddress; + public ILInstruction DestAddress { + get { return this.destAddress; } + set { + ValidateChild(value); + SetChildInstruction(ref this.destAddress, value, 0); + } + } + public static readonly SlotInfo SourceAddressSlot = new SlotInfo("SourceAddress", canInlineInto: true); + ILInstruction sourceAddress; + public ILInstruction SourceAddress { + get { return this.sourceAddress; } + set { + ValidateChild(value); + SetChildInstruction(ref this.sourceAddress, value, 1); + } + } + public static readonly SlotInfo SizeSlot = new SlotInfo("Size", canInlineInto: true); + ILInstruction size; + public ILInstruction Size { + get { return this.size; } + set { + ValidateChild(value); + SetChildInstruction(ref this.size, value, 2); + } + } + protected sealed override int GetChildCount() + { + return 3; + } + protected sealed override ILInstruction GetChild(int index) + { + switch (index) { + case 0: + return this.destAddress; + case 1: + return this.sourceAddress; + case 2: + return this.size; + default: + throw new IndexOutOfRangeException(); + } + } + protected sealed override void SetChild(int index, ILInstruction value) + { + switch (index) { + case 0: + this.DestAddress = value; + break; + case 1: + this.SourceAddress = value; + break; + case 2: + this.Size = value; + break; + default: + throw new IndexOutOfRangeException(); + } + } + protected sealed override SlotInfo GetChildSlot(int index) + { + switch (index) { + case 0: + return DestAddressSlot; + case 1: + return SourceAddressSlot; + case 2: + return SizeSlot; + default: + throw new IndexOutOfRangeException(); + } + } + public sealed override ILInstruction Clone() + { + var clone = (Cpblk)ShallowClone(); + clone.DestAddress = this.destAddress.Clone(); + clone.SourceAddress = this.sourceAddress.Clone(); + clone.Size = this.size.Clone(); + return clone; + } + /// Gets/Sets whether the memory access is volatile. + public bool IsVolatile { get; set; } + /// Returns the alignment specified by the 'unaligned' prefix; or 0 if there was no 'unaligned' prefix. + public byte UnalignedPrefix { get; set; } + public override StackType ResultType { get { return StackType.Void; } } + protected override InstructionFlags ComputeFlags() + { + return destAddress.Flags | sourceAddress.Flags | size.Flags | InstructionFlags.MayThrow | InstructionFlags.SideEffect; + } + public override InstructionFlags DirectFlags { + get { + return InstructionFlags.MayThrow | InstructionFlags.SideEffect; + } + } + public override void WriteTo(ITextOutput output, ILAstWritingOptions options) + { + ILRange.WriteTo(output, options); + if (IsVolatile) + output.Write("volatile."); + if (UnalignedPrefix > 0) + output.Write("unaligned(" + UnalignedPrefix + ")."); + output.Write(OpCode); + output.Write('('); + this.destAddress.WriteTo(output, options); + output.Write(", "); + this.sourceAddress.WriteTo(output, options); + output.Write(", "); + this.size.WriteTo(output, options); + output.Write(')'); + } + public override void AcceptVisitor(ILVisitor visitor) + { + visitor.VisitCpblk(this); + } + public override T AcceptVisitor(ILVisitor visitor) + { + return visitor.VisitCpblk(this); + } + public override T AcceptVisitor(ILVisitor visitor, C context) + { + return visitor.VisitCpblk(this, context); + } + protected internal override bool PerformMatch(ILInstruction other, ref Patterns.Match match) + { + var o = other as Cpblk; + return o != null && this.destAddress.PerformMatch(o.destAddress, ref match) && this.sourceAddress.PerformMatch(o.sourceAddress, ref match) && this.size.PerformMatch(o.size, ref match) && IsVolatile == o.IsVolatile && UnalignedPrefix == o.UnalignedPrefix; + } + } +} +namespace ICSharpCode.Decompiler.IL +{ + /// memset(address, value, size) + public sealed partial class Initblk : ILInstruction, ISupportsVolatilePrefix, ISupportsUnalignedPrefix + { + public Initblk(ILInstruction address, ILInstruction value, ILInstruction size) : base(OpCode.Initblk) + { + this.Address = address; + this.Value = value; + this.Size = size; + } + public static readonly SlotInfo AddressSlot = new SlotInfo("Address", canInlineInto: true); + ILInstruction address; + public ILInstruction Address { + get { return this.address; } + set { + ValidateChild(value); + SetChildInstruction(ref this.address, value, 0); + } + } + public static readonly SlotInfo ValueSlot = new SlotInfo("Value", canInlineInto: true); + ILInstruction value; + public ILInstruction Value { + get { return this.value; } + set { + ValidateChild(value); + SetChildInstruction(ref this.value, value, 1); + } + } + public static readonly SlotInfo SizeSlot = new SlotInfo("Size", canInlineInto: true); + ILInstruction size; + public ILInstruction Size { + get { return this.size; } + set { + ValidateChild(value); + SetChildInstruction(ref this.size, value, 2); + } + } + protected sealed override int GetChildCount() + { + return 3; + } + protected sealed override ILInstruction GetChild(int index) + { + switch (index) { + case 0: + return this.address; + case 1: + return this.value; + case 2: + return this.size; + default: + throw new IndexOutOfRangeException(); + } + } + protected sealed override void SetChild(int index, ILInstruction value) + { + switch (index) { + case 0: + this.Address = value; + break; + case 1: + this.Value = value; + break; + case 2: + this.Size = value; + break; + default: + throw new IndexOutOfRangeException(); + } + } + protected sealed override SlotInfo GetChildSlot(int index) + { + switch (index) { + case 0: + return AddressSlot; + case 1: + return ValueSlot; + case 2: + return SizeSlot; + default: + throw new IndexOutOfRangeException(); + } + } + public sealed override ILInstruction Clone() + { + var clone = (Initblk)ShallowClone(); + clone.Address = this.address.Clone(); + clone.Value = this.value.Clone(); + clone.Size = this.size.Clone(); + return clone; + } + /// Gets/Sets whether the memory access is volatile. + public bool IsVolatile { get; set; } + /// Returns the alignment specified by the 'unaligned' prefix; or 0 if there was no 'unaligned' prefix. + public byte UnalignedPrefix { get; set; } + public override StackType ResultType { get { return StackType.Void; } } + protected override InstructionFlags ComputeFlags() + { + return address.Flags | value.Flags | size.Flags | InstructionFlags.MayThrow | InstructionFlags.SideEffect; + } + public override InstructionFlags DirectFlags { + get { + return InstructionFlags.MayThrow | InstructionFlags.SideEffect; + } + } + public override void WriteTo(ITextOutput output, ILAstWritingOptions options) + { + ILRange.WriteTo(output, options); + if (IsVolatile) + output.Write("volatile."); + if (UnalignedPrefix > 0) + output.Write("unaligned(" + UnalignedPrefix + ")."); + output.Write(OpCode); + output.Write('('); + this.address.WriteTo(output, options); + output.Write(", "); + this.value.WriteTo(output, options); + output.Write(", "); + this.size.WriteTo(output, options); + output.Write(')'); + } + public override void AcceptVisitor(ILVisitor visitor) + { + visitor.VisitInitblk(this); + } + public override T AcceptVisitor(ILVisitor visitor) + { + return visitor.VisitInitblk(this); + } + public override T AcceptVisitor(ILVisitor visitor, C context) + { + return visitor.VisitInitblk(this, context); + } + protected internal override bool PerformMatch(ILInstruction other, ref Patterns.Match match) + { + var o = other as Initblk; + return o != null && this.address.PerformMatch(o.address, ref match) && this.value.PerformMatch(o.value, ref match) && this.size.PerformMatch(o.size, ref match) && IsVolatile == o.IsVolatile && UnalignedPrefix == o.UnalignedPrefix; + } + } +} +namespace ICSharpCode.Decompiler.IL { /// Load address of instance field public sealed partial class LdFlda : ILInstruction, IInstructionWithFieldOperand @@ -2932,6 +3272,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); field.WriteTo(output); @@ -2973,6 +3314,7 @@ namespace ICSharpCode.Decompiler.IL public IField Field { get { return field; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); field.WriteTo(output); @@ -3020,6 +3362,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); type.WriteTo(output); @@ -3061,6 +3404,7 @@ namespace ICSharpCode.Decompiler.IL public override StackType ResultType { get { return StackType.O; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); type.WriteTo(output); @@ -3163,6 +3507,7 @@ namespace ICSharpCode.Decompiler.IL } void OriginalWriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); if (IsVolatile) output.Write("volatile."); if (UnalignedPrefix > 0) @@ -3287,6 +3632,7 @@ namespace ICSharpCode.Decompiler.IL } void OriginalWriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); if (IsVolatile) output.Write("volatile."); if (UnalignedPrefix > 0) @@ -3343,6 +3689,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); type.WriteTo(output); @@ -3393,6 +3740,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); type.WriteTo(output); @@ -3443,6 +3791,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); type.WriteTo(output); @@ -3553,6 +3902,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); type.WriteTo(output); @@ -3598,6 +3948,7 @@ namespace ICSharpCode.Decompiler.IL public override StackType ResultType { get { return type.GetStackType(); } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); type.WriteTo(output); @@ -3710,6 +4061,7 @@ namespace ICSharpCode.Decompiler.IL public override StackType ResultType { get { return StackType.I4; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); type.WriteTo(output); @@ -3895,6 +4247,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); if (IsReadOnly) output.Write("readonly."); output.Write(OpCode); @@ -3996,6 +4349,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write('('); this.array.WriteTo(output, options); @@ -4021,6 +4375,87 @@ namespace ICSharpCode.Decompiler.IL } } namespace ICSharpCode.Decompiler.IL +{ + /// Maps a string value to an integer. This is used in switch(string). + public sealed partial class StringToInt : ILInstruction + { + public static readonly SlotInfo ArgumentSlot = new SlotInfo("Argument", canInlineInto: true); + ILInstruction argument; + public ILInstruction Argument { + get { return this.argument; } + set { + ValidateChild(value); + SetChildInstruction(ref this.argument, value, 0); + } + } + protected sealed override int GetChildCount() + { + return 1; + } + protected sealed override ILInstruction GetChild(int index) + { + switch (index) { + case 0: + return this.argument; + default: + throw new IndexOutOfRangeException(); + } + } + protected sealed override void SetChild(int index, ILInstruction value) + { + switch (index) { + case 0: + this.Argument = value; + break; + default: + throw new IndexOutOfRangeException(); + } + } + protected sealed override SlotInfo GetChildSlot(int index) + { + switch (index) { + case 0: + return ArgumentSlot; + default: + throw new IndexOutOfRangeException(); + } + } + public sealed override ILInstruction Clone() + { + var clone = (StringToInt)ShallowClone(); + clone.Argument = this.argument.Clone(); + return clone; + } + public override StackType ResultType { get { return StackType.I4; } } + protected override InstructionFlags ComputeFlags() + { + return argument.Flags; + } + public override InstructionFlags DirectFlags { + get { + return InstructionFlags.None; + } + } + public override void AcceptVisitor(ILVisitor visitor) + { + visitor.VisitStringToInt(this); + } + public override T AcceptVisitor(ILVisitor visitor) + { + return visitor.VisitStringToInt(this); + } + public override T AcceptVisitor(ILVisitor visitor, C context) + { + return visitor.VisitStringToInt(this, context); + } + protected internal override bool PerformMatch(ILInstruction other, ref Patterns.Match match) + { + var o = other as StringToInt; + return o != null && this.argument.PerformMatch(o.argument, ref match); + } + } +} +namespace ICSharpCode.Decompiler.IL { /// Push a typed reference of type class onto the stack. public sealed partial class MakeRefAny : UnaryInstruction @@ -4035,6 +4470,7 @@ namespace ICSharpCode.Decompiler.IL public override StackType ResultType { get { return StackType.O; } } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); type.WriteTo(output); @@ -4113,6 +4549,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); type.WriteTo(output); @@ -4207,6 +4644,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write('('); this.value.WriteTo(output, options); @@ -4299,6 +4737,7 @@ namespace ICSharpCode.Decompiler.IL } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write('('); this.value.WriteTo(output, options); @@ -4360,6 +4799,7 @@ namespace ICSharpCode.Decompiler.IL.Patterns } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write('('); output.Write(')'); @@ -4485,6 +4925,10 @@ namespace ICSharpCode.Decompiler.IL { Default(inst); } + protected internal virtual void VisitCallIndirect(CallIndirect inst) + { + Default(inst); + } protected internal virtual void VisitCkfinite(Ckfinite inst) { Default(inst); @@ -4561,6 +5005,14 @@ namespace ICSharpCode.Decompiler.IL { Default(inst); } + protected internal virtual void VisitCpblk(Cpblk inst) + { + Default(inst); + } + protected internal virtual void VisitInitblk(Initblk inst) + { + Default(inst); + } protected internal virtual void VisitLdFlda(LdFlda inst) { Default(inst); @@ -4633,6 +5085,10 @@ namespace ICSharpCode.Decompiler.IL { Default(inst); } + protected internal virtual void VisitStringToInt(StringToInt inst) + { + Default(inst); + } protected internal virtual void VisitMakeRefAny(MakeRefAny inst) { Default(inst); @@ -4771,6 +5227,10 @@ namespace ICSharpCode.Decompiler.IL { return Default(inst); } + protected internal virtual T VisitCallIndirect(CallIndirect inst) + { + return Default(inst); + } protected internal virtual T VisitCkfinite(Ckfinite inst) { return Default(inst); @@ -4847,6 +5307,14 @@ namespace ICSharpCode.Decompiler.IL { return Default(inst); } + protected internal virtual T VisitCpblk(Cpblk inst) + { + return Default(inst); + } + protected internal virtual T VisitInitblk(Initblk inst) + { + return Default(inst); + } protected internal virtual T VisitLdFlda(LdFlda inst) { return Default(inst); @@ -4919,6 +5387,10 @@ namespace ICSharpCode.Decompiler.IL { return Default(inst); } + protected internal virtual T VisitStringToInt(StringToInt inst) + { + return Default(inst); + } protected internal virtual T VisitMakeRefAny(MakeRefAny inst) { return Default(inst); @@ -5057,6 +5529,10 @@ namespace ICSharpCode.Decompiler.IL { return Default(inst, context); } + protected internal virtual T VisitCallIndirect(CallIndirect inst, C context) + { + return Default(inst, context); + } protected internal virtual T VisitCkfinite(Ckfinite inst, C context) { return Default(inst, context); @@ -5133,6 +5609,14 @@ namespace ICSharpCode.Decompiler.IL { return Default(inst, context); } + protected internal virtual T VisitCpblk(Cpblk inst, C context) + { + return Default(inst, context); + } + protected internal virtual T VisitInitblk(Initblk inst, C context) + { + return Default(inst, context); + } protected internal virtual T VisitLdFlda(LdFlda inst, C context) { return Default(inst, context); @@ -5205,6 +5689,10 @@ namespace ICSharpCode.Decompiler.IL { return Default(inst, context); } + protected internal virtual T VisitStringToInt(StringToInt inst, C context) + { + return Default(inst, context); + } protected internal virtual T VisitMakeRefAny(MakeRefAny inst, C context) { return Default(inst, context); @@ -5257,6 +5745,7 @@ namespace ICSharpCode.Decompiler.IL "comp", "call", "callvirt", + "calli", "ckfinite", "conv", "ldloc", @@ -5276,6 +5765,8 @@ namespace ICSharpCode.Decompiler.IL "ldtypetoken", "ldmembertoken", "localloc", + "cpblk", + "initblk", "ldflda", "ldsflda", "castclass", @@ -5294,6 +5785,7 @@ namespace ICSharpCode.Decompiler.IL "ldlen", "ldelema", "array.to.pointer", + "string.to.int", "mkrefany", "refanytype", "refanyval", @@ -5585,6 +6077,34 @@ namespace ICSharpCode.Decompiler.IL argument = default(ILInstruction); return false; } + public bool MatchCpblk(out ILInstruction destAddress, out ILInstruction sourceAddress, out ILInstruction size) + { + var inst = this as Cpblk; + if (inst != null) { + destAddress = inst.DestAddress; + sourceAddress = inst.SourceAddress; + size = inst.Size; + return true; + } + destAddress = default(ILInstruction); + sourceAddress = default(ILInstruction); + size = default(ILInstruction); + return false; + } + public bool MatchInitblk(out ILInstruction address, out ILInstruction value, out ILInstruction size) + { + var inst = this as Initblk; + if (inst != null) { + address = inst.Address; + value = inst.Value; + size = inst.Size; + return true; + } + address = default(ILInstruction); + value = default(ILInstruction); + size = default(ILInstruction); + return false; + } public bool MatchLdFlda(out ILInstruction target, out IField field) { var inst = this as LdFlda; diff --git a/ICSharpCode.Decompiler/IL/Instructions.tt b/ICSharpCode.Decompiler/IL/Instructions.tt index 2b28a9efe..59c19a742 100644 --- a/ICSharpCode.Decompiler/IL/Instructions.tt +++ b/ICSharpCode.Decompiler/IL/Instructions.tt @@ -73,7 +73,7 @@ new OpCode("bit.not", "Bitwise NOT", Unary, CustomConstructor, MatchCondition("IsLifted == o.IsLifted && UnderlyingResultType == o.UnderlyingResultType")), new OpCode("arglist", "Retrieves the RuntimeArgumentHandle.", NoArguments, ResultType("O")), new OpCode("br", "Unconditional branch. goto target;", - CustomClassName("Branch"), NoArguments, CustomConstructor, UnconditionalBranch, MayBranch, CustomComputeFlags, + CustomClassName("Branch"), NoArguments, CustomConstructor, UnconditionalBranch, MayBranch, MatchCondition("this.TargetBlock == o.TargetBlock")), new OpCode("leave", "Unconditional branch to end of block container. Return is represented using IsLeavingFunction and an (optional) return value. The block container evaluates to the value produced by the argument of the leave instruction.", CustomConstructor, CustomArguments("value"), UnconditionalBranch, MayBranch, CustomWriteTo, CustomComputeFlags, @@ -93,11 +93,11 @@ }), CustomConstructor, CustomComputeFlags, CustomWriteTo), new OpCode("switch", "Switch statement", CustomClassName("SwitchInstruction"), CustomConstructor, CustomComputeFlags, CustomWriteTo, ResultType("Void"), - MatchCondition("Value.PerformMatch(o.Value, ref match) && DefaultBody.PerformMatch(o.DefaultBody, ref match) && Patterns.ListMatch.DoMatch(this.Sections, o.Sections, ref match)")), + MatchCondition("IsLifted == o.IsLifted && Value.PerformMatch(o.Value, ref match) && Patterns.ListMatch.DoMatch(this.Sections, o.Sections, ref match)")), new OpCode("switch.section", "Switch section within a switch statement", CustomClassName("SwitchSection"), CustomChildren(new [] { new ChildInfo("body") }), CustomConstructor, CustomComputeFlags, CustomWriteTo, ResultType("Void"), - MatchCondition("this.Labels.Intervals.SequenceEqual(o.Labels.Intervals)")), + MatchCondition("this.Labels.SetEquals(o.Labels) && this.HasNullLabel == o.HasNullLabel")), new OpCode("try.catch", "Try-catch statement.", BaseClass("TryInstruction"), CustomConstructor, CustomComputeFlags, CustomWriteTo, MatchCondition("TryBlock.PerformMatch(o.TryBlock, ref match)"), @@ -135,6 +135,12 @@ new OpCode("call", "Non-virtual method call.", Call), new OpCode("callvirt", "Virtual method call.", CustomClassName("CallVirt"), Call), + new OpCode("calli", "Unsafe function pointer call.", + CustomClassName("CallIndirect"), + CustomConstructor, CustomWriteTo, + MatchCondition("EqualSignature(o)"), + MatchCondition("Patterns.ListMatch.DoMatch(this.Arguments, o.Arguments, ref match)"), + MatchCondition("this.FunctionPointer.PerformMatch(o.FunctionPointer, ref match)")), new OpCode("ckfinite", "Checks that the input float is not NaN or infinite.", Unary, MayThrow, VoidResult), new OpCode("conv", "Numeric cast.", @@ -176,7 +182,15 @@ CustomClassName("LdMemberToken"), NoArguments, HasMemberOperand, ResultType("O")), new OpCode("localloc", "Allocates space in the stack frame", CustomClassName("LocAlloc"), Unary, ResultType("I"), MayThrow), - + new OpCode("cpblk", "memcpy(destAddress, sourceAddress, size);", + CustomArguments("destAddress", "sourceAddress", "size"), + MayThrow, MemoryAccess, + SupportsVolatilePrefix, SupportsUnalignedPrefix, ResultType("Void")), + new OpCode("initblk", "memset(address, value, size)", + CustomArguments("address", "value", "size"), + MayThrow, MemoryAccess, + SupportsVolatilePrefix, SupportsUnalignedPrefix, ResultType("Void")), + new OpCode("ldflda", "Load address of instance field", CustomClassName("LdFlda"), CustomArguments("target"), MayThrowIfNotDelayed, HasFieldOperand, ResultType("Ref")), new OpCode("ldsflda", "Load static field address", @@ -220,6 +234,8 @@ new OpCode("array.to.pointer", "Converts an array pointer (O) to a reference to the first element, or to a null reference if the array is null or empty." + Environment.NewLine + "Also used to convert a string to a reference to the first character.", CustomArguments("array"), ResultType("Ref")), + new OpCode("string.to.int", "Maps a string value to an integer. This is used in switch(string).", + CustomArguments("argument"), CustomConstructor, CustomWriteTo, ResultType("I4")), new OpCode("mkrefany", "Push a typed reference of type class onto the stack.", CustomClassName("MakeRefAny"), Unary, HasTypeOperand, ResultType("O")), @@ -483,6 +499,7 @@ namespace ICSharpCode.Decompiler.IL public IEnumerable WriteToBody { get { + yield return "ILRange.WriteTo(output, options);"; foreach (string line in WriteOpCodePrefix) yield return line; yield return "output.Write(OpCode);"; diff --git a/ICSharpCode.Decompiler/IL/Instructions/BinaryNumericInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/BinaryNumericInstruction.cs index a1a037443..e409973ab 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/BinaryNumericInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/BinaryNumericInstruction.cs @@ -178,6 +178,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write("." + GetOperatorName(Operator)); if (CheckForOverflow) { diff --git a/ICSharpCode.Decompiler/IL/Instructions/Block.cs b/ICSharpCode.Decompiler/IL/Instructions/Block.cs index 3931beece..e32ede62f 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/Block.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/Block.cs @@ -108,6 +108,9 @@ namespace ICSharpCode.Decompiler.IL // only the last instruction may have an unreachable endpoint Debug.Assert(!Instructions[i].HasFlag(InstructionFlags.EndPointUnreachable)); } + if (this.Type == BlockType.ControlFlow) { + Debug.Assert(finalInstruction.OpCode == OpCode.Nop); + } } public override StackType ResultType { @@ -126,13 +129,14 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write("Block "); output.WriteDefinition(Label, this); if (Parent is BlockContainer) output.Write(" (incoming: {0})", IncomingEdgeCount); output.Write(' '); output.MarkFoldStart("{...}"); - output.WriteLine(" {"); + output.WriteLine("{"); output.Indent(); foreach (var inst in Instructions) { inst.WriteTo(output, options); diff --git a/ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs b/ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs index 5cf84221c..3308e709c 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs @@ -40,11 +40,19 @@ namespace ICSharpCode.Decompiler.IL public readonly InstructionCollection Blocks; public StackType ExpectedResultType { get; set; } - + + int leaveCount; + /// /// Gets the number of 'leave' instructions that target this BlockContainer. /// - public int LeaveCount { get; internal set; } + public int LeaveCount { + get => leaveCount; + internal set { + leaveCount = value; + InvalidateFlags(); + } + } Block entryPoint; @@ -107,8 +115,15 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.WriteDefinition("BlockContainer", this); output.Write(' '); + if (entryPoint.IncomingEdgeCount > 1) { + output.Write("(loop) "); + } + if (entryPoint.Instructions.Count == 1 && entryPoint.Instructions[0] is SwitchInstruction) { + output.Write("(switch) "); + } output.MarkFoldStart("{...}"); output.WriteLine("{"); output.Indent(); @@ -154,7 +169,7 @@ namespace ICSharpCode.Decompiler.IL Debug.Assert(EntryPoint == Blocks[0]); Debug.Assert(!IsConnected || EntryPoint.IncomingEdgeCount >= 1); Debug.Assert(Blocks.All(b => b.HasFlag(InstructionFlags.EndPointUnreachable))); - Debug.Assert(Blocks.All(b => b.FinalInstruction.OpCode == OpCode.Nop)); + Debug.Assert(Blocks.All(b => b.Type == BlockType.ControlFlow)); // this also implies that the blocks don't use FinalInstruction } protected override InstructionFlags ComputeFlags() @@ -226,5 +241,15 @@ namespace ICSharpCode.Decompiler.IL } return null; } + + public static BlockContainer FindClosestSwitchContainer(ILInstruction inst) + { + while (inst != null) { + if (inst is BlockContainer bc && bc.entryPoint.Instructions.FirstOrDefault() is SwitchInstruction) + return bc; + inst = inst.Parent; + } + return null; + } } } diff --git a/ICSharpCode.Decompiler/IL/Instructions/Branch.cs b/ICSharpCode.Decompiler/IL/Instructions/Branch.cs index 8cfab388b..6248f75f7 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/Branch.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/Branch.cs @@ -39,23 +39,10 @@ namespace ICSharpCode.Decompiler.IL public Branch(Block targetBlock) : base(OpCode.Branch) { - if (targetBlock == null) - throw new ArgumentNullException(nameof(targetBlock)); - this.targetBlock = targetBlock; + this.targetBlock = targetBlock ?? throw new ArgumentNullException(nameof(targetBlock)); this.targetILOffset = targetBlock.ILRange.Start; } - protected override InstructionFlags ComputeFlags() - { - return InstructionFlags.MayBranch | InstructionFlags.EndPointUnreachable; - } - - public override InstructionFlags DirectFlags { - get { - return InstructionFlags.MayBranch | InstructionFlags.EndPointUnreachable; - } - } - public int TargetILOffset { get { return targetBlock != null ? targetBlock.ILRange.Start : targetILOffset; } } @@ -126,6 +113,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write(' '); output.WriteReference(TargetLabel, (object)targetBlock ?? TargetILOffset, isLocal: true); diff --git a/ICSharpCode.Decompiler/IL/Instructions/CallIndirect.cs b/ICSharpCode.Decompiler/IL/Instructions/CallIndirect.cs new file mode 100644 index 000000000..a2380d5cf --- /dev/null +++ b/ICSharpCode.Decompiler/IL/Instructions/CallIndirect.cs @@ -0,0 +1,171 @@ +// Copyright (c) 2017 Daniel Grunwald +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Linq; +using ICSharpCode.Decompiler.TypeSystem; + +namespace ICSharpCode.Decompiler.IL +{ + partial class CallIndirect + { + public static readonly SlotInfo ArgumentSlot = new SlotInfo("Argument", canInlineInto: true, isCollection: true); + public static readonly SlotInfo FunctionPointerSlot = new SlotInfo("FunctionPointer", canInlineInto: true); + + public readonly InstructionCollection Arguments; + ILInstruction functionPointer; + + public Mono.Cecil.MethodCallingConvention CallingConvention { get; } + public IType ReturnType { get; } + public ImmutableArray ParameterTypes { get; } + + /// + /// A 'final instruction' that gets executed after the Instructions collection. + /// Provides the return value for the block. + /// + /// + /// Blocks in containers must have 'Nop' as a final instruction. + /// + public ILInstruction FunctionPointer { + get { + return functionPointer; + } + set { + ValidateChild(value); + SetChildInstruction(ref functionPointer, value, Arguments.Count); + } + } + + protected internal override void InstructionCollectionUpdateComplete() + { + base.InstructionCollectionUpdateComplete(); + if (functionPointer?.Parent == this) + functionPointer.ChildIndex = Arguments.Count; + } + + public CallIndirect(Mono.Cecil.MethodCallingConvention callingConvention, IType returnType, ImmutableArray parameterTypes, + IEnumerable arguments, ILInstruction functionPointer) : base(OpCode.CallIndirect) + { + this.CallingConvention = callingConvention; + this.ReturnType = returnType ?? throw new ArgumentNullException("returnType"); + this.ParameterTypes = parameterTypes.ToImmutableArray(); + this.Arguments = new InstructionCollection(this, 0); + this.Arguments.AddRange(arguments); + this.FunctionPointer = functionPointer; + } + + public override ILInstruction Clone() + { + return new CallIndirect(CallingConvention, ReturnType, ParameterTypes, + this.Arguments.Select(inst => inst.Clone()), functionPointer.Clone() + ) { + ILRange = this.ILRange + }; + } + + public override StackType ResultType => ReturnType.GetStackType(); + + internal override void CheckInvariant(ILPhase phase) + { + base.CheckInvariant(phase); + Debug.Assert(Arguments.Count == ParameterTypes.Length); + } + + public override void WriteTo(ITextOutput output, ILAstWritingOptions options) + { + ILRange.WriteTo(output, options); + output.Write("call.indirect "); + ReturnType.WriteTo(output); + output.Write('('); + bool first = true; + foreach (var (inst, type) in Arguments.Zip(ParameterTypes, (a,b) => (a,b))) { + if (first) + first = false; + else + output.Write(", "); + inst.WriteTo(output, options); + output.Write(" : "); + type.WriteTo(output); + } + if (Arguments.Count > 0) + output.Write(", "); + functionPointer.WriteTo(output, options); + output.Write(')'); + } + + protected override int GetChildCount() + { + return Arguments.Count + 1; + } + + protected override ILInstruction GetChild(int index) + { + if (index == Arguments.Count) + return functionPointer; + return Arguments[index]; + } + + protected override void SetChild(int index, ILInstruction value) + { + if (index == Arguments.Count) + FunctionPointer = value; + else + Arguments[index] = value; + } + + protected override SlotInfo GetChildSlot(int index) + { + if (index == Arguments.Count) + return FunctionPointerSlot; + else + return ArgumentSlot; + } + + protected override InstructionFlags ComputeFlags() + { + var flags = this.DirectFlags; + foreach (var inst in Arguments) { + flags |= inst.Flags; + } + flags |= functionPointer.Flags; + return flags; + } + + public override InstructionFlags DirectFlags { + get { + return InstructionFlags.MayThrow | InstructionFlags.SideEffect; + } + } + + bool EqualSignature(CallIndirect other) + { + if (CallingConvention != other.CallingConvention) + return false; + if (ParameterTypes.Length != other.ParameterTypes.Length) + return false; + for (int i = 0; i < ParameterTypes.Length; i++) { + if (!ParameterTypes[i].Equals(other.ParameterTypes[i])) + return false; + } + return ReturnType.Equals(other.ReturnType); + } + } +} diff --git a/ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs index f846cb754..915ba74bc 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs @@ -76,6 +76,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); if (ConstrainedTo != null) { output.Write("constrained["); ConstrainedTo.WriteTo(output, ILNameSyntax.ShortTypeName); diff --git a/ICSharpCode.Decompiler/IL/Instructions/Comp.cs b/ICSharpCode.Decompiler/IL/Instructions/Comp.cs index 371cc4723..b4de5e4c2 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/Comp.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/Comp.cs @@ -175,6 +175,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); if (options.UseLogicOperationSugar && MatchLogicNot(out var arg)) { output.Write("logic.not("); arg.WriteTo(output, options); diff --git a/ICSharpCode.Decompiler/IL/Instructions/CompoundAssignmentInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/CompoundAssignmentInstruction.cs index 7d372c5cf..2b7f34e40 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/CompoundAssignmentInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/CompoundAssignmentInstruction.cs @@ -154,6 +154,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write("." + GetOperatorName(Operator)); if (CompoundAssignmentType == CompoundAssignmentType.EvaluatesToNewValue) diff --git a/ICSharpCode.Decompiler/IL/Instructions/Conv.cs b/ICSharpCode.Decompiler/IL/Instructions/Conv.cs index 8ba33dec9..235170a07 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/Conv.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/Conv.cs @@ -260,6 +260,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); if (CheckForOverflow) { output.Write(".ovf"); diff --git a/ICSharpCode.Decompiler/IL/Instructions/DefaultValue.cs b/ICSharpCode.Decompiler/IL/Instructions/DefaultValue.cs new file mode 100644 index 000000000..b8ecea156 --- /dev/null +++ b/ICSharpCode.Decompiler/IL/Instructions/DefaultValue.cs @@ -0,0 +1,33 @@ +// Copyright (c) 2017 Siegfried Pammer +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Text; + +namespace ICSharpCode.Decompiler.IL +{ + partial class DefaultValue + { + /// + /// Gets whether the IL stack was empty at the point of this instruction. + /// (not counting the argument of the instruction itself) + /// + public bool ILStackWasEmpty; + } +} diff --git a/ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs b/ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs index 4c385d202..4424ba4f5 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs @@ -18,10 +18,8 @@ using System; using System.Collections.Generic; -using System.Threading; using ICSharpCode.Decompiler.IL.Transforms; using Mono.Cecil; -using ICSharpCode.Decompiler.Disassembler; using System.Linq; using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.Util; @@ -31,7 +29,8 @@ namespace ICSharpCode.Decompiler.IL { partial class ILFunction { - public readonly MethodDefinition Method; + public readonly IMethod Method; + public readonly MethodDefinition CecilMethod; public readonly ILVariableCollection Variables; /// @@ -62,10 +61,11 @@ namespace ICSharpCode.Decompiler.IL /// public IType AsyncReturnType; - public ILFunction(MethodDefinition method, ILInstruction body) : base(OpCode.ILFunction) + public ILFunction(IMethod method, MethodDefinition cecilMethod, ILInstruction body) : base(OpCode.ILFunction) { this.Body = body; this.Method = method; + this.CecilMethod = cecilMethod; this.Variables = new ILVariableCollection(this); } @@ -85,6 +85,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); if (Method != null) { output.Write(' '); @@ -113,12 +114,41 @@ namespace ICSharpCode.Decompiler.IL } body.WriteTo(output, options); - output.WriteLine(); + + if (options.ShowILRanges) { + var unusedILRanges = FindUnusedILRanges(); + if (!unusedILRanges.IsEmpty) { + output.Write("// Unused IL Ranges: "); + output.Write(string.Join(", ", unusedILRanges.Intervals.Select( + range => $"[{range.Start:x4}..{range.InclusiveEnd:x4}]"))); + output.WriteLine(); + } + } + output.Unindent(); output.WriteLine("}"); } + LongSet FindUnusedILRanges() + { + var usedILRanges = new List(); + MarkUsedILRanges(body); + return new LongSet(new LongInterval(0, CecilMethod.Body.CodeSize)).ExceptWith(new LongSet(usedILRanges)); + + void MarkUsedILRanges(ILInstruction inst) + { + if (CSharp.SequencePointBuilder.HasUsableILRange(inst)) { + usedILRanges.Add(new LongInterval(inst.ILRange.Start, inst.ILRange.End)); + } + if (!(inst is ILFunction)) { + foreach (var child in inst.Children) { + MarkUsedILRanges(child); + } + } + } + } + protected override InstructionFlags ComputeFlags() { // Creating a lambda may throw OutOfMemoryException diff --git a/ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs index b4042364e..433bf39d8 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs @@ -208,10 +208,26 @@ namespace ICSharpCode.Decompiler.IL /// public Interval ILRange; - public void AddILRange(Interval ilRange) + public void AddILRange(Interval newRange) { - // TODO: try to combine the two ranges - this.ILRange = ilRange; + if (newRange.IsEmpty) { + return; + } + if (this.ILRange.IsEmpty) { + this.ILRange = newRange; + return; + } + if (newRange.Start <= this.ILRange.Start) { + if (newRange.End < this.ILRange.Start) { + this.ILRange = newRange; // use the earlier range + } else { + // join overlapping ranges + this.ILRange = new Interval(newRange.Start, Math.Max(newRange.End, this.ILRange.End)); + } + } else if (newRange.Start <= this.ILRange.End) { + // join overlapping ranges + this.ILRange = new Interval(this.ILRange.Start, Math.Max(newRange.End, this.ILRange.End)); + } } /// @@ -745,17 +761,4 @@ namespace ICSharpCode.Decompiler.IL /// StackType UnderlyingResultType { get; } } - - public class ILAstWritingOptions - { - /// - /// Sugar for logic.not/and/or. - /// - public bool UseLogicOperationSugar { get; set; } - - /// - /// Sugar for ldfld/stfld. - /// - public bool UseFieldSugar { get; set; } - } } diff --git a/ICSharpCode.Decompiler/IL/Instructions/IfInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/IfInstruction.cs index 09ae5a87c..59845c679 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/IfInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/IfInstruction.cs @@ -78,6 +78,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); if (options.UseLogicOperationSugar) { if (MatchLogicAnd(out var lhs, out var rhs)) { output.Write("logic.and("); diff --git a/ICSharpCode.Decompiler/IL/Instructions/InstructionCollection.cs b/ICSharpCode.Decompiler/IL/Instructions/InstructionCollection.cs index d0030a9bb..eb44716a8 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/InstructionCollection.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/InstructionCollection.cs @@ -135,14 +135,14 @@ namespace ICSharpCode.Decompiler.IL /// Returns -1 if the instruction does not exist in the collection. /// /// - /// Runs in O(1) is the item can be found using the Parent/ChildIndex properties. + /// Runs in O(1) if the item can be found using the Parent/ChildIndex properties. /// Otherwise, runs in O(N). /// public int IndexOf(T item) { // If this collection is the item's primary position, we can use ChildIndex: int index = item.ChildIndex - firstChildIndex; - if (index >= 0 && index <= list.Count && list[index] == item) + if (index >= 0 && index < list.Count && list[index] == item) return index; // But we still need to fall back on a full search, because the ILAst might be // in a state where item is in multiple locations. diff --git a/ICSharpCode.Decompiler/IL/Instructions/LdLen.cs b/ICSharpCode.Decompiler/IL/Instructions/LdLen.cs index b654624b0..82f65eb32 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/LdLen.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/LdLen.cs @@ -40,6 +40,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write('.'); output.Write(resultType); diff --git a/ICSharpCode.Decompiler/IL/Instructions/Leave.cs b/ICSharpCode.Decompiler/IL/Instructions/Leave.cs index 7bdabcc26..38e60cbe1 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/Leave.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/Leave.cs @@ -111,6 +111,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); if (targetContainer != null) { output.Write(' '); diff --git a/ICSharpCode.Decompiler/IL/Instructions/LockInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/LockInstruction.cs index f0c1b1ebc..b38c399bc 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/LockInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/LockInstruction.cs @@ -28,6 +28,7 @@ namespace ICSharpCode.Decompiler.IL { public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write("lock ("); OnExpression.WriteTo(output, options); output.WriteLine(") {"); @@ -38,36 +39,4 @@ namespace ICSharpCode.Decompiler.IL output.Write("}"); } } - - /// - /// IL using instruction. - /// Equivalent to: - /// - /// stloc v(resourceExpression) - /// try { - /// body - /// } finally { - /// v?.Dispose(); - /// } - /// - /// - /// - /// The value of v is undefined after the end of the body block. - /// - partial class UsingInstruction - { - public override void WriteTo(ITextOutput output, ILAstWritingOptions options) - { - output.Write("using ("); - Variable.WriteTo(output); - output.Write(" = "); - ResourceExpression.WriteTo(output, options); - output.WriteLine(") {"); - output.Indent(); - Body.WriteTo(output, options); - output.Unindent(); - output.WriteLine(); - output.Write("}"); - } - } } diff --git a/ICSharpCode.Decompiler/IL/Instructions/MemoryInstructions.cs b/ICSharpCode.Decompiler/IL/Instructions/MemoryInstructions.cs index de52425b3..533973dc0 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/MemoryInstructions.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/MemoryInstructions.cs @@ -41,13 +41,15 @@ namespace ICSharpCode.Decompiler.IL { if (options.UseFieldSugar) { if (this.MatchLdFld(out var target, out var field)) { + ILRange.WriteTo(output, options); output.Write("ldfld "); Disassembler.DisassemblerHelpers.WriteOperand(output, field); output.Write('('); - this.target.WriteTo(output, options); + target.WriteTo(output, options); output.Write(')'); return; } else if (this.MatchLdsFld(out field)) { + ILRange.WriteTo(output, options); output.Write("ldsfld "); Disassembler.DisassemblerHelpers.WriteOperand(output, field); return; @@ -63,19 +65,21 @@ namespace ICSharpCode.Decompiler.IL { if (options.UseFieldSugar) { if (this.MatchStFld(out var target, out var field, out var value)) { + ILRange.WriteTo(output, options); output.Write("stfld "); Disassembler.DisassemblerHelpers.WriteOperand(output, field); output.Write('('); - this.target.WriteTo(output, options); + target.WriteTo(output, options); output.Write(", "); - this.value.WriteTo(output, options); + value.WriteTo(output, options); output.Write(')'); return; } else if (this.MatchStsFld(out field, out value)) { + ILRange.WriteTo(output, options); output.Write("stsfld "); Disassembler.DisassemblerHelpers.WriteOperand(output, field); output.Write('('); - this.value.WriteTo(output, options); + value.WriteTo(output, options); output.Write(')'); return; } diff --git a/ICSharpCode.Decompiler/IL/Instructions/NullCoalescingInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/NullCoalescingInstruction.cs index fd4385d1d..04606493a 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/NullCoalescingInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/NullCoalescingInstruction.cs @@ -91,6 +91,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); output.Write("("); valueInst.WriteTo(output, options); diff --git a/ICSharpCode.Decompiler/IL/Instructions/PatternMatching.cs b/ICSharpCode.Decompiler/IL/Instructions/PatternMatching.cs index 26b33c0f6..3382d6926 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/PatternMatching.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/PatternMatching.cs @@ -27,6 +27,11 @@ namespace ICSharpCode.Decompiler.IL return OpCode == OpCode.LdcI4 && ((LdcI4)this).Value == val; } + public bool MatchLdcF(double value) + { + return MatchLdcF(out var v) && v == value; + } + /// /// Matches either LdcI4 or LdcI8. /// @@ -321,6 +326,27 @@ namespace ICSharpCode.Decompiler.IL } } + /// + /// Matches 'comp(arg == ldnull)' + /// + public bool MatchCompEqualsNull(out ILInstruction arg) + { + if (!MatchCompEquals(out var left, out var right)) { + arg = null; + return false; + } + if (right.MatchLdNull()) { + arg = left; + return true; + } else if (left.MatchLdNull()) { + arg = right; + return true; + } else { + arg = null; + return false; + } + } + /// /// Matches comp(left != right) or logic.not(comp(left == right)). /// diff --git a/ICSharpCode.Decompiler/IL/Instructions/SimpleInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/SimpleInstruction.cs index 18f5b6f6f..bb3432835 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/SimpleInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/SimpleInstruction.cs @@ -26,18 +26,31 @@ namespace ICSharpCode.Decompiler.IL { public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); // the non-custom WriteTo would add useless parentheses } } + + public enum NopKind + { + Normal, + Pop + } partial class Nop { public string Comment; + public NopKind Kind; + public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); + if (Kind != NopKind.Normal) { + output.Write("." + Kind.ToString().ToLowerInvariant()); + } if (!string.IsNullOrEmpty(Comment)) { output.Write(" // " + Comment); } @@ -60,6 +73,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); if (!string.IsNullOrEmpty(Message)) { output.Write("(\""); @@ -86,6 +100,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); if (!string.IsNullOrEmpty(Message)) { output.Write("(\""); diff --git a/ICSharpCode.Decompiler/IL/Instructions/StringToInt.cs b/ICSharpCode.Decompiler/IL/Instructions/StringToInt.cs new file mode 100644 index 000000000..9ac94e591 --- /dev/null +++ b/ICSharpCode.Decompiler/IL/Instructions/StringToInt.cs @@ -0,0 +1,46 @@ +// Copyright (c) 2017 Siegfried Pammer +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + + +namespace ICSharpCode.Decompiler.IL +{ + partial class StringToInt + { + public string[] Map { get; } + + public StringToInt(ILInstruction argument, string[] map) + : base(OpCode.StringToInt) + { + this.Argument = argument; + this.Map = map; + } + + public override void WriteTo(ITextOutput output, ILAstWritingOptions options) + { + ILRange.WriteTo(output, options); + output.Write("string.to.int ("); + Argument.WriteTo(output, options); + output.Write(", { "); + for (int i = 0; i < Map.Length; i++) { + if (i > 0) output.Write(", "); + output.Write($"[{i}] = \"{Map[i]}\""); + } + output.Write(" })"); + } + } +} diff --git a/ICSharpCode.Decompiler/IL/Instructions/SwitchInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/SwitchInstruction.cs index 8e22ffe20..7cba520d6 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/SwitchInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/SwitchInstruction.cs @@ -16,6 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +using System; using System.Diagnostics; using System.Linq; using ICSharpCode.Decompiler.Util; @@ -32,15 +33,19 @@ namespace ICSharpCode.Decompiler.IL partial class SwitchInstruction { public static readonly SlotInfo ValueSlot = new SlotInfo("Value", canInlineInto: true); - public static readonly SlotInfo DefaultBodySlot = new SlotInfo("DefaultBody"); public static readonly SlotInfo SectionSlot = new SlotInfo("Section", isCollection: true); - + + /// + /// If the switch instruction is lifted, the value instruction produces a value of type Nullable{T} for some + /// integral type T. The section with SwitchSection.HasNullLabel is called if the value is null. + /// + public bool IsLifted; + public SwitchInstruction(ILInstruction value) : base(OpCode.SwitchInstruction) { this.Value = value; - this.DefaultBody = new Nop(); - this.Sections = new InstructionCollection(this, 2); + this.Sections = new InstructionCollection(this, 1); } ILInstruction value; @@ -52,21 +57,11 @@ namespace ICSharpCode.Decompiler.IL } } - ILInstruction defaultBody; - - public ILInstruction DefaultBody { - get { return this.defaultBody; } - set { - ValidateChild(value); - SetChildInstruction(ref this.defaultBody, value, 1); - } - } - public readonly InstructionCollection Sections; protected override InstructionFlags ComputeFlags() { - var sectionFlags = defaultBody.Flags; + var sectionFlags = InstructionFlags.EndPointUnreachable; // neutral element for CombineBranches() foreach (var section in Sections) { sectionFlags = SemanticHelper.CombineBranches(sectionFlags, section.Flags); } @@ -81,15 +76,16 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { - output.Write("switch ("); + ILRange.WriteTo(output, options); + output.Write("switch"); + if (IsLifted) + output.Write(".lifted"); + output.Write(" ("); value.WriteTo(output, options); output.Write(") "); output.MarkFoldStart("{...}"); output.WriteLine("{"); output.Indent(); - output.Write("default: "); - defaultBody.WriteTo(output, options); - output.WriteLine(); foreach (var section in this.Sections) { section.WriteTo(output, options); output.WriteLine(); @@ -101,34 +97,28 @@ namespace ICSharpCode.Decompiler.IL protected override int GetChildCount() { - return 2 + Sections.Count; + return 1 + Sections.Count; } protected override ILInstruction GetChild(int index) { if (index == 0) return value; - else if (index == 1) - return defaultBody; - return Sections[index - 2]; + return Sections[index - 1]; } protected override void SetChild(int index, ILInstruction value) { if (index == 0) Value = value; - else if (index == 1) - DefaultBody = value; else - Sections[index - 2] = (SwitchSection)value; + Sections[index - 1] = (SwitchSection)value; } protected override SlotInfo GetChildSlot(int index) { if (index == 0) return ValueSlot; - else if (index == 1) - return DefaultBodySlot; return SectionSlot; } @@ -137,7 +127,6 @@ namespace ICSharpCode.Decompiler.IL var clone = new SwitchInstruction(value.Clone()); clone.ILRange = this.ILRange; clone.Value = value.Clone(); - this.DefaultBody = defaultBody.Clone(); clone.Sections.AddRange(this.Sections.Select(h => (SwitchSection)h.Clone())); return clone; } @@ -145,12 +134,19 @@ namespace ICSharpCode.Decompiler.IL internal override void CheckInvariant(ILPhase phase) { base.CheckInvariant(phase); + bool expectNullSection = this.IsLifted; LongSet sets = LongSet.Empty; foreach (var section in Sections) { - Debug.Assert(!section.Labels.IsEmpty); + if (section.HasNullLabel) { + Debug.Assert(expectNullSection, "Duplicate 'case null' or 'case null' in non-lifted switch."); + expectNullSection = false; + } + Debug.Assert(!section.Labels.IsEmpty || section.HasNullLabel); Debug.Assert(!section.Labels.Overlaps(sets)); sets = sets.UnionWith(section.Labels); } + Debug.Assert(sets.SetEquals(LongSet.Universe), "switch does not handle all possible cases"); + Debug.Assert(!expectNullSection, "Lifted switch is missing 'case null'"); } } @@ -162,6 +158,14 @@ namespace ICSharpCode.Decompiler.IL this.Labels = LongSet.Empty; } + /// + /// If true, serves as 'case null' in a lifted switch. + /// + public bool HasNullLabel { get; set; } + + /// + /// The set of labels that cause execution to jump to this switch section. + /// public LongSet Labels { get; set; } protected override InstructionFlags ComputeFlags() @@ -177,8 +181,18 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { - output.Write("case "); - output.Write(Labels.ToString()); + ILRange.WriteTo(output, options); + output.WriteDefinition("case", this, isLocal: true); + output.Write(' '); + if (HasNullLabel) { + output.Write("null"); + if (!Labels.IsEmpty) { + output.Write(", "); + output.Write(Labels.ToString()); + } + } else { + output.Write(Labels.ToString()); + } output.Write(": "); body.WriteTo(output, options); diff --git a/ICSharpCode.Decompiler/IL/Instructions/TryInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/TryInstruction.cs index 033d1cba0..b53611c42 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/TryInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/TryInstruction.cs @@ -67,6 +67,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(".try "); TryBlock.WriteTo(output, options); foreach (var handler in Handlers) { @@ -161,6 +162,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write("catch "); if (variable != null) { output.WriteDefinition(variable.Name, variable); @@ -202,6 +204,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(".try "); TryBlock.WriteTo(output, options); output.Write(" finally "); @@ -297,6 +300,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(".try "); TryBlock.WriteTo(output, options); output.Write(" fault "); diff --git a/ICSharpCode.Decompiler/IL/Instructions/UnaryInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/UnaryInstruction.cs index 52d489a0c..0773fc888 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/UnaryInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/UnaryInstruction.cs @@ -51,6 +51,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { + ILRange.WriteTo(output, options); output.Write(OpCode); if (IsLifted) { output.Write(".lifted"); diff --git a/ICSharpCode.Decompiler/IL/Instructions/UsingInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/UsingInstruction.cs new file mode 100644 index 000000000..2a9e79ce3 --- /dev/null +++ b/ICSharpCode.Decompiler/IL/Instructions/UsingInstruction.cs @@ -0,0 +1,54 @@ +// Copyright (c) 2017 Siegfried Pammer +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + + +namespace ICSharpCode.Decompiler.IL +{ + /// + /// IL using instruction. + /// Equivalent to: + /// + /// stloc v(resourceExpression) + /// try { + /// body + /// } finally { + /// v?.Dispose(); + /// } + /// + /// + /// + /// The value of v is undefined after the end of the body block. + /// + partial class UsingInstruction + { + public override void WriteTo(ITextOutput output, ILAstWritingOptions options) + { + ILRange.WriteTo(output, options); + output.Write("using ("); + Variable.WriteTo(output); + output.Write(" = "); + ResourceExpression.WriteTo(output, options); + output.WriteLine(") {"); + output.Indent(); + Body.WriteTo(output, options); + output.Unindent(); + output.WriteLine(); + output.Write("}"); + } + } +} diff --git a/ICSharpCode.Decompiler/IL/SequencePoint.cs b/ICSharpCode.Decompiler/IL/SequencePoint.cs new file mode 100644 index 000000000..d313fa73d --- /dev/null +++ b/ICSharpCode.Decompiler/IL/SequencePoint.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ICSharpCode.Decompiler.IL +{ + /// + /// A sequence point produced by the decompiler. + /// + public struct SequencePoint + { + /// + /// IL start offset. + /// + public int Offset { get; set; } + + /// + /// IL end offset. + /// + /// + /// This does not get stored in debug information; + /// it is used internally to create hidden sequence points + /// for the IL fragments not covered by any sequence point. + /// + public int EndOffset { get; set; } + + public int StartLine { get; set; } + public int StartColumn { get; set; } + public int EndLine { get; set; } + public int EndColumn { get; set; } + + public bool IsHidden { + get { return StartLine == 0xfeefee && StartLine == EndLine; } + } + + internal void SetHidden() + { + StartLine = EndLine = 0xfeefee; + } + } +} diff --git a/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs b/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs index 6d512e570..3d23b9ab7 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs @@ -58,7 +58,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms public void Run(ILFunction function, ILTransformContext context) { this.context = context; - currentFieldNames = function.Method.DeclaringType.Fields.Select(f => f.Name).ToArray(); + currentFieldNames = function.CecilMethod.DeclaringType.Fields.Select(f => f.Name).ToArray(); reservedVariableNames = new Dictionary(); loopCounters = CollectLoopCounters(function); foreach (var p in function.Descendants.OfType().Select(f => f.Method).SelectMany(m => m.Parameters)) @@ -196,6 +196,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms proposedName = proposedNameForLoads[0]; } } + if (string.IsNullOrEmpty(proposedName) && variable.Kind == VariableKind.StackSlot) { + var proposedNameForStoresFromNewObj = variable.StoreInstructions.OfType() + .Select(expr => GetNameByType(GuessType(variable.Type, expr.Value, context))) + .Except(currentFieldNames).ToList(); + if (proposedNameForStoresFromNewObj.Count == 1) { + proposedName = proposedNameForStoresFromNewObj[0]; + } + } if (string.IsNullOrEmpty(proposedName)) { proposedName = GetNameByType(variable.Type); } @@ -349,6 +357,25 @@ namespace ICSharpCode.Decompiler.IL.Transforms return char.ToLower(name[0]) + name.Substring(1); } + internal static IType GuessType(IType variableType, ILInstruction inst, ILTransformContext context) + { + if (!variableType.IsKnownType(KnownTypeCode.Object)) + return variableType; + + switch (inst) { + case NewObj newObj: + return newObj.Method.DeclaringType; + case Call call: + return call.Method.ReturnType; + case CallVirt callVirt: + return callVirt.Method.ReturnType; + case CallIndirect calli: + return calli.ReturnType; + default: + return context.TypeSystem.Compilation.FindType(inst.ResultType.ToKnownTypeCode()); + } + } + internal static string GenerateForeachVariableName(ILFunction function, ILInstruction valueContext, ILVariable existingVariable = null) { if (function == null) @@ -358,10 +385,15 @@ namespace ICSharpCode.Decompiler.IL.Transforms if (v != existingVariable) AddExistingName(reservedVariableNames, v.Name); } - foreach (var f in function.Method.DeclaringType.Fields.Select(f => f.Name)) + foreach (var f in function.CecilMethod.DeclaringType.Fields.Select(f => f.Name)) AddExistingName(reservedVariableNames, f); string baseName = GetNameFromInstruction(valueContext); + if (string.IsNullOrEmpty(baseName)) { + if (valueContext is LdLoc ldloc && ldloc.Variable.Kind == VariableKind.Parameter) { + baseName = ldloc.Variable.Name; + } + } string proposedName = "item"; if (!string.IsNullOrEmpty(baseName)) { @@ -399,7 +431,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms if (v != existingVariable) AddExistingName(reservedVariableNames, v.Name); } - foreach (var f in function.Method.DeclaringType.Fields.Select(f => f.Name)) + foreach (var f in function.CecilMethod.DeclaringType.Fields.Select(f => f.Name)) AddExistingName(reservedVariableNames, f); string baseName = GetNameByType(type); diff --git a/ICSharpCode.Decompiler/IL/Transforms/CachedDelegateInitialization.cs b/ICSharpCode.Decompiler/IL/Transforms/CachedDelegateInitialization.cs index 6d3b833e1..725f75e8f 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/CachedDelegateInitialization.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/CachedDelegateInitialization.cs @@ -101,9 +101,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms if (!DelegateConstruction.IsDelegateConstruction(value as NewObj, true)) return false; // do not transform if there are other stores/loads of this variable - if (v.StoreCount != 2 || v.LoadCount != 2 || v.AddressCount != 0) + if (v.StoreCount != 2 || v.StoreInstructions.Count != 2 || v.LoadCount != 2 || v.AddressCount != 0) return false; - // do not transform if there is no usage directly aftewards + // do not transform if the first assignment is not assigning null: + var otherStore = v.StoreInstructions.OfType().SingleOrDefault(store => store != storeInst); + if (otherStore == null || !otherStore.Value.MatchLdNull() || !(otherStore.Parent is Block)) + return false; + // do not transform if there is no usage directly afterwards var nextInstruction = inst.Parent.Children.ElementAtOrDefault(inst.ChildIndex + 1); if (nextInstruction == null) return false; @@ -111,6 +115,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms if (usages.Length != 1) return false; context.Step("CachedDelegateInitializationWithLocal", inst); + ((Block)otherStore.Parent).Instructions.Remove(otherStore); inst.ReplaceWith(new StLoc(v, value)); return true; } diff --git a/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs b/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs index ea1e61834..1ef40d116 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs @@ -51,9 +51,12 @@ namespace ICSharpCode.Decompiler.IL.Transforms // dead store to stack if (copiedExpr.Flags == InstructionFlags.None) { // no-op -> delete + context.Step("remove dead store to stack: no-op -> delete", block.Instructions[i]); block.Instructions.RemoveAt(i--); } else { // evaluate the value for its side-effects + context.Step("remove dead store to stack: evaluate the value for its side-effects", block.Instructions[i]); + copiedExpr.AddILRange(block.Instructions[i].ILRange); block.Instructions[i] = copiedExpr; } } else if (v.IsSingleDefinition && CanPerformCopyPropagation(v, copiedExpr)) { diff --git a/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs b/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs index 130349971..62bf0ac17 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs @@ -34,26 +34,24 @@ namespace ICSharpCode.Decompiler.IL.Transforms if (!context.Settings.AnonymousMethods) return; this.context = context; - this.decompilationContext = new SimpleTypeResolveContext(context.TypeSystem.Resolve(function.Method)); + this.decompilationContext = new SimpleTypeResolveContext(function.Method); var orphanedVariableInits = new List(); var targetsToReplace = new List(); foreach (var block in function.Descendants.OfType()) { for (int i = block.Instructions.Count - 1; i >= 0; i--) { context.CancellationToken.ThrowIfCancellationRequested(); foreach (var call in block.Instructions[i].Descendants.OfType()) { - ILInstruction target; - ILFunction f = TransformDelegateConstruction(call, out target); + ILFunction f = TransformDelegateConstruction(call, out ILInstruction target); if (f != null) { - call.Arguments[0].ReplaceWith(new Nop()); + f.AddILRange(call.Arguments[0].ILRange); + f.AddILRange(call.Arguments[1].ILRange); + call.Arguments[0].ReplaceWith(new LdNull()); call.Arguments[1].ReplaceWith(f); - } if (target is IInstructionWithVariableOperand && !target.MatchLdThis()) targetsToReplace.Add((IInstructionWithVariableOperand)target); } - - ILVariable targetVariable; - ILInstruction value; - if (block.Instructions[i].MatchStLoc(out targetVariable, out value)) { + } + if (block.Instructions[i].MatchStLoc(out ILVariable targetVariable, out ILInstruction value)) { var newObj = value as NewObj; // TODO : it is probably not a good idea to remove *all* display-classes // is there a way to minimize the false-positives? @@ -65,7 +63,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms } } foreach (var target in targetsToReplace.OrderByDescending(t => ((ILInstruction)t).ILRange.Start)) { - function.AcceptVisitor(new TransformDisplayClassUsages(target, target.Variable.CaptureScope, orphanedVariableInits)); + function.AcceptVisitor(new TransformDisplayClassUsages(function, target, target.Variable.CaptureScope, orphanedVariableInits)); } foreach (var store in orphanedVariableInits) { if (store.Parent is Block containingBlock) @@ -106,7 +104,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms internal static bool IsPotentialClosure(ILTransformContext context, NewObj inst) { - var decompilationContext = new SimpleTypeResolveContext(context.TypeSystem.Resolve(context.Function.Method)); + var decompilationContext = new SimpleTypeResolveContext(context.Function.Method); return IsPotentialClosure(decompilationContext.CurrentTypeDefinition, inst.Method.DeclaringTypeDefinition); } @@ -226,8 +224,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms public ILInstruction value; } - public TransformDisplayClassUsages(IInstructionWithVariableOperand targetLoad, BlockContainer captureScope, List orphanedVariableInits) + public TransformDisplayClassUsages(ILFunction function, IInstructionWithVariableOperand targetLoad, BlockContainer captureScope, List orphanedVariableInits) { + this.currentFunction = function; this.targetLoad = targetLoad; this.captureScope = captureScope; this.orphanedVariableInits = orphanedVariableInits; @@ -241,17 +240,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms } } - protected internal override void VisitILFunction(ILFunction function) - { - var old = currentFunction; - currentFunction = function; - try { - base.VisitILFunction(function); - } finally { - currentFunction = old; - } - } - protected internal override void VisitStLoc(StLoc inst) { base.VisitStLoc(inst); @@ -271,17 +259,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms protected internal override void VisitStObj(StObj inst) { base.VisitStObj(inst); - ILInstruction target; - IField field; - if (!inst.Target.MatchLdFlda(out target, out field) || !MatchesTargetOrCopyLoad(target)) + if (!inst.Target.MatchLdFlda(out ILInstruction target, out IField field) || !MatchesTargetOrCopyLoad(target)) return; field = (IField)field.MemberDefinition; - DisplayClassVariable info; ILInstruction value; - if (initValues.TryGetValue(field, out info)) { + if (initValues.TryGetValue(field, out DisplayClassVariable info)) { inst.ReplaceWith(new StLoc(info.variable, inst.Value)); } else { - if (inst.Value.MatchLdLoc(out var v) && v.Kind == VariableKind.Parameter) { + if (inst.Value.MatchLdLoc(out var v) && v.Kind == VariableKind.Parameter && currentFunction == v.Function) { // special case for parameters: remove copies of parameter values. orphanedVariableInits.Add(inst); value = inst.Value; @@ -298,12 +283,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms protected internal override void VisitLdObj(LdObj inst) { base.VisitLdObj(inst); - ILInstruction target; - IField field; - if (!inst.Target.MatchLdFlda(out target, out field) || !MatchesTargetOrCopyLoad(target)) + if (!inst.Target.MatchLdFlda(out ILInstruction target, out IField field)) return; - DisplayClassVariable info; - if (!initValues.TryGetValue((IField)field.MemberDefinition, out info)) + if (!initValues.TryGetValue((IField)field.MemberDefinition, out DisplayClassVariable info)) return; inst.ReplaceWith(info.value.Clone()); } @@ -316,8 +298,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms if (!MatchesTargetOrCopyLoad(inst.Target)) return; var field = (IField)inst.Field.MemberDefinition; - DisplayClassVariable info; - if (!initValues.TryGetValue(field, out info)) { + if (!initValues.TryGetValue(field, out DisplayClassVariable info)) { var v = currentFunction.RegisterVariable(VariableKind.Local, field.Type, field.Name); v.CaptureScope = captureScope; inst.ReplaceWith(new LdLoca(v)); @@ -329,6 +310,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms throw new NotImplementedException(); } } + + protected internal override void VisitCompoundAssignmentInstruction(CompoundAssignmentInstruction inst) + { + base.VisitCompoundAssignmentInstruction(inst); + if (inst.Target.MatchLdLoc(out var v)) { + inst.ReplaceWith(new StLoc(v, new BinaryNumericInstruction(inst.Operator, inst.Target, inst.Value, inst.CheckForOverflow, inst.Sign))); + } + } } #endregion } diff --git a/ICSharpCode.Decompiler/IL/Transforms/DetectCatchWhenConditionBlocks.cs b/ICSharpCode.Decompiler/IL/Transforms/DetectCatchWhenConditionBlocks.cs index 14bc7ac4e..872d0acd7 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/DetectCatchWhenConditionBlocks.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/DetectCatchWhenConditionBlocks.cs @@ -41,10 +41,21 @@ namespace ICSharpCode.Decompiler.IL.Transforms // br whenConditionBlock // } var instructions = container.EntryPoint.Instructions; - ((StLoc)instructions[0]).Value = exceptionSlot; - instructions[1].ReplaceWith(new Branch(whenConditionBlock)); - instructions.RemoveAt(2); - container.SortBlocks(deleteUnreachableBlocks: true); + if (instructions.Count == 3) { + // stloc temp(isinst exceptionType(ldloc exceptionVar)) + // if (comp(ldloc temp != ldnull)) br whenConditionBlock + // br falseBlock + ((StLoc)instructions[0]).Value = exceptionSlot; + instructions[1].ReplaceWith(new Branch(whenConditionBlock)); + instructions.RemoveAt(2); + container.SortBlocks(deleteUnreachableBlocks: true); + } else if (instructions.Count == 2) { + // if (comp(isinst exceptionType(ldloc exceptionVar) != ldnull)) br whenConditionBlock + // br falseBlock + instructions[0].ReplaceWith(new Branch(whenConditionBlock)); + instructions.RemoveAt(1); + container.SortBlocks(deleteUnreachableBlocks: true); + } } } } @@ -61,21 +72,42 @@ namespace ICSharpCode.Decompiler.IL.Transforms exceptionType = null; exceptionSlot = null; whenConditionBlock = null; - if (entryPoint == null || entryPoint.IncomingEdgeCount != 1 || entryPoint.Instructions.Count != 3) + if (entryPoint == null || entryPoint.IncomingEdgeCount != 1) return false; - if (!entryPoint.Instructions[0].MatchStLoc(out var temp, out var isinst) || - temp.Kind != VariableKind.StackSlot || !isinst.MatchIsInst(out exceptionSlot, out exceptionType)) - return false; - if (!exceptionSlot.MatchLdLoc(out var exceptionVar) || exceptionVar.Kind != VariableKind.Exception) - return false; - if (!entryPoint.Instructions[1].MatchIfInstruction(out var condition, out var branch)) - return false; - if (!condition.MatchCompNotEquals(out var left, out var right)) - return false; - if (!entryPoint.Instructions[2].MatchBranch(out var falseBlock) || !MatchFalseBlock(container, falseBlock, out var returnVar, out var exitBlock)) - return false; - if ((left.MatchLdNull() && right.MatchLdLoc(temp)) || (right.MatchLdNull() && left.MatchLdLoc(temp))) { - return branch.MatchBranch(out whenConditionBlock); + if (entryPoint.Instructions.Count == 3) { + // stloc temp(isinst exceptionType(ldloc exceptionVar)) + // if (comp(ldloc temp != ldnull)) br whenConditionBlock + // br falseBlock + if (!entryPoint.Instructions[0].MatchStLoc(out var temp, out var isinst) || + temp.Kind != VariableKind.StackSlot || !isinst.MatchIsInst(out exceptionSlot, out exceptionType)) + return false; + if (!exceptionSlot.MatchLdLoc(out var exceptionVar) || exceptionVar.Kind != VariableKind.Exception) + return false; + if (!entryPoint.Instructions[1].MatchIfInstruction(out var condition, out var branch)) + return false; + if (!condition.MatchCompNotEquals(out var left, out var right)) + return false; + if (!entryPoint.Instructions[2].MatchBranch(out var falseBlock) || !MatchFalseBlock(container, falseBlock, out var returnVar, out var exitBlock)) + return false; + if ((left.MatchLdNull() && right.MatchLdLoc(temp)) || (right.MatchLdNull() && left.MatchLdLoc(temp))) { + return branch.MatchBranch(out whenConditionBlock); + } + } else if (entryPoint.Instructions.Count == 2) { + // if (comp(isinst exceptionType(ldloc exceptionVar) != ldnull)) br whenConditionBlock + // br falseBlock + if (!entryPoint.Instructions[0].MatchIfInstruction(out var condition, out var branch)) + return false; + if (!condition.MatchCompNotEquals(out var left, out var right)) + return false; + if (!entryPoint.Instructions[1].MatchBranch(out var falseBlock) || !MatchFalseBlock(container, falseBlock, out var returnVar, out var exitBlock)) + return false; + if (!left.MatchIsInst(out exceptionSlot, out exceptionType)) + return false; + if (!exceptionSlot.MatchLdLoc(out var exceptionVar) || exceptionVar.Kind != VariableKind.Exception) + return false; + if (right.MatchLdNull()) { + return branch.MatchBranch(out whenConditionBlock); + } } return false; } diff --git a/ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs b/ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs index c48bc0655..bba216c13 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs @@ -54,9 +54,30 @@ namespace ICSharpCode.Decompiler.IL.Transforms if (inst.Target.MatchLdLoca(out ILVariable v) && TypeUtils.IsCompatibleTypeForMemoryAccess(new ByReferenceType(v.Type), inst.Type) && inst.UnalignedPrefix == 0 - && !inst.IsVolatile) { + && !inst.IsVolatile) + { context.Step($"stobj(ldloca {v.Name}, ...) => stloc {v.Name}(...)", inst); - inst.ReplaceWith(new StLoc(v, inst.Value)); + inst.ReplaceWith(new StLoc(v, inst.Value) { ILRange = inst.ILRange }); + return true; + } + return false; + } + + protected internal override void VisitLdObj(LdObj inst) + { + base.VisitLdObj(inst); + LdObjToLdLoc(inst, context); + } + + internal static bool LdObjToLdLoc(LdObj inst, ILTransformContext context) + { + if (inst.Target.MatchLdLoca(out ILVariable v) + && TypeUtils.IsCompatibleTypeForMemoryAccess(new ByReferenceType(v.Type), inst.Type) + && inst.UnalignedPrefix == 0 + && !inst.IsVolatile) + { + context.Step($"ldobj(ldloca {v.Name}, ...) => ldloc {v.Name}(...)", inst); + inst.ReplaceWith(new LdLoc(v) { ILRange = inst.ILRange }); return true; } return false; @@ -83,6 +104,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms var newObj = new NewObj(inst.Method); newObj.ILRange = inst.ILRange; newObj.Arguments.AddRange(inst.Arguments.Skip(1)); + newObj.ILStackWasEmpty = inst.ILStackWasEmpty; var expr = new StObj(inst.Arguments[0], newObj, inst.Method.DeclaringType); inst.ReplaceWith(expr); return expr; diff --git a/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs b/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs index 4b97e7ac0..f0011a9cf 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs @@ -111,16 +111,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms && inst.Sign == Sign.Unsigned && (inst.Kind == ComparisonKind.GreaterThan || inst.Kind == ComparisonKind.LessThanOrEqual)) { - ILInstruction array; - if (inst.Left.MatchLdLen(StackType.I, out array)) { - // comp.unsigned(ldlen array > conv i4->i(ldc.i4 0)) - // => comp(ldlen.i4 array > ldc.i4 0) - // This is a special case where the C# compiler doesn't generate conv.i4 after ldlen. - context.Step("comp(ldlen.i4 array > ldc.i4 0)", inst); - inst.InputType = StackType.I4; - inst.Left.ReplaceWith(new LdLen(StackType.I4, array) { ILRange = inst.Left.ILRange }); - inst.Right = rightWithoutConv; - } if (inst.Kind == ComparisonKind.GreaterThan) { context.Step("comp.unsigned(left > ldc.i4 0) => comp(left != ldc.i4 0)", inst); inst.Kind = ComparisonKind.Inequality; @@ -132,6 +122,16 @@ namespace ICSharpCode.Decompiler.IL.Transforms VisitComp(inst); return; } + } else if (rightWithoutConv.MatchLdcI4(0) && inst.Kind.IsEqualityOrInequality()) { + if (inst.Left.MatchLdLen(StackType.I, out ILInstruction array)) { + // comp.unsigned(ldlen array == conv i4->i(ldc.i4 0)) + // => comp(ldlen.i4 array == ldc.i4 0) + // This is a special case where the C# compiler doesn't generate conv.i4 after ldlen. + context.Step("comp(ldlen.i4 array == ldc.i4 0)", inst); + inst.InputType = StackType.I4; + inst.Left.ReplaceWith(new LdLen(StackType.I4, array) { ILRange = inst.Left.ILRange }); + inst.Right = rightWithoutConv; + } } if (inst.Right.MatchLdNull() && inst.Left.MatchBox(out arg, out var type) && type.Kind == TypeKind.TypeParameter) { @@ -275,7 +275,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms } return false; } - + + protected internal override void VisitLdObj(LdObj inst) + { + base.VisitLdObj(inst); + EarlyExpressionTransforms.LdObjToLdLoc(inst, context); + } + protected internal override void VisitStObj(StObj inst) { base.VisitStObj(inst); diff --git a/ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs b/ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs index d5dd01d6e..70d7e5f9f 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs @@ -64,8 +64,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms static bool IsCatchWhenBlock(Block block) { - return block.Parent is BlockContainer container && container.Parent is TryCatchHandler handler - && handler.Filter == container && block == container.EntryPoint; + var container = BlockContainer.FindClosestContainer(block); + return container?.Parent is TryCatchHandler handler + && handler.Filter == container; } /// @@ -292,6 +293,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms parent = parent.Parent; } return parent == next; + case OpCode.BlockContainer: + if (((BlockContainer)next).EntryPoint.Instructions[0] is SwitchInstruction switchInst) { + next = switchInst; + goto case OpCode.SwitchInstruction; + } else { + return false; + } case OpCode.SwitchInstruction: return parent == next || (parent.MatchBinaryNumericInstruction(BinaryNumericOperator.Sub) && parent.Parent == next); default: @@ -333,6 +341,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms default: return false; } + } else if (expr is BlockContainer container && container.EntryPoint.IncomingEdgeCount == 1) { + // Possibly a switch-container, allow inlining into the switch instruction: + return FindLoadInNext(container.EntryPoint.Instructions[0], v, expressionBeingMoved, out loadInst) ?? false; + // If FindLoadInNext() returns null, we still can't continue searching + // because we can't inline over the remainder of the blockcontainer. } foreach (var child in expr.Children) { if (!child.SlotInfo.CanInlineInto) diff --git a/ICSharpCode.Decompiler/IL/Transforms/InlineReturnTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/InlineReturnTransform.cs new file mode 100644 index 000000000..e9c53f8ca --- /dev/null +++ b/ICSharpCode.Decompiler/IL/Transforms/InlineReturnTransform.cs @@ -0,0 +1,95 @@ +// Copyright (c) 2017 Siegfried Pammer +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ICSharpCode.Decompiler.IL.Transforms +{ + /// + /// This transform duplicates return blocks if they return a local variable that was assigned right before the return. + /// + class InlineReturnTransform : IILTransform + { + public void Run(ILFunction function, ILTransformContext context) + { + var instructionsToModify = new List<(BlockContainer, Block, Branch)>(); + + // Process all leave instructions in a leave-block, that is a block consisting solely of a leave instruction. + foreach (var leave in function.Descendants.OfType()) { + if (!(leave.Parent is Block leaveBlock && leaveBlock.Instructions.Count == 1)) + continue; + // Skip, if the leave instruction has no value or the value is not a load of a local variable. + if (!leave.Value.MatchLdLoc(out var returnVar) || returnVar.Kind != VariableKind.Local) + continue; + // If all instructions can be modified, add item to the global list. + if (CanModifyInstructions(returnVar, leaveBlock, out var list)) + instructionsToModify.AddRange(list); + } + + foreach (var (container, b, br) in instructionsToModify) { + Block block = b; + // if there is only one branch to this return block, move it to the matching container. + // otherwise duplicate the return block. + if (block.IncomingEdgeCount == 1) { + block.Remove(); + } else { + block = (Block)block.Clone(); + } + container.Blocks.Add(block); + // adjust the target of the branch to the newly created block. + br.TargetBlock = block; + } + } + + /// + /// Determines a list of all store instructions that write to a given . + /// Returns false if any of these instructions does not meet the following criteria: + /// - must be a stloc + /// - must be a direct child of a block + /// - must be the penultimate instruction + /// - must be followed by a branch instruction to + /// - must have a BlockContainer as ancestor. + /// Returns true, if all instructions meet these criteria, and contains a list of 3-tuples. + /// Each tuple consists of the target block container, the leave block, and the branch instruction that should be modified. + /// + static bool CanModifyInstructions(ILVariable returnVar, Block leaveBlock, out List<(BlockContainer, Block, Branch)> instructionsToModify) + { + instructionsToModify = new List<(BlockContainer, Block, Branch)>(); + foreach (var inst in returnVar.StoreInstructions) { + if (!(inst is StLoc store)) + return false; + if (!(store.Parent is Block storeBlock)) + return false; + if (store.ChildIndex + 2 != storeBlock.Instructions.Count) + return false; + if (!(storeBlock.Instructions[store.ChildIndex + 1] is Branch br)) + return false; + if (br.TargetBlock != leaveBlock) + return false; + var targetBlockContainer = BlockContainer.FindClosestContainer(store); + if (targetBlockContainer == null) + return false; + instructionsToModify.Add((targetBlockContainer, leaveBlock, br)); + } + + return true; + } + } +} diff --git a/ICSharpCode.Decompiler/IL/Transforms/LockTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/LockTransform.cs index e09c0a2b8..cc497af74 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/LockTransform.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/LockTransform.cs @@ -83,7 +83,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms context.Step("LockTransformV2", block); block.Instructions.RemoveAt(i - 1); block.Instructions.RemoveAt(i - 2); - body.ReplaceWith(new LockInstruction(objectStore.Value, body.TryBlock)); + body.ReplaceWith(new LockInstruction(objectStore.Value, body.TryBlock) { ILRange = objectStore.ILRange }); return true; } @@ -127,7 +127,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms context.Step("LockTransformV4", block); block.Instructions.RemoveAt(i - 1); tryContainer.EntryPoint.Instructions.RemoveAt(0); - body.ReplaceWith(new LockInstruction(objectStore.Value, body.TryBlock)); + body.ReplaceWith(new LockInstruction(objectStore.Value, body.TryBlock) { ILRange = objectStore.ILRange }); return true; } @@ -173,7 +173,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms block.Instructions.RemoveAt(i - 1); block.Instructions.RemoveAt(i - 2); tryContainer.EntryPoint.Instructions.RemoveAt(0); - body.ReplaceWith(new LockInstruction(objectStore.Value, body.TryBlock)); + body.ReplaceWith(new LockInstruction(objectStore.Value, body.TryBlock) { ILRange = objectStore.ILRange }); return true; } diff --git a/ICSharpCode.Decompiler/IL/Transforms/NullableLiftingTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/NullableLiftingTransform.cs index 8d11720be..20c63b6c8 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/NullableLiftingTransform.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/NullableLiftingTransform.cs @@ -102,7 +102,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms #region AnalyzeCondition bool AnalyzeCondition(ILInstruction condition) { - if (MatchHasValueCall(condition, out var v)) { + if (MatchHasValueCall(condition, out ILVariable v)) { if (nullableVars == null) nullableVars = new List(); nullableVars.Add(v); @@ -387,9 +387,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms // Comparing two nullables: HasValue comparison must be the same operator as the Value comparison if ((hasValueTestNegated ? hasValueComp.Kind.Negate() : hasValueComp.Kind) != newComparisonKind) return null; - if (!MatchHasValueCall(hasValueComp.Left, out var leftVar)) + if (!MatchHasValueCall(hasValueComp.Left, out ILVariable leftVar)) return null; - if (!MatchHasValueCall(hasValueComp.Right, out var rightVar)) + if (!MatchHasValueCall(hasValueComp.Right, out ILVariable rightVar)) return null; nullableVars = new List { leftVar }; var (left, leftBits) = DoLift(valueComp.Left); @@ -401,7 +401,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms context.Step("NullableLiftingTransform: C# (in)equality comparison", valueComp.Instruction); return valueComp.MakeLifted(newComparisonKind, left, right); } - } else if (newComparisonKind == ComparisonKind.Equality && !hasValueTestNegated && MatchHasValueCall(hasValueTest, out var v)) { + } else if (newComparisonKind == ComparisonKind.Equality && !hasValueTestNegated && MatchHasValueCall(hasValueTest, out ILVariable v)) { // Comparing nullable with non-nullable -> we can fall back to the normal comparison code. nullableVars = new List { v }; return LiftCSharpComparison(valueComp, newComparisonKind); @@ -461,13 +461,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms // else // ldc.i4 0 - if (!MatchHasValueCall(hasValueComp.Left, out var nullable1)) + if (!MatchHasValueCall(hasValueComp.Left, out ILVariable nullable1)) return null; - if (!MatchHasValueCall(hasValueComp.Right, out var nullable2)) + if (!MatchHasValueCall(hasValueComp.Right, out ILVariable nullable2)) return null; if (!nestedIfInst.MatchIfInstructionPositiveCondition(out var condition, out var trueInst, out var falseInst)) return null; - if (!MatchHasValueCall(condition, out var nullable)) + if (!MatchHasValueCall(condition, out ILVariable nullable)) return null; if (nullable != nullable1 && nullable != nullable2) return null; @@ -516,7 +516,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms if (trueInst.MatchIfInstructionPositiveCondition(out var nestedCondition, out var nestedTrue, out var nestedFalse)) { // Sometimes Roslyn generates pointless conditions like: // if (nullable.HasValue && (!nullable.HasValue || nullable.GetValueOrDefault() == b)) - if (MatchHasValueCall(nestedCondition, out var v) && nullableVars.Contains(v)) { + if (MatchHasValueCall(nestedCondition, out ILVariable v) && nullableVars.Contains(v)) { trueInst = nestedTrue; } } @@ -758,11 +758,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms #region Match...Call /// - /// Matches 'call get_HasValue(ldloca v)' + /// Matches 'call get_HasValue(arg)' /// - internal static bool MatchHasValueCall(ILInstruction inst, out ILVariable v) + internal static bool MatchHasValueCall(ILInstruction inst, out ILInstruction arg) { - v = null; + arg = null; if (!(inst is Call call)) return false; if (call.Arguments.Count != 1) @@ -771,7 +771,20 @@ namespace ICSharpCode.Decompiler.IL.Transforms return false; if (call.Method.DeclaringTypeDefinition?.KnownTypeCode != KnownTypeCode.NullableOfT) return false; - return call.Arguments[0].MatchLdLoca(out v); + arg = call.Arguments[0]; + return true; + } + + /// + /// Matches 'call get_HasValue(ldloca v)' + /// + internal static bool MatchHasValueCall(ILInstruction inst, out ILVariable v) + { + if (MatchHasValueCall(inst, out ILInstruction arg)) { + return arg.MatchLdLoca(out v); + } + v = null; + return false; } /// @@ -779,7 +792,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms /// internal static bool MatchHasValueCall(ILInstruction inst, ILVariable v) { - return MatchHasValueCall(inst, out var v2) && v == v2; + return MatchHasValueCall(inst, out ILVariable v2) && v == v2; } /// @@ -811,7 +824,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms /// /// Matches 'call Nullable{T}.GetValueOrDefault(arg)' /// - static bool MatchGetValueOrDefault(ILInstruction inst, out ILInstruction arg) + internal static bool MatchGetValueOrDefault(ILInstruction inst, out ILInstruction arg) { arg = null; if (!(inst is Call call)) diff --git a/ICSharpCode.Decompiler/IL/Transforms/ProxyCallReplacer.cs b/ICSharpCode.Decompiler/IL/Transforms/ProxyCallReplacer.cs new file mode 100644 index 000000000..717d880cc --- /dev/null +++ b/ICSharpCode.Decompiler/IL/Transforms/ProxyCallReplacer.cs @@ -0,0 +1,79 @@ +using System.Diagnostics; +using System.Linq; +using ICSharpCode.Decompiler.TypeSystem; +using Mono.Cecil; + +namespace ICSharpCode.Decompiler.IL.Transforms +{ + class ProxyCallReplacer : IILTransform + { + ILTransformContext context; + + public void Run(ILFunction function, ILTransformContext context) + { + this.context = context; + foreach (var inst in function.Descendants.OfType()) { + MethodDefinition methodDef = context.TypeSystem.GetCecil(inst.Method) as MethodDefinition; + if (methodDef != null && methodDef.Body != null) { + if (inst.Method.IsCompilerGeneratedOrIsInCompilerGeneratedClass()) { + // partially copied from CSharpDecompiler + var specializingTypeSystem = this.context.TypeSystem.GetSpecializingTypeSystem(this.context.TypeSystem.Compilation.TypeResolveContext); + var ilReader = new ILReader(specializingTypeSystem); + System.Threading.CancellationToken cancellationToken = new System.Threading.CancellationToken(); + var proxyFunction = ilReader.ReadIL(methodDef.Body, cancellationToken); + var transformContext = new ILTransformContext(proxyFunction, specializingTypeSystem, this.context.Settings) { + CancellationToken = cancellationToken + }; + foreach (var transform in CSharp.CSharpDecompiler.GetILTransforms()) { + if (transform.GetType() != typeof(ProxyCallReplacer)) { // don't call itself on itself + cancellationToken.ThrowIfCancellationRequested(); + transform.Run(proxyFunction, transformContext); + } + } + + if (!(proxyFunction.Body is BlockContainer blockContainer)) + return; + if (blockContainer.Blocks.Count != 1) + return; + var block = blockContainer.Blocks[0]; + Call call = null; + if (block.Instructions.Count == 1) { + // leave IL_0000 (call Test(ldloc this, ldloc A_1)) + if (!block.Instructions[0].MatchLeave(blockContainer, out ILInstruction returnValue)) + return; + call = returnValue as Call; + } else if (block.Instructions.Count == 2) { + // call Test(ldloc this, ldloc A_1) + // leave IL_0000(nop) + call = block.Instructions[0] as Call; + if (!block.Instructions[1].MatchLeave(blockContainer, out ILInstruction returnValue)) + return; + if (!returnValue.MatchNop()) + return; + } + if (call == null) { + return; + } + if (call.Method.IsConstructor) + return; + + // check if original arguments are only correct ldloc calls + for (int i = 0; i < call.Arguments.Count; i++) { + var originalArg = call.Arguments[i]; + if (!originalArg.MatchLdLoc(out ILVariable var) || + var.Kind != VariableKind.Parameter || + var.Index != i - 1) { + return; + } + } + + Call newInst = (Call)call.Clone(); + + newInst.Arguments.ReplaceList(inst.Arguments); + inst.ReplaceWith(newInst); + } + } + } + } + } +} diff --git a/ICSharpCode.Decompiler/IL/Transforms/SwitchOnNullableTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/SwitchOnNullableTransform.cs new file mode 100644 index 000000000..af7cc6ae7 --- /dev/null +++ b/ICSharpCode.Decompiler/IL/Transforms/SwitchOnNullableTransform.cs @@ -0,0 +1,186 @@ +// Copyright (c) 2017 Siegfried Pammer +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; +using ICSharpCode.Decompiler.IL.ControlFlow; +using ICSharpCode.Decompiler.TypeSystem; +using ICSharpCode.Decompiler.Util; + +namespace ICSharpCode.Decompiler.IL.Transforms +{ + /// + /// Detects switch-on-nullable patterns employed by the C# compiler and transforms them to an ILAst-switch-instruction. + /// + class SwitchOnNullableTransform : IILTransform + { + public void Run(ILFunction function, ILTransformContext context) + { + if (!context.Settings.LiftNullables) + return; + + HashSet changedContainers = new HashSet(); + + foreach (var block in function.Descendants.OfType()) { + bool changed = false; + for (int i = block.Instructions.Count - 1; i >= 0; i--) { + SwitchInstruction newSwitch; + if (MatchSwitchOnNullable(block.Instructions, i, out newSwitch)) { + block.Instructions[i + 1].ReplaceWith(newSwitch); + block.Instructions.RemoveRange(i - 2, 3); + i -= 2; + changed = true; + continue; + } + if (MatchRoslynSwitchOnNullable(block.Instructions, i, out newSwitch)) { + block.Instructions[i - 1].ReplaceWith(newSwitch); + block.Instructions.RemoveRange(i, 2); + i--; + changed = true; + continue; + } + } + if (!changed) continue; + SwitchDetection.SimplifySwitchInstruction(block); + if (block.Parent is BlockContainer container) + changedContainers.Add(container); + } + + foreach (var container in changedContainers) + container.SortBlocks(deleteUnreachableBlocks: true); + } + + /// + /// Matches legacy C# switch on nullable. + /// + bool MatchSwitchOnNullable(InstructionCollection instructions, int i, out SwitchInstruction newSwitch) + { + newSwitch = null; + // match first block: + // stloc tmp(ldloca switchValueVar) + // stloc switchVariable(call GetValueOrDefault(ldloc tmp)) + // if (logic.not(call get_HasValue(ldloc tmp))) br nullCaseBlock + // br switchBlock + if (i < 2) return false; + if (!instructions[i - 2].MatchStLoc(out var tmp, out var ldloca) || + !instructions[i - 1].MatchStLoc(out var switchVariable, out var getValueOrDefault) || + !instructions[i].MatchIfInstruction(out var condition, out var trueInst)) + return false; + if (!tmp.IsSingleDefinition || tmp.LoadCount != 2) + return false; + if (!switchVariable.IsSingleDefinition || switchVariable.LoadCount != 1) + return false; + if (!instructions[i + 1].MatchBranch(out var switchBlock) || !trueInst.MatchBranch(out var nullCaseBlock)) + return false; + if (!ldloca.MatchLdLoca(out var switchValueVar)) + return false; + if (!condition.MatchLogicNot(out var getHasValue)) + return false; + if (!NullableLiftingTransform.MatchGetValueOrDefault(getValueOrDefault, out ILInstruction getValueOrDefaultArg)) + return false; + if (!NullableLiftingTransform.MatchHasValueCall(getHasValue, out ILInstruction getHasValueArg)) + return false; + if (!(getHasValueArg.MatchLdLoc(tmp) && getValueOrDefaultArg.MatchLdLoc(tmp))) + return false; + // match second block: switchBlock + // switch (ldloc switchVariable) { + // case [0..1): br caseBlock1 + // ... more cases ... + // case [long.MinValue..0),[1..5),[6..10),[11..long.MaxValue]: br defaultBlock + // } + if (switchBlock.Instructions.Count != 1 || switchBlock.IncomingEdgeCount != 1) + return false; + if (!(switchBlock.Instructions[0] is SwitchInstruction switchInst)) + return false; + newSwitch = BuildLiftedSwitch(nullCaseBlock, switchInst, new LdLoc(switchValueVar)); + return true; + } + + static SwitchInstruction BuildLiftedSwitch(Block nullCaseBlock, SwitchInstruction switchInst, ILInstruction switchValue) + { + SwitchInstruction newSwitch = new SwitchInstruction(switchValue); + newSwitch.IsLifted = true; + newSwitch.Sections.AddRange(switchInst.Sections); + newSwitch.Sections.Add(new SwitchSection { Body = new Branch(nullCaseBlock), HasNullLabel = true }); + return newSwitch; + } + + /// + /// Matches Roslyn C# switch on nullable. + /// + bool MatchRoslynSwitchOnNullable(InstructionCollection instructions, int i, out SwitchInstruction newSwitch) + { + newSwitch = null; + // match first block: + // stloc tmp(ldloc switchValueVar) + // if (logic.not(call get_HasValue(ldloca tmp))) br nullCaseBlock + // br switchBlock + if (i < 1) return false; + if (!instructions[i - 1].MatchStLoc(out var tmp, out var switchValue) || + !instructions[i].MatchIfInstruction(out var condition, out var trueInst)) + return false; + if (tmp.StoreCount != 1 || tmp.AddressCount != 2 || tmp.LoadCount != 0) + return false; + if (!instructions[i + 1].MatchBranch(out var switchBlock) || !trueInst.MatchBranch(out var nullCaseBlock)) + return false; + if (!condition.MatchLogicNot(out var getHasValue) || !NullableLiftingTransform.MatchHasValueCall(getHasValue, out ILVariable target1) || target1 != tmp) + return false; + // match second block: switchBlock + // note: I have seen cases where switchVar is inlined into the switch. + // stloc switchVar(call GetValueOrDefault(ldloca tmp)) + // switch (ldloc switchVar) { + // case [0..1): br caseBlock1 + // ... more cases ... + // case [long.MinValue..0),[1..5),[6..10),[11..long.MaxValue]: br defaultBlock + // } + if (switchBlock.IncomingEdgeCount != 1) + return false; + SwitchInstruction switchInst; + switch (switchBlock.Instructions.Count) { + case 2: { + // this is the normal case described by the pattern above + if (!switchBlock.Instructions[0].MatchStLoc(out var switchVar, out var getValueOrDefault)) + return false; + if (!switchVar.IsSingleDefinition || switchVar.LoadCount != 1) + return false; + if (!NullableLiftingTransform.MatchGetValueOrDefault(getValueOrDefault, tmp)) + return false; + if (!(switchBlock.Instructions[1] is SwitchInstruction si)) + return false; + switchInst = si; + break; + } + case 1: { + // this is the special case where `call GetValueOrDefault(ldloca tmp)` is inlined into the switch. + if (!(switchBlock.Instructions[0] is SwitchInstruction si)) + return false; + if (!NullableLiftingTransform.MatchGetValueOrDefault(si.Value, tmp)) + return false; + switchInst = si; + break; + } + default: { + return false; + } + } + newSwitch = BuildLiftedSwitch(nullCaseBlock, switchInst, switchValue); + return true; + } + } +} diff --git a/ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs new file mode 100644 index 000000000..7dffaf2b4 --- /dev/null +++ b/ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs @@ -0,0 +1,614 @@ +// Copyright (c) 2017 Siegfried Pammer +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; +using ICSharpCode.Decompiler.IL.ControlFlow; +using ICSharpCode.Decompiler.TypeSystem; +using ICSharpCode.Decompiler.Util; + +namespace ICSharpCode.Decompiler.IL.Transforms +{ + /// + /// Detects switch-on-string patterns employed by the C# compiler and transforms them to an ILAst-switch-instruction. + /// + class SwitchOnStringTransform : IILTransform + { + public void Run(ILFunction function, ILTransformContext context) + { + if (!context.Settings.SwitchStatementOnString) + return; + + HashSet changedContainers = new HashSet(); + + foreach (var block in function.Descendants.OfType()) { + bool changed = false; + for (int i = block.Instructions.Count - 1; i >= 0; i--) { + if (SimplifyCascadingIfStatements(block.Instructions, ref i)) { + changed = true; + continue; + } + if (MatchLegacySwitchOnStringWithHashtable(block.Instructions, ref i)) { + changed = true; + continue; + } + if (MatchLegacySwitchOnStringWithDict(block.Instructions, ref i)) { + changed = true; + continue; + } + if (MatchRoslynSwitchOnString(block.Instructions, ref i)) { + changed = true; + continue; + } + } + if (!changed) continue; + SwitchDetection.SimplifySwitchInstruction(block); + if (block.Parent is BlockContainer container) + changedContainers.Add(container); + } + + foreach (var container in changedContainers) + container.SortBlocks(deleteUnreachableBlocks: true); + } + + bool SimplifyCascadingIfStatements(InstructionCollection instructions, ref int i) + { + if (i < 1) return false; + // match first block: checking switch-value for null or first value (Roslyn) + // if (call op_Equality(ldloc switchValueVar, ldstr value)) br firstBlock + // -or- + // if (comp(ldloc switchValueVar == ldnull)) br defaultBlock + if (!(instructions[i].MatchIfInstruction(out var condition, out var firstBlockJump))) + return false; + if (!firstBlockJump.MatchBranch(out var firstBlock)) + return false; + List<(string, Block)> values = new List<(string, Block)>(); + ILInstruction switchValue = null; + + // match call to operator ==(string, string) + if (!MatchStringEqualityComparison(condition, out var switchValueVar, out string firstBlockValue)) + return false; + values.Add((firstBlockValue, firstBlock)); + + bool extraLoad = false; + if (instructions[i - 1].MatchStLoc(switchValueVar, out switchValue)) { + // stloc switchValueVar(switchValue) + // if (call op_Equality(ldloc switchValueVar, ldstr value)) br firstBlock + } else if (instructions[i - 1] is StLoc stloc && stloc.Value.MatchLdLoc(switchValueVar)) { + // in case of optimized legacy code there are two stlocs: + // stloc otherSwitchValueVar(ldloc switchValue) + // stloc switchValueVar(ldloc otherSwitchValueVar) + // if (call op_Equality(ldloc otherSwitchValueVar, ldstr value)) br firstBlock + var otherSwitchValueVar = switchValueVar; + switchValueVar = stloc.Variable; + if (i >= 2 && instructions[i - 2].MatchStLoc(otherSwitchValueVar, out switchValue) + && otherSwitchValueVar.IsSingleDefinition && otherSwitchValueVar.LoadCount == 2) + { + extraLoad = true; + } else { + switchValue = new LdLoc(otherSwitchValueVar); + } + } else { + switchValue = new LdLoc(switchValueVar); + } + // if instruction must be followed by a branch to the next case + if (!(instructions.ElementAtOrDefault(i + 1) is Branch nextCaseJump)) + return false; + // extract all cases and add them to the values list. + Block currentCaseBlock = nextCaseJump.TargetBlock; + Block nextCaseBlock; + while ((nextCaseBlock = MatchCaseBlock(currentCaseBlock, switchValueVar, out string value, out Block block)) != null) { + values.Add((value, block)); + currentCaseBlock = nextCaseBlock; + } + // We didn't find enough cases, exit + if (values.Count < 3) + return false; + // if the switchValueVar is used in other places as well, do not eliminate the store. + bool keepAssignmentBefore = false; + if (switchValueVar.LoadCount > values.Count) { + keepAssignmentBefore = true; + switchValue = new LdLoc(switchValueVar); + } + var sections = new List(values.SelectWithIndex((index, b) => new SwitchSection { Labels = new LongSet(index), Body = new Branch(b.Item2) })); + sections.Add(new SwitchSection { Labels = new LongSet(new LongInterval(0, sections.Count)).Invert(), Body = new Branch(currentCaseBlock) }); + var stringToInt = new StringToInt(switchValue, values.SelectArray(item => item.Item1)); + var inst = new SwitchInstruction(stringToInt); + inst.Sections.AddRange(sections); + if (extraLoad) { + instructions[i - 2].ReplaceWith(inst); + instructions.RemoveRange(i - 1, 3); + i -= 2; + } else { + if (keepAssignmentBefore) { + instructions[i].ReplaceWith(inst); + instructions.RemoveAt(i + 1); + } else { + instructions[i - 1].ReplaceWith(inst); + instructions.RemoveRange(i, 2); + i--; + } + } + return true; + } + + /// + /// Each case consists of two blocks: + /// 1. block: + /// if (call op_Equality(ldloc switchVariable, ldstr value)) br caseBlock + /// br nextBlock + /// -or- + /// if (comp(ldloc switchValueVar == ldnull)) br nextBlock + /// br caseBlock + /// 2. block is caseBlock + /// This method matches the above pattern or its inverted form: + /// the call to ==(string, string) is wrapped in logic.not and the branch targets are reversed. + /// Returns the next block that follows in the block-chain. + /// The is updated if the value gets copied to a different variable. + /// See comments below for more info. + /// + Block MatchCaseBlock(Block currentBlock, ILVariable switchVariable, out string value, out Block caseBlock) + { + value = null; + caseBlock = null; + + if (currentBlock.IncomingEdgeCount != 1 || currentBlock.Instructions.Count != 2) + return null; + if (!currentBlock.Instructions[0].MatchIfInstruction(out var condition, out var caseBlockBranch)) + return null; + if (!caseBlockBranch.MatchBranch(out caseBlock)) + return null; + Block nextBlock; + if (condition.MatchLogicNot(out var inner)) { + condition = inner; + nextBlock = caseBlock; + if (!currentBlock.Instructions[1].MatchBranch(out caseBlock)) + return null; + } else { + if (!currentBlock.Instructions[1].MatchBranch(out nextBlock)) + return null; + } + if (!MatchStringEqualityComparison(condition, switchVariable, out value)) { + return null; + } + return nextBlock; + } + + /// + /// Matches the C# 2.0 switch-on-string pattern, which uses Dictionary<string, int>. + /// + bool MatchLegacySwitchOnStringWithDict(InstructionCollection instructions, ref int i) + { + if (i < 1) return false; + // match first block: checking switch-value for null + // stloc switchValueVar(switchValue) + // if (comp(ldloc switchValueVar == ldnull)) br nullCase + // br nextBlock + if (!(instructions[i].MatchIfInstruction(out var condition, out var exitBlockJump) && + instructions[i - 1].MatchStLoc(out var switchValueVar, out var switchValue) && switchValueVar.Type.IsKnownType(KnownTypeCode.String))) + return false; + if (!switchValueVar.IsSingleDefinition) + return false; + if (!exitBlockJump.MatchBranch(out var nullValueCaseBlock)) + return false; + if (!(condition.MatchCompEquals(out var left, out var right) && right.MatchLdNull() + && ((SemanticHelper.IsPure(switchValue.Flags) && left.Match(switchValue).Success) || left.MatchLdLoc(switchValueVar)))) + return false; + var nextBlockJump = instructions.ElementAtOrDefault(i + 1) as Branch; + if (nextBlockJump == null || nextBlockJump.TargetBlock.IncomingEdgeCount != 1) + return false; + // match second block: checking compiler-generated Dictionary for null + // if (comp(volatile.ldobj System.Collections.Generic.Dictionary`2[[System.String],[System.Int32]](ldsflda $$method0x600000c-1) != ldnull)) br caseNullBlock + // br dictInitBlock + var nextBlock = nextBlockJump.TargetBlock; + if (nextBlock.Instructions.Count != 2 || !nextBlock.Instructions[0].MatchIfInstruction(out condition, out var tryGetValueBlockJump)) + return false; + if (!tryGetValueBlockJump.MatchBranch(out var tryGetValueBlock)) + return false; + if (!nextBlock.Instructions[1].MatchBranch(out var dictInitBlock) || dictInitBlock.IncomingEdgeCount != 1) + return false; + if (!(condition.MatchCompNotEquals(out left, out right) && right.MatchLdNull() && + MatchDictionaryFieldLoad(left, IsStringToIntDictionary, out var dictField, out var dictionaryType))) + return false; + // match third block: initialization of compiler-generated Dictionary + // stloc dict(newobj Dictionary..ctor(ldc.i4 valuesLength)) + // call Add(ldloc dict, ldstr value, ldc.i4 index) + // ... more calls to Add ... + // volatile.stobj System.Collections.Generic.Dictionary`2[[System.String],[System.Int32]](ldsflda $$method0x600003f-1, ldloc dict) + // br switchHeadBlock + if (dictInitBlock.IncomingEdgeCount != 1 || dictInitBlock.Instructions.Count < 3) + return false; + if (!ExtractStringValuesFromInitBlock(dictInitBlock, out var stringValues, tryGetValueBlock, dictionaryType, dictField)) + return false; + // match fourth block: TryGetValue on compiler-generated Dictionary + // if (logic.not(call TryGetValue(volatile.ldobj System.Collections.Generic.Dictionary`2[[System.String],[System.Int32]](ldsflda $$method0x600000c-1), ldloc switchValueVar, ldloca switchIndexVar))) br defaultBlock + // br switchBlock + if (tryGetValueBlock.IncomingEdgeCount != 2 || tryGetValueBlock.Instructions.Count != 2) + return false; + if (!tryGetValueBlock.Instructions[0].MatchIfInstruction(out condition, out var defaultBlockJump)) + return false; + if (!defaultBlockJump.MatchBranch(out var defaultBlock)) + return false; + if (!(condition.MatchLogicNot(out var arg) && arg is Call c && c.Method.Name == "TryGetValue" && + MatchDictionaryFieldLoad(c.Arguments[0], IsStringToIntDictionary, out var dictField2, out _) && dictField2.Equals(dictField))) + return false; + if (!c.Arguments[1].MatchLdLoc(switchValueVar) || !c.Arguments[2].MatchLdLoca(out var switchIndexVar)) + return false; + if (!tryGetValueBlock.Instructions[1].MatchBranch(out var switchBlock)) + return false; + // match fifth block: switch-instruction block + // switch (ldloc switchVariable) { + // case [0..1): br caseBlock1 + // ... more cases ... + // case [long.MinValue..0),[13..long.MaxValue]: br defaultBlock + // } + if (switchBlock.IncomingEdgeCount != 1 || switchBlock.Instructions.Count != 1) + return false; + if (!(switchBlock.Instructions[0] is SwitchInstruction switchInst && switchInst.Value.MatchLdLoc(switchIndexVar))) + return false; + var sections = new List(switchInst.Sections); + // switch contains case null: + if (nullValueCaseBlock != defaultBlock) { + if (!AddNullSection(sections, stringValues, nullValueCaseBlock)) { + return false; + } + } + bool keepAssignmentBefore = false; + if (switchValueVar.LoadCount > 2) { + switchValue = new LdLoc(switchValueVar); + keepAssignmentBefore = true; + } + var stringToInt = new StringToInt(switchValue, stringValues.ToArray()); + var inst = new SwitchInstruction(stringToInt); + inst.Sections.AddRange(sections); + instructions[i + 1].ReplaceWith(inst); + if (keepAssignmentBefore) { + // delete if (comp(ldloc switchValueVar == ldnull)) + instructions.RemoveAt(i); + i--; + } else { + // delete both the if and the assignment before + instructions.RemoveRange(i - 1, 2); + i -= 2; + } + return true; + } + + private bool AddNullSection(List sections, List stringValues, Block nullValueCaseBlock) + { + var label = new LongSet(sections.Count); + var possibleConflicts = sections.Where(sec => sec.Labels.Overlaps(label)).ToArray(); + if (possibleConflicts.Length > 1) + return false; + else if (possibleConflicts.Length == 1) { + if (possibleConflicts[0].Labels.Count() == 1) + return false; // cannot remove only label + possibleConflicts[0].Labels = possibleConflicts[0].Labels.ExceptWith(label); + } + stringValues.Add(null); + sections.Add(new SwitchSection() { Labels = label, Body = new Branch(nullValueCaseBlock) }); + return true; + } + + /// + /// Matches 'volatile.ldobj dictionaryType(ldsflda dictField)' + /// + bool MatchDictionaryFieldLoad(ILInstruction inst, Func typeMatcher, out IField dictField, out IType dictionaryType) + { + dictField = null; + dictionaryType = null; + return inst.MatchLdObj(out var dictionaryFieldLoad, out dictionaryType) && + typeMatcher(dictionaryType) && + dictionaryFieldLoad.MatchLdsFlda(out dictField) && + (dictField.IsCompilerGeneratedOrIsInCompilerGeneratedClass() || dictField.Name.StartsWith("$$method", StringComparison.Ordinal)); + } + + /// + /// Matches and extracts values from Add-call sequences. + /// + bool ExtractStringValuesFromInitBlock(Block block, out List values, Block targetBlock, IType dictionaryType, IField dictionaryField) + { + values = null; + // stloc dictVar(newobj Dictionary..ctor(ldc.i4 valuesLength)) + // -or- + // stloc dictVar(newobj Hashtable..ctor(ldc.i4 capacity, ldc.f loadFactor)) + if (!(block.Instructions[0].MatchStLoc(out var dictVar, out var newObjDict) && newObjDict is NewObj newObj)) + return false; + if (!newObj.Method.DeclaringType.Equals(dictionaryType)) + return false; + int valuesLength = 0; + if (newObj.Arguments.Count == 2) { + if (!newObj.Arguments[0].MatchLdcI4(out valuesLength)) + return false; + if (!newObj.Arguments[1].MatchLdcF(0.5)) + return false; + } else if (newObj.Arguments.Count == 1) { + if (!newObj.Arguments[0].MatchLdcI4(out valuesLength)) + return false; + } + values = new List(valuesLength); + int i = 0; + while (MatchAddCall(dictionaryType, block.Instructions[i + 1], dictVar, i, out var value)) { + values.Add(value); + i++; + } + // final store to compiler-generated variable: + // volatile.stobj dictionaryType(ldsflda dictionaryField, ldloc dictVar) + if (!(block.Instructions[i + 1].MatchStObj(out var loadField, out var dictVarLoad, out var dictType) && + dictType.Equals(dictionaryType) && loadField.MatchLdsFlda(out var dictField) && dictField.Equals(dictionaryField) && + dictVarLoad.MatchLdLoc(dictVar))) + return false; + return block.Instructions[i + 2].MatchBranch(targetBlock); + } + + /// + /// call Add(ldloc dictVar, ldstr value, ldc.i4 index) + /// -or- + /// call Add(ldloc dictVar, ldstr value, box System.Int32(ldc.i4 index)) + /// + bool MatchAddCall(IType dictionaryType, ILInstruction inst, ILVariable dictVar, int index, out string value) + { + value = null; + if (!(inst is Call c && c.Method.Name == "Add" && c.Arguments.Count == 3)) + return false; + if (!(c.Arguments[0].MatchLdLoc(dictVar) && c.Arguments[1].MatchLdStr(out value))) + return false; + if (!(c.Method.DeclaringType.Equals(dictionaryType) && !c.Method.IsStatic)) + return false; + return (c.Arguments[2].MatchLdcI4(index) || (c.Arguments[2].MatchBox(out var arg, out _) && arg.MatchLdcI4(index))); + } + + bool IsStringToIntDictionary(IType dictionaryType) + { + if (dictionaryType.FullName != "System.Collections.Generic.Dictionary") + return false; + if (dictionaryType.TypeArguments.Count != 2) + return false; + return dictionaryType.TypeArguments[0].IsKnownType(KnownTypeCode.String) && + dictionaryType.TypeArguments[1].IsKnownType(KnownTypeCode.Int32); + } + + bool IsNonGenericHashtable(IType dictionaryType) + { + if (dictionaryType.FullName != "System.Collections.Hashtable") + return false; + if (dictionaryType.TypeArguments.Count != 0) + return false; + return true; + } + + bool MatchLegacySwitchOnStringWithHashtable(InstructionCollection instructions, ref int i) + { + // match first block: checking compiler-generated Hashtable for null + // if (comp(volatile.ldobj System.Collections.Hashtable(ldsflda $$method0x600003f-1) != ldnull)) br switchHeadBlock + // br tableInitBlock + if (!(instructions[i].MatchIfInstruction(out var condition, out var branchToSwitchHead) && i + 1 < instructions.Count)) + return false; + if (!instructions[i + 1].MatchBranch(out var tableInitBlock) || tableInitBlock.IncomingEdgeCount != 1) + return false; + if (!(condition.MatchCompNotEquals(out var left, out var right) && right.MatchLdNull() && + MatchDictionaryFieldLoad(left, IsNonGenericHashtable, out var dictField, out var dictionaryType))) + return false; + if (!branchToSwitchHead.MatchBranch(out var switchHead)) + return false; + // match second block: initialization of compiler-generated Hashtable + // stloc table(newobj Hashtable..ctor(ldc.i4 capacity, ldc.f loadFactor)) + // call Add(ldloc table, ldstr value, box System.Int32(ldc.i4 index)) + // ... more calls to Add ... + // volatile.stobj System.Collections.Hashtable(ldsflda $$method0x600003f - 1, ldloc table) + // br switchHeadBlock + if (tableInitBlock.IncomingEdgeCount != 1 || tableInitBlock.Instructions.Count < 3) + return false; + if (!ExtractStringValuesFromInitBlock(tableInitBlock, out var stringValues, switchHead, dictionaryType, dictField)) + return false; + // match third block: checking switch-value for null + // stloc tmp(ldloc switch-value) + // stloc switchVariable(ldloc tmp) + // if (comp(ldloc tmp == ldnull)) br nullCaseBlock + // br getItemBlock + if (switchHead.Instructions.Count != 4 || switchHead.IncomingEdgeCount != 2) + return false; + if (!switchHead.Instructions[0].MatchStLoc(out var tmp, out var switchValue)) + return false; + if (!switchHead.Instructions[1].MatchStLoc(out var switchVariable, out var tmpLoad) || !tmpLoad.MatchLdLoc(tmp)) + return false; + if (!switchHead.Instructions[2].MatchIfInstruction(out condition, out var nullCaseBlockBranch)) + return false; + if (!switchHead.Instructions[3].MatchBranch(out var getItemBlock) || !nullCaseBlockBranch.MatchBranch(out var nullCaseBlock)) + return false; + if (!(condition.MatchCompEquals(out left, out right) && right.MatchLdNull() && left.MatchLdLoc(tmp))) + return false; + // match fourth block: get_Item on compiler-generated Hashtable + // stloc tmp2(call get_Item(volatile.ldobj System.Collections.Hashtable(ldsflda $$method0x600003f - 1), ldloc switchVariable)) + // stloc switchVariable(ldloc tmp2) + // if (comp(ldloc tmp2 == ldnull)) br defaultCaseBlock + // br switchBlock + if (getItemBlock.IncomingEdgeCount != 1 || getItemBlock.Instructions.Count != 4) + return false; + if (!(getItemBlock.Instructions[0].MatchStLoc(out var tmp2, out var getItem) && getItem is Call getItemCall && getItemCall.Method.Name == "get_Item")) + return false; + if (!getItemBlock.Instructions[1].MatchStLoc(out var switchVariable2, out var tmp2Load) || !tmp2Load.MatchLdLoc(tmp2)) + return false; + if (!ILVariableEqualityComparer.Instance.Equals(switchVariable, switchVariable2)) + return false; + if (!getItemBlock.Instructions[2].MatchIfInstruction(out condition, out var defaultBlockBranch)) + return false; + if (!getItemBlock.Instructions[3].MatchBranch(out var switchBlock) || !defaultBlockBranch.MatchBranch(out var defaultBlock)) + return false; + if (!(condition.MatchCompEquals(out left, out right) && right.MatchLdNull() && left.MatchLdLoc(tmp2))) + return false; + if (!(getItemCall.Arguments.Count == 2 && MatchDictionaryFieldLoad(getItemCall.Arguments[0], IsStringToIntDictionary, out var dictField2, out _) && dictField2.Equals(dictField)) && + getItemCall.Arguments[1].MatchLdLoc(switchVariable2)) + return false; + // match fifth block: switch-instruction block + // switch (ldobj System.Int32(unbox System.Int32(ldloc switchVariable))) { + // case [0..1): br caseBlock1 + // ... more cases ... + // case [long.MinValue..0),[13..long.MaxValue]: br defaultBlock + // } + if (switchBlock.IncomingEdgeCount != 1 || switchBlock.Instructions.Count != 1) + return false; + if (!(switchBlock.Instructions[0] is SwitchInstruction switchInst && switchInst.Value.MatchLdObj(out var target, out var ldobjType) && + target.MatchUnbox(out var arg, out var unboxType) && arg.MatchLdLoc(switchVariable2) && ldobjType.IsKnownType(KnownTypeCode.Int32) && unboxType.Equals(ldobjType))) + return false; + var sections = new List(switchInst.Sections); + // switch contains case null: + if (nullCaseBlock != defaultBlock) { + if (!AddNullSection(sections, stringValues, nullCaseBlock)) { + return false; + } + } + var stringToInt = new StringToInt(switchValue, stringValues.ToArray()); + var inst = new SwitchInstruction(stringToInt); + inst.Sections.AddRange(sections); + instructions[i + 1].ReplaceWith(inst); + instructions.RemoveAt(i); + return true; + } + + bool MatchRoslynSwitchOnString(InstructionCollection instructions, ref int i) + { + if (i < 1) return false; + // stloc switchValueVar(call ComputeStringHash(switchValue)) + // switch (ldloc switchValueVar) { + // case [211455823..211455824): br caseBlock1 + // ... more cases ... + // case [long.MinValue..-365098645),...,[1697255802..long.MaxValue]: br defaultBlock + // } + if (!(instructions[i] is SwitchInstruction switchInst && switchInst.Value.MatchLdLoc(out var switchValueVar) && + MatchComputeStringHashCall(instructions[i - 1], switchValueVar, out LdLoc switchValueLoad))) + return false; + + var stringValues = new List<(int, string, Block)>(); + int index = 0; + SwitchSection defaultSection = switchInst.Sections.MaxBy(s => s.Labels.Count()); + foreach (var section in switchInst.Sections) { + if (section == defaultSection) continue; + // extract target block + if (!section.Body.MatchBranch(out Block target)) + return false; + if (!MatchRoslynCaseBlockHead(target, switchValueLoad.Variable, out Block body, out string stringValue)) + return false; + stringValues.Add((index++, stringValue, body)); + } + ILInstruction switchValueInst = switchValueLoad; + // stloc switchValueLoadVariable(switchValue) + // stloc switchValueVar(call ComputeStringHash(ldloc switchValueLoadVariable)) + // switch (ldloc switchValueVar) { + bool keepAssignmentBefore; + // if the switchValueLoad.Variable is only used in the compiler generated case equality checks, we can remove it. + if (i > 1 && instructions[i - 2].MatchStLoc(switchValueLoad.Variable, out var switchValueTmp) && + switchValueLoad.Variable.IsSingleDefinition && switchValueLoad.Variable.LoadCount == switchInst.Sections.Count) + { + switchValueInst = switchValueTmp; + keepAssignmentBefore = false; + } else { + keepAssignmentBefore = true; + } + var defaultLabel = new LongSet(new LongInterval(0, index)).Invert(); + var newSwitch = new SwitchInstruction(new StringToInt(switchValueInst, stringValues.Select(item => item.Item2).ToArray())); + newSwitch.Sections.AddRange(stringValues.Select(section => new SwitchSection { Labels = new Util.LongSet(section.Item1), Body = new Branch(section.Item3) })); + newSwitch.Sections.Add(new SwitchSection { Labels = defaultLabel, Body = defaultSection.Body }); + instructions[i].ReplaceWith(newSwitch); + if (keepAssignmentBefore) { + instructions.RemoveAt(i - 1); + i--; + } else { + instructions.RemoveRange(i - 2, 2); + i -= 2; + } + return true; + } + + /// + /// Matches and the negated version: + /// if (call op_Equality(ldloc V_0, ldstr "Fifth case")) br body + /// br exit + /// + bool MatchRoslynCaseBlockHead(Block target, ILVariable switchValueVar, out Block body, out string stringValue) + { + body = null; + stringValue = null; + if (target.Instructions.Count != 2) + return false; + if (!target.Instructions[0].MatchIfInstruction(out var condition, out var bodyBranch)) + return false; + if (!bodyBranch.MatchBranch(out body)) + return false; + if (MatchStringEqualityComparison(condition, switchValueVar, out stringValue)) { + return body != null; + } else if (condition.MatchLogicNot(out condition) && MatchStringEqualityComparison(condition, switchValueVar, out stringValue)) { + if (!target.Instructions[1].MatchBranch(out Block exit)) + return false; + body = exit; + return true; + } else { + return false; + } + } + + /// + /// Matches 'stloc(targetVar, call ComputeStringHash(ldloc switchValue))' + /// + bool MatchComputeStringHashCall(ILInstruction inst, ILVariable targetVar, out LdLoc switchValue) + { + switchValue = null; + if (!inst.MatchStLoc(targetVar, out var value)) + return false; + if (!(value is Call c && c.Arguments.Count == 1 && c.Method.Name == "ComputeStringHash" && c.Method.IsCompilerGeneratedOrIsInCompilerGeneratedClass())) + return false; + if (!(c.Arguments[0] is LdLoc)) + return false; + switchValue = (LdLoc)c.Arguments[0]; + return true; + } + + /// + /// Matches 'call string.op_Equality(ldloc(variable), ldstr(stringValue))' + /// or 'comp(ldloc(variable) == ldnull)' + /// + bool MatchStringEqualityComparison(ILInstruction condition, ILVariable variable, out string stringValue) + { + return MatchStringEqualityComparison(condition, out var v, out stringValue) && v == variable; + } + + /// + /// Matches 'call string.op_Equality(ldloc(variable), ldstr(stringValue))' + /// or 'comp(ldloc(variable) == ldnull)' + /// + bool MatchStringEqualityComparison(ILInstruction condition, out ILVariable variable, out string stringValue) + { + stringValue = null; + variable = null; + ILInstruction left, right; + if (condition is Call c && c.Method.IsOperator && c.Method.Name == "op_Equality" + && c.Method.DeclaringType.IsKnownType(KnownTypeCode.String) && c.Arguments.Count == 2) + { + left = c.Arguments[0]; + right = c.Arguments[1]; + return left.MatchLdLoc(out variable) && right.MatchLdStr(out stringValue); + } else if (condition.MatchCompEqualsNull(out var arg)) { + stringValue = null; + return arg.MatchLdLoc(out variable); + } else { + return false; + } + } + } +} diff --git a/ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs b/ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs index 5d41bb402..a1de1bf3e 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs @@ -47,6 +47,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms continue; if (TransformRoslynCompoundAssignmentCall(block, i)) continue; + if (TransformRoslynPostIncDecOperatorOnAddress(block, i)) + continue; } } @@ -303,6 +305,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms var stobj = block.Instructions.ElementAtOrDefault(i + 2) as StObj; if (inst == null || nextInst == null || stobj == null) return false; + if (!inst.Variable.IsSingleDefinition || inst.Variable.LoadCount != 2) + return false; if (!(inst.Value is LdElema || inst.Value is LdFlda || inst.Value is LdsFlda)) return false; ILInstruction target; @@ -321,7 +325,37 @@ namespace ICSharpCode.Decompiler.IL.Transforms block.Instructions.RemoveAt(i + 1); return true; } - + + /// + /// stloc l(ldobj(ldflda(target))) + /// stobj(ldflda(target), binary.op(ldloc l, ldc.i4 1)) + /// --> + /// compound.op.old(ldobj(ldflda(target)), ldc.i4 1) + /// + bool TransformRoslynPostIncDecOperatorOnAddress(Block block, int i) + { + var inst = block.Instructions[i] as StLoc; + var stobj = block.Instructions.ElementAtOrDefault(i + 1) as StObj; + if (inst == null || stobj == null) + return false; + if (!inst.Variable.IsSingleDefinition || inst.Variable.LoadCount != 1) + return false; + if (!inst.Value.MatchLdObj(out var loadTarget, out var loadType) || !loadTarget.MatchLdFlda(out var fieldTarget, out var field)) + return false; + if (!stobj.Target.MatchLdFlda(out var fieldTarget2, out var field2)) + return false; + if (!fieldTarget.Match(fieldTarget2).Success || !field.Equals(field2)) + return false; + var binary = stobj.Value as BinaryNumericInstruction; + if (binary == null || !binary.Left.MatchLdLoc(inst.Variable) || !binary.Right.MatchLdcI4(1) + || (binary.Operator != BinaryNumericOperator.Add && binary.Operator != BinaryNumericOperator.Sub)) + return false; + context.Step("TransformRoslynPostIncDecOperator", inst); + stobj.ReplaceWith(new CompoundAssignmentInstruction(binary, inst.Value, binary.Right, loadType, CompoundAssignmentType.EvaluatesToOldValue)); + block.Instructions.RemoveAt(i); + return true; + } + /// /// stloc s(ldflda) /// stloc s2(ldobj(ldflda(ldloc s))) diff --git a/ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs b/ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs index bc699eaed..12f9db004 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.Linq; using ICSharpCode.Decompiler.TypeSystem; +using ICSharpCode.Decompiler.Util; namespace ICSharpCode.Decompiler.IL.Transforms { @@ -45,7 +46,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms ILInstruction inst = body.Instructions[pos]; // Match stloc(v, newobj) if (inst.MatchStLoc(out var v, out var initInst) && (v.Kind == VariableKind.Local || v.Kind == VariableKind.StackSlot)) { - Block initializerBlock = null; IType instType; switch (initInst) { case NewObj newObjInst: @@ -65,49 +65,55 @@ namespace ICSharpCode.Decompiler.IL.Transforms instType = newObjInst.Method.DeclaringType; break; case DefaultValue defaultVal: + if (defaultVal.ILStackWasEmpty && v.Kind == VariableKind.Local && !context.Function.Method.IsConstructor) { + // on statement level (no other expressions on IL stack), + // prefer to keep local variables (but not stack slots), + // unless we are in a constructor (where inlining object initializers might be critical + // for the base ctor call) + return false; + } instType = defaultVal.Type; break; - case Block existingInitializer: - if (existingInitializer.Type == BlockType.CollectionInitializer || existingInitializer.Type == BlockType.ObjectInitializer) { - initializerBlock = existingInitializer; - var value = ((StLoc)initializerBlock.Instructions[0]).Value; - if (value is NewObj no) - instType = no.Method.DeclaringType; - else - instType = ((DefaultValue)value).Type; - break; - } - return false; default: return false; } int initializerItemsCount = 0; - var blockType = initializerBlock?.Type ?? BlockType.CollectionInitializer; - var possibleIndexVariables = new Dictionary(); + var blockType = BlockType.CollectionInitializer; + possibleIndexVariables = new Dictionary(); + currentPath = new List(); + isCollection = false; + pathStack = new Stack>(); + pathStack.Push(new HashSet()); // Detect initializer type by scanning the following statements // each must be a callvirt with ldloc v as first argument // if the method is a setter we're dealing with an object initializer // if the method is named Add and has at least 2 arguments we're dealing with a collection/dictionary initializer while (pos + initializerItemsCount + 1 < body.Instructions.Count - && IsPartOfInitializer(body.Instructions, pos + initializerItemsCount + 1, v, instType, ref blockType, possibleIndexVariables)) { + && IsPartOfInitializer(body.Instructions, pos + initializerItemsCount + 1, v, instType, ref blockType)) { initializerItemsCount++; } + // Do not convert the statements into an initializer if there's an incompatible usage of the initializer variable + // directly after the possible initializer. + if (IsMethodCallOnVariable(body.Instructions[pos + initializerItemsCount + 1], v)) + return false; + // Calculate the correct number of statements inside the initializer: + // All index variables that were used in the initializer have Index set to -1. + // We fetch the first unused variable from the list and remove all instructions after its + // first usage (i.e. the init store) from the initializer. var index = possibleIndexVariables.Where(info => info.Value.Index > -1).Min(info => (int?)info.Value.Index); if (index != null) { initializerItemsCount = index.Value - pos - 1; } + // The initializer would be empty, there's nothing to do here. if (initializerItemsCount <= 0) return false; context.Step("CollectionOrObjectInitializer", inst); - ILVariable finalSlot; - if (initializerBlock == null) { - initializerBlock = new Block(blockType); - finalSlot = context.Function.RegisterVariable(VariableKind.InitializerTarget, v.Type); - initializerBlock.FinalInstruction = new LdLoc(finalSlot); - initializerBlock.Instructions.Add(new StLoc(finalSlot, initInst.Clone())); - } else { - finalSlot = ((LdLoc)initializerBlock.FinalInstruction).Variable; - } + // Create a new block and final slot (initializer target variable) + var initializerBlock = new Block(blockType); + ILVariable finalSlot = context.Function.RegisterVariable(VariableKind.InitializerTarget, v.Type); + initializerBlock.FinalInstruction = new LdLoc(finalSlot); + initializerBlock.Instructions.Add(new StLoc(finalSlot, initInst.Clone())); + // Move all instructions to the initializer block. for (int i = 1; i <= initializerItemsCount; i++) { switch (body.Instructions[i + pos]) { case CallInstruction call: @@ -139,20 +145,67 @@ namespace ICSharpCode.Decompiler.IL.Transforms return true; } - bool IsPartOfInitializer(InstructionCollection instructions, int pos, ILVariable target, IType rootType, ref BlockType blockType, Dictionary possibleIndexVariables) + bool IsMethodCallOnVariable(ILInstruction inst, ILVariable variable) + { + if (inst.MatchLdLocRef(variable)) + return true; + if (inst is CallInstruction call && call.Arguments.Count > 0 && !call.Method.IsStatic) + return IsMethodCallOnVariable(call.Arguments[0], variable); + if (inst.MatchLdFld(out var target, out _) || inst.MatchStFld(out target, out _, out _) || inst.MatchLdFlda(out target, out _)) + return IsMethodCallOnVariable(target, variable); + return false; + } + + Dictionary possibleIndexVariables; + List currentPath; + bool isCollection; + Stack> pathStack; + + bool IsPartOfInitializer(InstructionCollection instructions, int pos, ILVariable target, IType rootType, ref BlockType blockType) { + // Include any stores to local variables that are single-assigned and do not reference the initializer-variable + // in the list of possible index variables. + // Index variables are used to implement dictionary initializers. if (instructions[pos] is StLoc stloc && stloc.Variable.Kind == VariableKind.Local && stloc.Variable.IsSingleDefinition) { if (stloc.Value.Descendants.OfType().Any(ld => ld.Variable == target && (ld is LdLoc || ld is LdLoca))) return false; possibleIndexVariables.Add(stloc.Variable, (stloc.ChildIndex, stloc.Value)); return true; } - (var kind, var path, var values, var targetVariable) = AccessPathElement.GetAccessPath(instructions[pos], rootType, possibleIndexVariables); + (var kind, var newPath, var values, var targetVariable) = AccessPathElement.GetAccessPath(instructions[pos], rootType, possibleIndexVariables); + if (kind == AccessPathKind.Invalid || target != targetVariable) + return false; + // Treat last element separately: + // Can either be an Add method call or property setter. + var lastElement = newPath.Last(); + newPath.RemoveLast(); + // Compare new path with current path: + int minLen = Math.Min(currentPath.Count, newPath.Count); + int firstDifferenceIndex = 0; + while (firstDifferenceIndex < minLen && newPath[firstDifferenceIndex] == currentPath[firstDifferenceIndex]) + firstDifferenceIndex++; + while (currentPath.Count > firstDifferenceIndex) { + isCollection = false; + currentPath.RemoveAt(currentPath.Count - 1); + pathStack.Pop(); + } + while (currentPath.Count < newPath.Count) { + AccessPathElement newElement = newPath[currentPath.Count]; + currentPath.Add(newElement); + if (isCollection || !pathStack.Peek().Add(newElement)) + return false; + pathStack.Push(new HashSet()); + } switch (kind) { case AccessPathKind.Adder: - return target == targetVariable; + isCollection = true; + if (pathStack.Peek().Count != 0) + return false; + return true; case AccessPathKind.Setter: - if (values.Count == 1 && target == targetVariable) { + if (isCollection || !pathStack.Peek().Add(lastElement)) + return false; + if (values.Count == 1) { blockType = BlockType.ObjectInitializer; return true; } @@ -183,7 +236,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms public override string ToString() => $"[{Member}, {Indices}]"; - public static (AccessPathKind Kind, List Path, List Values, ILVariable Target) GetAccessPath(ILInstruction instruction, IType rootType, Dictionary possibleIndexVariables = null) + public static (AccessPathKind Kind, List Path, List Values, ILVariable Target) GetAccessPath( + ILInstruction instruction, IType rootType, Dictionary possibleIndexVariables = null) { List path = new List(); ILVariable target = null; @@ -203,6 +257,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms var isGetter = property?.Getter == method; var indices = call.Arguments.Skip(1).Take(call.Arguments.Count - (isGetter ? 1 : 2)).ToArray(); if (possibleIndexVariables != null) { + // Mark all index variables as used foreach (var index in indices.OfType()) { if (possibleIndexVariables.TryGetValue(index.Variable, out var info)) possibleIndexVariables[index.Variable] = (-1, info.Value); @@ -224,17 +279,18 @@ namespace ICSharpCode.Decompiler.IL.Transforms } } break; - case LdObj ldobj: + case LdObj ldobj: { if (ldobj.Target is LdFlda ldflda) { path.Insert(0, new AccessPathElement(ldflda.Field)); instruction = ldflda.Target; break; } goto default; - case StObj stobj: - if (stobj.Target is LdFlda ldflda2) { - path.Insert(0, new AccessPathElement(ldflda2.Field)); - instruction = ldflda2.Target; + } + case StObj stobj: { + if (stobj.Target is LdFlda ldflda) { + path.Insert(0, new AccessPathElement(ldflda.Field)); + instruction = ldflda.Target; if (values == null) { values = new List(new[] { stobj.Value }); kind = AccessPathKind.Setter; @@ -242,6 +298,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms break; } goto default; + } case LdLoc ldloc: target = ldloc.Variable; instruction = null; @@ -250,6 +307,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms target = ldloca.Variable; instruction = null; break; + case LdFlda ldflda: + path.Insert(0, new AccessPathElement(ldflda.Field)); + instruction = ldflda.Target; + break; default: kind = AccessPathKind.Invalid; instruction = null; @@ -313,7 +374,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms public bool Equals(AccessPathElement other) { - return other.Member.Equals(this.Member) && (other.Indices == this.Indices || other.Indices.SequenceEqual(this.Indices, ILInstructionMatchComparer.Instance)); + return other.Member.Equals(this.Member) + && (other.Indices == this.Indices || other.Indices.SequenceEqual(this.Indices, ILInstructionMatchComparer.Instance)); } public static bool operator ==(AccessPathElement lhs, AccessPathElement rhs) @@ -337,12 +399,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms return true; if (x == null || y == null) return false; - return x.Match(y).Success; + return SemanticHelper.IsPure(x.Flags) + && SemanticHelper.IsPure(y.Flags) + && x.Match(y).Success; } public int GetHashCode(ILInstruction obj) { - return obj.GetHashCode(); + throw new NotSupportedException(); } } } diff --git a/ICSharpCode.Decompiler/IL/Transforms/UsingTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/UsingTransform.cs index e0993d6ce..3d6cd1639 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/UsingTransform.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/UsingTransform.cs @@ -87,7 +87,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms context.Step("UsingTransform", tryFinally); storeInst.Variable.Kind = VariableKind.UsingLocal; block.Instructions.RemoveAt(i); - block.Instructions[i - 1] = new UsingInstruction(storeInst.Variable, storeInst.Value, tryFinally.TryBlock); + block.Instructions[i - 1] = new UsingInstruction(storeInst.Variable, storeInst.Value, tryFinally.TryBlock) { ILRange = storeInst.ILRange }; return true; } @@ -188,7 +188,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms if (objVar.Type.IsKnownType(KnownTypeCode.NullableOfT)) { if (!entryPoint.Instructions[checkIndex].MatchIfInstruction(out var condition, out var disposeInst)) return false; - if (!(NullableLiftingTransform.MatchHasValueCall(condition, out var v) && v == objVar)) + if (!NullableLiftingTransform.MatchHasValueCall(condition, objVar)) return false; if (!(disposeInst is Block disposeBlock) || disposeBlock.Instructions.Count != 1) return false; diff --git a/ICSharpCode.Decompiler/Output/TextTokenWriter.cs b/ICSharpCode.Decompiler/Output/TextTokenWriter.cs index f0d26ef11..5ce584f1d 100644 --- a/ICSharpCode.Decompiler/Output/TextTokenWriter.cs +++ b/ICSharpCode.Decompiler/Output/TextTokenWriter.cs @@ -116,7 +116,7 @@ namespace ICSharpCode.Decompiler if (symbol == null && node.Role == Roles.TargetExpression && node.Parent is InvocationExpression) { symbol = node.Parent.GetSymbol(); } - if (symbol != null && node.Parent is ObjectCreateExpression) { + if (symbol != null && node.Role == Roles.Type && node.Parent is ObjectCreateExpression) { symbol = node.Parent.GetSymbol(); } if (node is IdentifierExpression && node.Role == Roles.TargetExpression && node.Parent is InvocationExpression && symbol is IMember member) { @@ -335,9 +335,15 @@ namespace ICSharpCode.Decompiler case "char": case "string": case "object": - var typeSymbol = (nodeStack.Peek().GetSymbol() as IType)?.GetDefinition(); - if (typeSymbol == null) goto default; - output.WriteReference(type, typeSystem.GetCecil(typeSymbol)); + var node = nodeStack.Peek(); + ISymbol symbol; + if (node.Role == Roles.Type && node.Parent is ObjectCreateExpression) { + symbol = node.Parent.GetSymbol(); + } else { + symbol = nodeStack.Peek().GetSymbol(); + } + if (symbol == null) goto default; + output.WriteReference(type, SymbolToCecil(symbol)); break; default: output.Write(type); diff --git a/ICSharpCode.Decompiler/TypeSystem/CecilLoader.cs b/ICSharpCode.Decompiler/TypeSystem/CecilLoader.cs index c52d0df6b..b07a0c835 100644 --- a/ICSharpCode.Decompiler/TypeSystem/CecilLoader.cs +++ b/ICSharpCode.Decompiler/TypeSystem/CecilLoader.cs @@ -350,6 +350,8 @@ namespace ICSharpCode.Decompiler.TypeSystem } else if (type is GenericParameter) { GenericParameter typeGP = (GenericParameter)type; return TypeParameterReference.Create(typeGP.Owner is MethodReference ? SymbolKind.Method : SymbolKind.TypeDefinition, typeGP.Position); + } else if (type is FunctionPointerType) { + return KnownTypeReference.Get(KnownTypeCode.IntPtr); } else if (type.IsNested) { ITypeReference typeRef = CreateType(type.DeclaringType, typeAttributes, ref typeIndex); int partTypeParameterCount; diff --git a/ICSharpCode.Decompiler/Util/CollectionExtensions.cs b/ICSharpCode.Decompiler/Util/CollectionExtensions.cs index 0223d4f1e..df1785c7e 100644 --- a/ICSharpCode.Decompiler/Util/CollectionExtensions.cs +++ b/ICSharpCode.Decompiler/Util/CollectionExtensions.cs @@ -114,5 +114,88 @@ namespace ICSharpCode.Decompiler.Util moreB = enumB.MoveNext(); } } + + /// + /// Returns the minimum element. + /// + /// The input sequence is empty + public static T MinBy(this IEnumerable source, Func keySelector) where K : IComparable + { + return source.MinBy(keySelector, Comparer.Default); + } + + /// + /// Returns the minimum element. + /// + /// The input sequence is empty + public static T MinBy(this IEnumerable source, Func keySelector, IComparer keyComparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (keyComparer == null) + keyComparer = Comparer.Default; + using (var enumerator = source.GetEnumerator()) { + if (!enumerator.MoveNext()) + throw new InvalidOperationException("Sequence contains no elements"); + T minElement = enumerator.Current; + K minKey = keySelector(minElement); + while (enumerator.MoveNext()) { + T element = enumerator.Current; + K key = keySelector(element); + if (keyComparer.Compare(key, minKey) < 0) { + minElement = element; + minKey = key; + } + } + return minElement; + } + } + + /// + /// Returns the maximum element. + /// + /// The input sequence is empty + public static T MaxBy(this IEnumerable source, Func keySelector) where K : IComparable + { + return source.MaxBy(keySelector, Comparer.Default); + } + + /// + /// Returns the maximum element. + /// + /// The input sequence is empty + public static T MaxBy(this IEnumerable source, Func keySelector, IComparer keyComparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (keyComparer == null) + keyComparer = Comparer.Default; + using (var enumerator = source.GetEnumerator()) { + if (!enumerator.MoveNext()) + throw new InvalidOperationException("Sequence contains no elements"); + T maxElement = enumerator.Current; + K maxKey = keySelector(maxElement); + while (enumerator.MoveNext()) { + T element = enumerator.Current; + K key = keySelector(element); + if (keyComparer.Compare(key, maxKey) > 0) { + maxElement = element; + maxKey = key; + } + } + return maxElement; + } + } + + public static void RemoveLast(this IList list) + { + if (list == null) + throw new ArgumentNullException(nameof(list)); + list.RemoveAt(list.Count - 1); + } } } diff --git a/ICSharpCode.Decompiler/Util/GraphVizGraph.cs b/ICSharpCode.Decompiler/Util/GraphVizGraph.cs new file mode 100644 index 000000000..3488a52f1 --- /dev/null +++ b/ICSharpCode.Decompiler/Util/GraphVizGraph.cs @@ -0,0 +1,221 @@ +// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Text.RegularExpressions; + +namespace ICSharpCode.Decompiler.Util +{ +#if DEBUG + /// + /// GraphViz graph. + /// + sealed class GraphVizGraph + { + List nodes = new List(); + List edges = new List(); + + public string rankdir; + public string Title; + + public void AddEdge(GraphVizEdge edge) + { + edges.Add(edge); + } + + public void AddNode(GraphVizNode node) + { + nodes.Add(node); + } + + public void Save(string fileName) + { + using (StreamWriter writer = new StreamWriter(fileName)) + Save(writer); + } + + public void Show() + { + Show(null); + } + + public void Show(string name) + { + if (name == null) + name = Title; + if (name != null) + foreach (char c in Path.GetInvalidFileNameChars()) + name = name.Replace(c, '-'); + string fileName = name != null ? Path.Combine(Path.GetTempPath(), name) : Path.GetTempFileName(); + Save(fileName + ".gv"); + Process.Start("dot", "\"" + fileName + ".gv\" -Tpng -o \"" + fileName + ".png\"").WaitForExit(); + Process.Start(fileName + ".png"); + } + + static string Escape(string text) + { + if (Regex.IsMatch(text, @"^[\w\d]+$")) { + return text; + } else { + return "\"" + text.Replace("\\", "\\\\").Replace("\r", "").Replace("\n", "\\n").Replace("\"", "\\\"") + "\""; + } + } + + static void WriteGraphAttribute(TextWriter writer, string name, string value) + { + if (value != null) + writer.WriteLine("{0}={1};", name, Escape(value)); + } + + internal static void WriteAttribute(TextWriter writer, string name, double? value, ref bool isFirst) + { + if (value != null) { + WriteAttribute(writer, name, value.Value.ToString(CultureInfo.InvariantCulture), ref isFirst); + } + } + + internal static void WriteAttribute(TextWriter writer, string name, bool? value, ref bool isFirst) + { + if (value != null) { + WriteAttribute(writer, name, value.Value ? "true" : "false", ref isFirst); + } + } + + internal static void WriteAttribute(TextWriter writer, string name, string value, ref bool isFirst) + { + if (value != null) { + if (isFirst) + isFirst = false; + else + writer.Write(','); + writer.Write("{0}={1}", name, Escape(value)); + } + } + + public void Save(TextWriter writer) + { + if (writer == null) + throw new ArgumentNullException("writer"); + writer.WriteLine("digraph G {"); + writer.WriteLine("node [fontsize = 16];"); + WriteGraphAttribute(writer, "rankdir", rankdir); + foreach (GraphVizNode node in nodes) { + node.Save(writer); + } + foreach (GraphVizEdge edge in edges) { + edge.Save(writer); + } + writer.WriteLine("}"); + } + } + + sealed class GraphVizEdge + { + public readonly string Source, Target; + + /// edge stroke color + public string color; + /// use edge to affect node ranking + public bool? constraint; + + public string label; + + public string style; + + /// point size of label + public int? fontsize; + + public GraphVizEdge(string source, string target) + { + if (source == null) + throw new ArgumentNullException("source"); + if (target == null) + throw new ArgumentNullException("target"); + this.Source = source; + this.Target = target; + } + + public GraphVizEdge(int source, int target) + { + this.Source = source.ToString(CultureInfo.InvariantCulture); + this.Target = target.ToString(CultureInfo.InvariantCulture); + } + + public void Save(TextWriter writer) + { + writer.Write("{0} -> {1} [", Source, Target); + bool isFirst = true; + GraphVizGraph.WriteAttribute(writer, "label", label, ref isFirst); + GraphVizGraph.WriteAttribute(writer, "style", style, ref isFirst); + GraphVizGraph.WriteAttribute(writer, "fontsize", fontsize, ref isFirst); + GraphVizGraph.WriteAttribute(writer, "color", color, ref isFirst); + GraphVizGraph.WriteAttribute(writer, "constraint", constraint, ref isFirst); + writer.WriteLine("];"); + } + } + + sealed class GraphVizNode + { + public readonly string ID; + public string label; + + public string labelloc; + + /// point size of label + public int? fontsize; + + /// minimum height in inches + public double? height; + + /// space around label + public string margin; + + /// node shape + public string shape; + + public GraphVizNode(string id) + { + if (id == null) + throw new ArgumentNullException("id"); + this.ID = id; + } + + public GraphVizNode(int id) + { + this.ID = id.ToString(CultureInfo.InvariantCulture); + } + + public void Save(TextWriter writer) + { + writer.Write(ID); + writer.Write(" ["); + bool isFirst = true; + GraphVizGraph.WriteAttribute(writer, "label", label, ref isFirst); + GraphVizGraph.WriteAttribute(writer, "labelloc", labelloc, ref isFirst); + GraphVizGraph.WriteAttribute(writer, "fontsize", fontsize, ref isFirst); + GraphVizGraph.WriteAttribute(writer, "margin", margin, ref isFirst); + GraphVizGraph.WriteAttribute(writer, "shape", shape, ref isFirst); + writer.WriteLine("];"); + } + } +#endif +} diff --git a/ILSpy.BamlDecompiler/BamlResourceEntryNode.cs b/ILSpy.BamlDecompiler/BamlResourceEntryNode.cs index 9b0a515dd..30444af81 100644 --- a/ILSpy.BamlDecompiler/BamlResourceEntryNode.cs +++ b/ILSpy.BamlDecompiler/BamlResourceEntryNode.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using System.Xml.Linq; using ICSharpCode.AvalonEdit.Highlighting; +using ICSharpCode.Decompiler.Util; using ICSharpCode.ILSpy; using ICSharpCode.ILSpy.TextView; using ICSharpCode.ILSpy.TreeNodes; @@ -135,7 +136,7 @@ namespace ILSpy.BamlDecompiler } } - static void RemoveConnectionIds(XElement element, Dictionary eventMappings) + static void RemoveConnectionIds(XElement element, List<(LongSet key, EventRegistration[] value)> eventMappings) { foreach (var child in element.Elements()) RemoveConnectionIds(child, eventMappings); @@ -143,10 +144,9 @@ namespace ILSpy.BamlDecompiler var removableAttrs = new List(); var addableAttrs = new List(); foreach (var attr in element.Attributes(XName.Get("ConnectionId", XmlBamlReader.XWPFNamespace))) { - int id; - if (int.TryParse(attr.Value, out id) && eventMappings.ContainsKey(id)) { - var map = eventMappings[id]; - foreach (var entry in map) { + int id, index; + if (int.TryParse(attr.Value, out id) && (index = eventMappings.FindIndex(item => item.key.Contains(id))) > -1) { + foreach (var entry in eventMappings[index].value) { string xmlns = ""; // TODO : implement xmlns resolver! addableAttrs.Add(new XAttribute(xmlns + entry.EventName, entry.MethodName)); } diff --git a/ILSpy.BamlDecompiler/ConnectMethodDecompiler.cs b/ILSpy.BamlDecompiler/ConnectMethodDecompiler.cs index 7c970ea54..39ddba883 100644 --- a/ILSpy.BamlDecompiler/ConnectMethodDecompiler.cs +++ b/ILSpy.BamlDecompiler/ConnectMethodDecompiler.cs @@ -10,6 +10,7 @@ using ICSharpCode.Decompiler.CSharp; using ICSharpCode.Decompiler.IL; using ICSharpCode.Decompiler.IL.Transforms; using ICSharpCode.Decompiler.TypeSystem; +using ICSharpCode.Decompiler.Util; using Mono.Cecil; namespace ILSpy.BamlDecompiler @@ -34,9 +35,9 @@ namespace ILSpy.BamlDecompiler this.assembly = assembly; } - public Dictionary DecompileEventMappings(string fullTypeName, CancellationToken cancellationToken) + public List<(LongSet, EventRegistration[])> DecompileEventMappings(string fullTypeName, CancellationToken cancellationToken) { - var result = new Dictionary(); + var result = new List<(LongSet, EventRegistration[])>(); TypeDefinition type = this.assembly.MainModule.GetType(fullTypeName); if (type == null) @@ -65,13 +66,12 @@ namespace ILSpy.BamlDecompiler function.RunTransforms(CSharpDecompiler.GetILTransforms(), context); var block = function.Body.Children.OfType().First(); - var ilSwitch = block.Children.OfType().FirstOrDefault(); + var ilSwitch = block.Descendants.OfType().FirstOrDefault(); if (ilSwitch != null) { foreach (var section in ilSwitch.Sections) { var events = FindEvents(section.Body); - foreach (long id in section.Labels.Values) - result.Add(id, events); + result.Add((section.Labels, events)); } } else { foreach (var ifInst in function.Descendants.OfType()) { @@ -82,7 +82,7 @@ namespace ILSpy.BamlDecompiler if (!comp.Right.MatchLdcI4(out id)) continue; var events = FindEvents(comp.Kind == ComparisonKind.Inequality ? ifInst.FalseInst : ifInst.TrueInst); - result.Add(id, events); + result.Add((new LongSet(id), events)); } } return result; @@ -92,13 +92,18 @@ namespace ILSpy.BamlDecompiler { var events = new List(); - if (inst is Block) { - foreach (var node in ((Block)inst).Instructions) { - FindEvents(node, events); - } - FindEvents(((Block)inst).FinalInstruction, events); - } else { - FindEvents(inst, events); + switch (inst) { + case Block b: + foreach (var node in ((Block)inst).Instructions) { + FindEvents(node, events); + } + FindEvents(((Block)inst).FinalInstruction, events); + break; + case Branch br: + return FindEvents(br.TargetBlock); + default: + FindEvents(inst, events); + break; } return events.ToArray(); } diff --git a/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj b/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj index 715adb513..dcaf09535 100644 --- a/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj +++ b/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj @@ -36,7 +36,7 @@ - + diff --git a/ILSpy/Commands/SortAssemblyListCommand.cs b/ILSpy/Commands/SortAssemblyListCommand.cs index 2020cf21d..3f8bc3920 100644 --- a/ILSpy/Commands/SortAssemblyListCommand.cs +++ b/ILSpy/Commands/SortAssemblyListCommand.cs @@ -18,12 +18,13 @@ using System; using System.Collections.Generic; +using ICSharpCode.TreeView; namespace ICSharpCode.ILSpy { [ExportMainMenuCommand(Menu = "_View", Header = "Sort assembly list by name", MenuIcon = "Images/Sort.png", MenuCategory = "View")] [ExportToolbarCommand(ToolTip = "Sort assembly list by name", ToolbarIcon = "Images/Sort.png", ToolbarCategory = "View")] - class SortAssemblyListCommand : SimpleCommand, IComparer + sealed class SortAssemblyListCommand : SimpleCommand, IComparer { public override void Execute(object parameter) { @@ -36,4 +37,25 @@ namespace ICSharpCode.ILSpy return string.Compare(x.ShortName, y.ShortName, StringComparison.CurrentCulture); } } + + [ExportMainMenuCommand(Menu = "_View", Header = "Collapse all tree nodes", MenuIcon = "Images/CollapseAll.png", MenuCategory = "View")] + [ExportToolbarCommand(ToolTip = "Collapse all tree nodes", ToolbarIcon = "Images/CollapseAll.png", ToolbarCategory = "View")] + sealed class CollapseAllCommand : SimpleCommand + { + public override void Execute(object parameter) + { + using (MainWindow.Instance.treeView.LockUpdates()) + CollapseChildren(MainWindow.Instance.treeView.Root); + + void CollapseChildren(SharpTreeNode node) + { + foreach (var child in node.Children) { + if (!child.IsExpanded) + continue; + CollapseChildren(child); + child.IsExpanded = false; + } + } + } + } } diff --git a/ILSpy/DebugSteps.xaml b/ILSpy/DebugSteps.xaml index a96d1463e..e343e5070 100644 --- a/ILSpy/DebugSteps.xaml +++ b/ILSpy/DebugSteps.xaml @@ -6,7 +6,12 @@ xmlns:local="clr-namespace:ICSharpCode.ILSpy" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> - + + + + + + @@ -21,5 +26,5 @@ - + diff --git a/ILSpy/DebugSteps.xaml.cs b/ILSpy/DebugSteps.xaml.cs index f2c44b474..f3c3b7a7f 100644 --- a/ILSpy/DebugSteps.xaml.cs +++ b/ILSpy/DebugSteps.xaml.cs @@ -2,6 +2,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using ICSharpCode.Decompiler.IL; using ICSharpCode.Decompiler.IL.Transforms; namespace ICSharpCode.ILSpy @@ -12,6 +13,13 @@ namespace ICSharpCode.ILSpy /// public partial class DebugSteps : UserControl, IPane { + static readonly ILAstWritingOptions writingOptions = new ILAstWritingOptions { + UseFieldSugar = true, + UseLogicOperationSugar = true + }; + + public static ILAstWritingOptions Options => writingOptions; + #if DEBUG ILAstLanguage language; #endif @@ -23,6 +31,7 @@ namespace ICSharpCode.ILSpy #if DEBUG MainWindow.Instance.SessionSettings.FilterSettings.PropertyChanged += FilterSettings_PropertyChanged; MainWindow.Instance.SelectionChanged += SelectionChanged; + writingOptions.PropertyChanged += WritingOptions_PropertyChanged; if (MainWindow.Instance.CurrentLanguage is ILAstLanguage l) { l.StepperUpdated += ILAstStepperUpdated; @@ -32,9 +41,17 @@ namespace ICSharpCode.ILSpy #endif } + private void WritingOptions_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + DecompileAsync(lastSelectedStep); + } + private void SelectionChanged(object sender, SelectionChangedEventArgs e) { - Dispatcher.Invoke(() => tree.ItemsSource = null); + Dispatcher.Invoke(() => { + tree.ItemsSource = null; + lastSelectedStep = int.MaxValue; + }); } private void FilterSettings_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) @@ -57,7 +74,10 @@ namespace ICSharpCode.ILSpy { #if DEBUG if (language == null) return; - Dispatcher.Invoke(() => tree.ItemsSource = language.Stepper.Steps); + Dispatcher.Invoke(() => { + tree.ItemsSource = language.Stepper.Steps; + lastSelectedStep = int.MaxValue; + }); #endif } @@ -71,6 +91,7 @@ namespace ICSharpCode.ILSpy #if DEBUG MainWindow.Instance.SessionSettings.FilterSettings.PropertyChanged -= FilterSettings_PropertyChanged; MainWindow.Instance.SelectionChanged -= SelectionChanged; + writingOptions.PropertyChanged -= WritingOptions_PropertyChanged; if (language != null) { language.StepperUpdated -= ILAstStepperUpdated; } @@ -98,8 +119,11 @@ namespace ICSharpCode.ILSpy DecompileAsync(n.BeginStep, true); } + int lastSelectedStep = int.MaxValue; + void DecompileAsync(int step, bool isDebug = false) { + lastSelectedStep = step; var window = MainWindow.Instance; var state = window.TextView.GetState(); window.TextView.DecompileAsync(window.CurrentLanguage, window.SelectedNodes, diff --git a/ILSpy/ExtensionMethods.cs b/ILSpy/ExtensionMethods.cs index 32cd8ea30..c83d09f4e 100644 --- a/ILSpy/ExtensionMethods.cs +++ b/ILSpy/ExtensionMethods.cs @@ -64,6 +64,31 @@ namespace ICSharpCode.ILSpy return ~start; } + public static int BinarySearch(this IList instance, TKey itemKey, Func keySelector) + where TKey : IComparable, IComparable + { + if (instance == null) + throw new ArgumentNullException(nameof(instance)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + int start = 0; + int end = instance.Count - 1; + + while (start <= end) { + int m = (start + end) / 2; + TKey key = keySelector(instance[m]); + int result = key.CompareTo(itemKey); + if (result == 0) + return m; + if (result < 0) + start = m + 1; + else + end = m - 1; + } + return ~start; + } + public static bool IsCustomAttribute(this TypeDefinition type) { while (type.FullName != "System.Object") { diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index f61c643c4..304e82ca8 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -50,7 +50,7 @@ - + @@ -106,6 +106,7 @@ DebugSteps.xaml + @@ -115,6 +116,7 @@ + @@ -344,6 +346,7 @@ + diff --git a/ILSpy/Images/CollapseAll.png b/ILSpy/Images/CollapseAll.png new file mode 100644 index 000000000..5e23dbc81 Binary files /dev/null and b/ILSpy/Images/CollapseAll.png differ diff --git a/ILSpy/Languages/CSharpHighlightingTokenWriter.cs b/ILSpy/Languages/CSharpHighlightingTokenWriter.cs new file mode 100644 index 000000000..6d91a6a11 --- /dev/null +++ b/ILSpy/Languages/CSharpHighlightingTokenWriter.cs @@ -0,0 +1,434 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ICSharpCode.AvalonEdit.Highlighting; +using ICSharpCode.Decompiler.CSharp; +using ICSharpCode.Decompiler.CSharp.OutputVisitor; +using ICSharpCode.Decompiler.CSharp.Syntax; +using ICSharpCode.Decompiler.TypeSystem; + +namespace ICSharpCode.ILSpy +{ + class CSharpHighlightingTokenWriter : DecoratingTokenWriter + { + ISmartTextOutput textOutput; + + HighlightingColor visibilityKeywordsColor; + HighlightingColor namespaceKeywordsColor; + HighlightingColor structureKeywordsColor; + HighlightingColor gotoKeywordsColor; + HighlightingColor queryKeywordsColor; + HighlightingColor exceptionKeywordsColor; + HighlightingColor checkedKeywordColor; + HighlightingColor unsafeKeywordsColor; + HighlightingColor valueTypeKeywordsColor; + HighlightingColor referenceTypeKeywordsColor; + HighlightingColor operatorKeywordsColor; + HighlightingColor parameterModifierColor; + HighlightingColor modifiersColor; + HighlightingColor accessorKeywordsColor; + HighlightingColor attributeKeywordsColor; + + HighlightingColor referenceTypeColor; + HighlightingColor valueTypeColor; + HighlightingColor interfaceTypeColor; + HighlightingColor enumerationTypeColor; + HighlightingColor typeParameterTypeColor; + HighlightingColor delegateTypeColor; + + HighlightingColor methodCallColor; + HighlightingColor methodDeclarationColor; + + HighlightingColor fieldDeclarationColor; + HighlightingColor fieldAccessColor; + + HighlightingColor valueKeywordColor; + HighlightingColor thisKeywordColor; + HighlightingColor trueKeywordColor; + HighlightingColor typeKeywordsColor; + + public CSharpHighlightingTokenWriter(TokenWriter decoratedWriter, ISmartTextOutput textOutput) : base(decoratedWriter) + { + this.textOutput = textOutput; + var highlighting = HighlightingManager.Instance.GetDefinition("C#"); + + //this.defaultTextColor = ???; + + this.visibilityKeywordsColor = highlighting.GetNamedColor("Visibility"); + this.namespaceKeywordsColor = highlighting.GetNamedColor("NamespaceKeywords"); + this.structureKeywordsColor = highlighting.GetNamedColor("Keywords"); + this.gotoKeywordsColor = highlighting.GetNamedColor("GotoKeywords"); + this.queryKeywordsColor = highlighting.GetNamedColor("QueryKeywords"); + this.exceptionKeywordsColor = highlighting.GetNamedColor("ExceptionKeywords"); + this.checkedKeywordColor = highlighting.GetNamedColor("CheckedKeyword"); + this.unsafeKeywordsColor = highlighting.GetNamedColor("UnsafeKeywords"); + this.valueTypeKeywordsColor = highlighting.GetNamedColor("ValueTypeKeywords"); + this.referenceTypeKeywordsColor = highlighting.GetNamedColor("ReferenceTypeKeywords"); + this.operatorKeywordsColor = highlighting.GetNamedColor("OperatorKeywords"); + this.parameterModifierColor = highlighting.GetNamedColor("ParameterModifiers"); + this.modifiersColor = highlighting.GetNamedColor("Modifiers"); + this.accessorKeywordsColor = highlighting.GetNamedColor("GetSetAddRemove"); + + this.referenceTypeColor = highlighting.GetNamedColor("ReferenceTypes"); + this.valueTypeColor = highlighting.GetNamedColor("ValueTypes"); + this.interfaceTypeColor = highlighting.GetNamedColor("InterfaceTypes"); + this.enumerationTypeColor = highlighting.GetNamedColor("EnumTypes"); + this.typeParameterTypeColor = highlighting.GetNamedColor("TypeParameters"); + this.delegateTypeColor = highlighting.GetNamedColor("DelegateTypes"); + this.methodDeclarationColor = this.methodCallColor = highlighting.GetNamedColor("MethodCall"); + //this.eventDeclarationColor = this.eventAccessColor = defaultTextColor; + //this.propertyDeclarationColor = this.propertyAccessColor = defaultTextColor; + this.fieldDeclarationColor = this.fieldAccessColor = highlighting.GetNamedColor("FieldAccess"); + //this.variableDeclarationColor = this.variableAccessColor = defaultTextColor; + //this.parameterDeclarationColor = this.parameterAccessColor = defaultTextColor; + this.valueKeywordColor = highlighting.GetNamedColor("NullOrValueKeywords"); + this.thisKeywordColor = highlighting.GetNamedColor("ThisOrBaseReference"); + this.trueKeywordColor = highlighting.GetNamedColor("TrueFalse"); + this.typeKeywordsColor = highlighting.GetNamedColor("TypeKeywords"); + this.attributeKeywordsColor = highlighting.GetNamedColor("AttributeKeywords"); + //this.externAliasKeywordColor = ...; + } + + public override void WriteKeyword(Role role, string keyword) + { + HighlightingColor color = null; + switch (keyword) { + case "namespace": + case "using": + if (role == UsingStatement.UsingKeywordRole) + color = structureKeywordsColor; + else + color = namespaceKeywordsColor; + break; + case "this": + case "base": + color = thisKeywordColor; + break; + case "true": + case "false": + color = trueKeywordColor; + break; + case "public": + case "internal": + case "protected": + case "private": + color = visibilityKeywordsColor; + break; + case "if": + case "else": + case "switch": + case "case": + case "default": + case "while": + case "do": + case "for": + case "foreach": + case "lock": + case "global": + case "dynamic": + case "await": + color = structureKeywordsColor; + break; + case "where": + if (nodeStack.PeekOrDefault() is QueryClause) + color = queryKeywordsColor; + else + color = structureKeywordsColor; + break; + case "in": + if (nodeStack.PeekOrDefault() is ForeachStatement) + color = structureKeywordsColor; + else if (nodeStack.PeekOrDefault() is QueryClause) + color = queryKeywordsColor; + else + color = parameterModifierColor; + break; + case "as": + case "is": + case "new": + case "sizeof": + case "typeof": + case "nameof": + case "stackalloc": + color = typeKeywordsColor; + break; + case "try": + case "throw": + case "catch": + case "finally": + color = exceptionKeywordsColor; + break; + case "when": + if (role == CatchClause.WhenKeywordRole) + color = exceptionKeywordsColor; + break; + case "get": + case "set": + case "add": + case "remove": + if (role == PropertyDeclaration.GetKeywordRole || + role == PropertyDeclaration.SetKeywordRole || + role == CustomEventDeclaration.AddKeywordRole || + role == CustomEventDeclaration.RemoveKeywordRole) + color = accessorKeywordsColor; + break; + case "abstract": + case "const": + case "event": + case "extern": + case "override": + case "readonly": + case "sealed": + case "static": + case "virtual": + case "volatile": + case "async": + case "partial": + color = modifiersColor; + break; + case "checked": + case "unchecked": + color = checkedKeywordColor; + break; + case "fixed": + case "unsafe": + color = unsafeKeywordsColor; + break; + case "enum": + case "struct": + color = valueTypeKeywordsColor; + break; + case "class": + case "interface": + case "delegate": + color = referenceTypeKeywordsColor; + break; + case "select": + case "group": + case "by": + case "into": + case "from": + case "ascending": + case "descending": + case "orderby": + case "let": + case "join": + case "on": + case "equals": + if (nodeStack.PeekOrDefault() is QueryClause) + color = queryKeywordsColor; + break; + case "explicit": + case "implicit": + case "operator": + color = operatorKeywordsColor; + break; + case "params": + case "ref": + case "out": + color = parameterModifierColor; + break; + case "break": + case "continue": + case "goto": + case "yield": + case "return": + color = gotoKeywordsColor; + break; + } + if (nodeStack.PeekOrDefault() is AttributeSection) + color = attributeKeywordsColor; + if (color != null) { + textOutput.BeginSpan(color); + } + base.WriteKeyword(role, keyword); + if (color != null) { + textOutput.EndSpan(); + } + } + + public override void WritePrimitiveType(string type) + { + HighlightingColor color = null; + switch (type) { + case "new": + color = typeKeywordsColor; + break; + case "bool": + case "byte": + case "char": + case "decimal": + case "double": + case "enum": + case "float": + case "int": + case "long": + case "sbyte": + case "short": + case "struct": + case "uint": + case "ushort": + case "ulong": + color = valueTypeKeywordsColor; + break; + case "object": + case "string": + case "void": + color = referenceTypeKeywordsColor; + break; + } + if (color != null) { + textOutput.BeginSpan(color); + } + base.WritePrimitiveType(type); + if (color != null) { + textOutput.EndSpan(); + } + } + + public override void WriteIdentifier(Identifier identifier) + { + HighlightingColor color = null; + if (identifier.Name == "value" && nodeStack.PeekOrDefault() is Accessor accessor && accessor.Role != PropertyDeclaration.GetterRole) + color = valueKeywordColor; + switch (GetCurrentDefinition()) { + case ITypeDefinition t: + switch (t.Kind) { + case TypeKind.Delegate: + color = delegateTypeColor; + break; + case TypeKind.Class: + color = referenceTypeColor; + break; + case TypeKind.Interface: + color = interfaceTypeColor; + break; + case TypeKind.Enum: + color = enumerationTypeColor; + break; + case TypeKind.Struct: + color = valueTypeColor; + break; + } + break; + case IMethod m: + color = methodDeclarationColor; + break; + case IField f: + color = fieldDeclarationColor; + break; + } + switch (GetCurrentMemberReference()) { + case IType t: + switch (t.Kind) { + case TypeKind.Delegate: + color = delegateTypeColor; + break; + case TypeKind.Class: + color = referenceTypeColor; + break; + case TypeKind.Interface: + color = interfaceTypeColor; + break; + case TypeKind.Enum: + color = enumerationTypeColor; + break; + case TypeKind.Struct: + color = valueTypeColor; + break; + } + break; + case IMethod m: + color = methodCallColor; + break; + case IField f: + color = fieldAccessColor; + break; + } + if (color != null) { + textOutput.BeginSpan(color); + } + base.WriteIdentifier(identifier); + if (color != null) { + textOutput.EndSpan(); + } + } + + public override void WritePrimitiveValue(object value, string literalValue = null) + { + HighlightingColor color = null; + if (value is null) { + color = valueKeywordColor; + } + if (value is true || value is false) { + color = trueKeywordColor; + } + if (color != null) { + textOutput.BeginSpan(color); + } + base.WritePrimitiveValue(value, literalValue); + if (color != null) { + textOutput.EndSpan(); + } + } + + ISymbol GetCurrentDefinition() + { + if (nodeStack == null || nodeStack.Count == 0) + return null; + + var node = nodeStack.Peek(); + if (node is Identifier) + node = node.Parent; + if (IsDefinition(ref node)) + return node.GetSymbol(); + + return null; + } + + static bool IsDefinition(ref AstNode node) + { + if (node is EntityDeclaration) + return true; + if (node is VariableInitializer && node.Parent is FieldDeclaration) { + node = node.Parent; + return true; + } + if (node is FixedVariableInitializer) + return true; + return false; + } + + ISymbol GetCurrentMemberReference() + { + AstNode node = nodeStack.Peek(); + var symbol = node.GetSymbol(); + if (symbol == null && node.Role == Roles.TargetExpression && node.Parent is InvocationExpression) { + symbol = node.Parent.GetSymbol(); + } + if (symbol != null && node.Parent is ObjectCreateExpression) { + symbol = node.Parent.GetSymbol(); + } + if (node is IdentifierExpression && node.Role == Roles.TargetExpression && node.Parent is InvocationExpression && symbol is IMember member) { + var declaringType = member.DeclaringType; + if (declaringType != null && declaringType.Kind == TypeKind.Delegate) + return null; + } + return symbol; + } + + Stack nodeStack = new Stack(); + + public override void StartNode(AstNode node) + { + nodeStack.Push(node); + base.StartNode(node); + } + + public override void EndNode(AstNode node) + { + base.EndNode(node); + nodeStack.Pop(); + } + } +} diff --git a/ILSpy/Languages/CSharpILMixedLanguage.cs b/ILSpy/Languages/CSharpILMixedLanguage.cs new file mode 100644 index 000000000..073fd61bb --- /dev/null +++ b/ILSpy/Languages/CSharpILMixedLanguage.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Threading; +using System.Windows; +using System.Windows.Media; +using ICSharpCode.AvalonEdit.Highlighting; +using ICSharpCode.Decompiler; +using ICSharpCode.Decompiler.CSharp; +using ICSharpCode.Decompiler.CSharp.OutputVisitor; +using ICSharpCode.Decompiler.CSharp.Syntax; +using ICSharpCode.Decompiler.Disassembler; +using ICSharpCode.Decompiler.IL; +using ICSharpCode.Decompiler.TypeSystem; +using ICSharpCode.Decompiler.Util; +using Mono.Cecil; +using Mono.Cecil.Cil; + +namespace ICSharpCode.ILSpy +{ + [Export(typeof(Language))] + class CSharpILMixedLanguage : ILLanguage + { + public override string Name => "IL with C#"; + + protected override ReflectionDisassembler CreateDisassembler(ITextOutput output, DecompilationOptions options) + { + return new ReflectionDisassembler(output, + new MixedMethodBodyDisassembler(output, options) { + DetectControlStructure = detectControlStructure, + ShowSequencePoints = options.DecompilerSettings.ShowDebugInfo + }, + options.CancellationToken); + } + + static CSharpDecompiler CreateDecompiler(ModuleDefinition module, DecompilationOptions options) + { + CSharpDecompiler decompiler = new CSharpDecompiler(module, options.DecompilerSettings); + decompiler.CancellationToken = options.CancellationToken; + return decompiler; + } + + static void WriteCode(TextWriter output, DecompilerSettings settings, SyntaxTree syntaxTree, IDecompilerTypeSystem typeSystem) + { + syntaxTree.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true }); + TokenWriter tokenWriter = new TextWriterTokenWriter(output); + tokenWriter = TokenWriter.WrapInWriterThatSetsLocationsInAST(tokenWriter); + syntaxTree.AcceptVisitor(new CSharpOutputVisitor(tokenWriter, settings.CSharpFormattingOptions)); + } + + class MixedMethodBodyDisassembler : MethodBodyDisassembler + { + readonly DecompilationOptions options; + // list sorted by IL offset + IList sequencePoints; + // lines of raw c# source code + string[] codeLines; + + public MixedMethodBodyDisassembler(ITextOutput output, DecompilationOptions options) + : base(output, options.CancellationToken) + { + this.options = options; + } + + public override void Disassemble(MethodBody body) + { + var method = body.Method; + try { + var csharpOutput = new StringWriter(); + CSharpDecompiler decompiler = CreateDecompiler(method.Module, options); + var st = decompiler.Decompile(method); + WriteCode(csharpOutput, options.DecompilerSettings, st, decompiler.TypeSystem); + var mapping = decompiler.CreateSequencePoints(st).FirstOrDefault(kvp => kvp.Key.CecilMethod == method); + this.sequencePoints = mapping.Value ?? (IList)EmptyList.Instance; + this.codeLines = csharpOutput.ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.None); + base.Disassemble(body); + } finally { + this.sequencePoints = null; + this.codeLines = null; + } + } + + protected override void WriteInstruction(ITextOutput output, Instruction instruction) + { + int index = sequencePoints.BinarySearch(instruction.Offset, seq => seq.Offset); + if (index >= 0) { + var info = sequencePoints[index]; + var highlightingOutput = output as ISmartTextOutput; + if (!info.IsHidden) { + for (int line = info.StartLine; line <= info.EndLine; line++) { + if (highlightingOutput != null) { + string text = codeLines[line - 1]; + int startColumn = 1; + int endColumn = text.Length + 1; + if (line == info.StartLine) + startColumn = info.StartColumn; + if (line == info.EndLine) + endColumn = info.EndColumn; + WriteHighlightedCommentLine(highlightingOutput, text, startColumn - 1, endColumn - 1, info.StartLine == info.EndLine); + } else + WriteCommentLine(output, codeLines[line - 1]); + } + } else { + output.Write("// "); + highlightingOutput?.BeginSpan(gray); + output.WriteLine("(no C# code)"); + highlightingOutput?.EndSpan(); + } + } + base.WriteInstruction(output, instruction); + } + + HighlightingColor gray = new HighlightingColor { Foreground = new SimpleHighlightingBrush(Colors.DarkGray) }; + + void WriteHighlightedCommentLine(ISmartTextOutput output, string text, int startColumn, int endColumn, bool isSingleLine) + { + if (startColumn > text.Length) { + Debug.Fail("startColumn is invalid"); + startColumn = text.Length; + } + if (endColumn > text.Length) { + Debug.Fail("endColumn is invalid"); + endColumn = text.Length; + } + output.Write("// "); + output.BeginSpan(gray); + if (isSingleLine) + output.Write(text.Substring(0, startColumn).TrimStart()); + else + output.Write(text.Substring(0, startColumn)); + output.EndSpan(); + output.Write(text.Substring(startColumn, endColumn - startColumn)); + output.BeginSpan(gray); + output.Write(text.Substring(endColumn)); + output.EndSpan(); + output.WriteLine(); + } + + void WriteCommentLine(ITextOutput output, string text) + { + output.WriteLine("// " + text); + } + } + } +} diff --git a/ILSpy/Languages/CSharpLanguage.cs b/ILSpy/Languages/CSharpLanguage.cs index c9ef04f3d..4be6e9518 100644 --- a/ILSpy/Languages/CSharpLanguage.cs +++ b/ILSpy/Languages/CSharpLanguage.cs @@ -100,7 +100,7 @@ namespace ICSharpCode.ILSpy syntaxTree.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true }); TokenWriter tokenWriter = new TextTokenWriter(output, settings, typeSystem) { FoldBraces = settings.FoldBraces }; if (output is ISmartTextOutput highlightingOutput) { - tokenWriter = new HighlightingTokenWriter(tokenWriter, highlightingOutput); + tokenWriter = new CSharpHighlightingTokenWriter(tokenWriter, highlightingOutput); } syntaxTree.AcceptVisitor(new CSharpOutputVisitor(tokenWriter, settings.CSharpFormattingOptions)); } @@ -327,9 +327,9 @@ namespace ICSharpCode.ILSpy decompiler.ProjectGuid = App.CommandLineArguments.FixedGuid; decompiler.DecompileProject(assembly.ModuleDefinition, options.SaveAsProjectDirectory, new TextOutputWriter(output), options.CancellationToken); } else { - base.DecompileAssembly(assembly, output, options); AddReferenceWarningMessage(assembly.AssemblyDefinition, output); output.WriteLine(); + base.DecompileAssembly(assembly, output, options); ModuleDefinition mainModule = assembly.ModuleDefinition; if (mainModule.Types.Count > 0) { output.Write("// Global type: "); @@ -518,423 +518,5 @@ namespace ICSharpCode.ILSpy var flags = ConversionFlags.All & ~ConversionFlags.ShowBody; return new CSharpAmbience() { ConversionFlags = flags }.ConvertSymbol(symbol); } - - class HighlightingTokenWriter : DecoratingTokenWriter - { - ISmartTextOutput textOutput; - - HighlightingColor visibilityKeywordsColor; - HighlightingColor namespaceKeywordsColor; - HighlightingColor structureKeywordsColor; - HighlightingColor gotoKeywordsColor; - HighlightingColor queryKeywordsColor; - HighlightingColor exceptionKeywordsColor; - HighlightingColor checkedKeywordColor; - HighlightingColor unsafeKeywordsColor; - HighlightingColor valueTypeKeywordsColor; - HighlightingColor referenceTypeKeywordsColor; - HighlightingColor operatorKeywordsColor; - HighlightingColor parameterModifierColor; - HighlightingColor modifiersColor; - HighlightingColor accessorKeywordsColor; - HighlightingColor attributeKeywordsColor; - - HighlightingColor referenceTypeColor; - HighlightingColor valueTypeColor; - HighlightingColor interfaceTypeColor; - HighlightingColor enumerationTypeColor; - HighlightingColor typeParameterTypeColor; - HighlightingColor delegateTypeColor; - - HighlightingColor methodCallColor; - HighlightingColor methodDeclarationColor; - - HighlightingColor fieldDeclarationColor; - HighlightingColor fieldAccessColor; - - HighlightingColor valueKeywordColor; - HighlightingColor thisKeywordColor; - HighlightingColor trueKeywordColor; - HighlightingColor typeKeywordsColor; - - public HighlightingTokenWriter(TokenWriter decoratedWriter, ISmartTextOutput textOutput) : base(decoratedWriter) - { - this.textOutput = textOutput; - var highlighting = HighlightingManager.Instance.GetDefinition("C#"); - - //this.defaultTextColor = ???; - - this.visibilityKeywordsColor = highlighting.GetNamedColor("Visibility"); - this.namespaceKeywordsColor = highlighting.GetNamedColor("NamespaceKeywords"); - this.structureKeywordsColor = highlighting.GetNamedColor("Keywords"); - this.gotoKeywordsColor = highlighting.GetNamedColor("GotoKeywords"); - this.queryKeywordsColor = highlighting.GetNamedColor("QueryKeywords"); - this.exceptionKeywordsColor = highlighting.GetNamedColor("ExceptionKeywords"); - this.checkedKeywordColor = highlighting.GetNamedColor("CheckedKeyword"); - this.unsafeKeywordsColor = highlighting.GetNamedColor("UnsafeKeywords"); - this.valueTypeKeywordsColor = highlighting.GetNamedColor("ValueTypeKeywords"); - this.referenceTypeKeywordsColor = highlighting.GetNamedColor("ReferenceTypeKeywords"); - this.operatorKeywordsColor = highlighting.GetNamedColor("OperatorKeywords"); - this.parameterModifierColor = highlighting.GetNamedColor("ParameterModifiers"); - this.modifiersColor = highlighting.GetNamedColor("Modifiers"); - this.accessorKeywordsColor = highlighting.GetNamedColor("GetSetAddRemove"); - - this.referenceTypeColor = highlighting.GetNamedColor("ReferenceTypes"); - this.valueTypeColor = highlighting.GetNamedColor("ValueTypes"); - this.interfaceTypeColor = highlighting.GetNamedColor("InterfaceTypes"); - this.enumerationTypeColor = highlighting.GetNamedColor("EnumTypes"); - this.typeParameterTypeColor = highlighting.GetNamedColor("TypeParameters"); - this.delegateTypeColor = highlighting.GetNamedColor("DelegateTypes"); - this.methodDeclarationColor = this.methodCallColor = highlighting.GetNamedColor("MethodCall"); - //this.eventDeclarationColor = this.eventAccessColor = defaultTextColor; - //this.propertyDeclarationColor = this.propertyAccessColor = defaultTextColor; - this.fieldDeclarationColor = this.fieldAccessColor = highlighting.GetNamedColor("FieldAccess"); - //this.variableDeclarationColor = this.variableAccessColor = defaultTextColor; - //this.parameterDeclarationColor = this.parameterAccessColor = defaultTextColor; - this.valueKeywordColor = highlighting.GetNamedColor("NullOrValueKeywords"); - this.thisKeywordColor = highlighting.GetNamedColor("ThisOrBaseReference"); - this.trueKeywordColor = highlighting.GetNamedColor("TrueFalse"); - this.typeKeywordsColor = highlighting.GetNamedColor("TypeKeywords"); - this.attributeKeywordsColor = highlighting.GetNamedColor("AttributeKeywords"); - //this.externAliasKeywordColor = ...; - } - - public override void WriteKeyword(Role role, string keyword) - { - HighlightingColor color = null; - switch (keyword) { - case "namespace": - case "using": - if (role == UsingStatement.UsingKeywordRole) - color = structureKeywordsColor; - else - color = namespaceKeywordsColor; - break; - case "this": - case "base": - color = thisKeywordColor; - break; - case "true": - case "false": - color = trueKeywordColor; - break; - case "public": - case "internal": - case "protected": - case "private": - color = visibilityKeywordsColor; - break; - case "if": - case "else": - case "switch": - case "case": - case "default": - case "while": - case "do": - case "for": - case "foreach": - case "lock": - case "global": - case "dynamic": - case "await": - case "where": - color = structureKeywordsColor; - break; - case "in": - if (nodeStack.PeekOrDefault() is ForeachStatement) - color = structureKeywordsColor; - else if (nodeStack.PeekOrDefault() is QueryClause) - color = queryKeywordsColor; - else - color = parameterModifierColor; - break; - case "as": - case "is": - case "new": - case "sizeof": - case "typeof": - case "nameof": - case "stackalloc": - color = typeKeywordsColor; - break; - case "try": - case "throw": - case "catch": - case "finally": - color = exceptionKeywordsColor; - break; - case "when": - if (role == CatchClause.WhenKeywordRole) - color = exceptionKeywordsColor; - break; - case "get": - case "set": - case "add": - case "remove": - if (role == PropertyDeclaration.GetKeywordRole || - role == PropertyDeclaration.SetKeywordRole || - role == CustomEventDeclaration.AddKeywordRole || - role == CustomEventDeclaration.RemoveKeywordRole) - color = accessorKeywordsColor; - break; - case "abstract": - case "const": - case "event": - case "extern": - case "override": - case "readonly": - case "sealed": - case "static": - case "virtual": - case "volatile": - case "async": - case "partial": - color = modifiersColor; - break; - case "checked": - case "unchecked": - color = checkedKeywordColor; - break; - case "fixed": - case "unsafe": - color = unsafeKeywordsColor; - break; - case "enum": - case "struct": - color = valueTypeKeywordsColor; - break; - case "class": - case "interface": - case "delegate": - color = referenceTypeKeywordsColor; - break; - case "select": - case "group": - case "by": - case "into": - case "from": - case "ascending": - case "descending": - case "orderby": - case "let": - case "join": - case "on": - case "equals": - if (nodeStack.PeekOrDefault() is QueryClause) - color = queryKeywordsColor; - break; - case "explicit": - case "implicit": - case "operator": - color = operatorKeywordsColor; - break; - case "params": - case "ref": - case "out": - color = parameterModifierColor; - break; - case "break": - case "continue": - case "goto": - case "yield": - case "return": - color = gotoKeywordsColor; - break; - } - if (nodeStack.PeekOrDefault() is AttributeSection) - color = attributeKeywordsColor; - if (color != null) { - textOutput.BeginSpan(color); - } - base.WriteKeyword(role, keyword); - if (color != null) { - textOutput.EndSpan(); - } - } - - public override void WritePrimitiveType(string type) - { - HighlightingColor color = null; - switch (type) { - case "new": - color = typeKeywordsColor; - break; - case "bool": - case "byte": - case "char": - case "decimal": - case "double": - case "enum": - case "float": - case "int": - case "long": - case "sbyte": - case "short": - case "struct": - case "uint": - case "ushort": - case "ulong": - color = valueTypeKeywordsColor; - break; - case "object": - case "string": - case "void": - color = referenceTypeKeywordsColor; - break; - } - if (color != null) { - textOutput.BeginSpan(color); - } - base.WritePrimitiveType(type); - if (color != null) { - textOutput.EndSpan(); - } - } - - public override void WriteIdentifier(Identifier identifier) - { - HighlightingColor color = null; - if (identifier.Name == "value" && nodeStack.PeekOrDefault() is Accessor accessor && accessor.Role != PropertyDeclaration.GetterRole) - color = valueKeywordColor; - switch (GetCurrentDefinition()) { - case ITypeDefinition t: - switch (t.Kind) { - case TypeKind.Delegate: - color = delegateTypeColor; - break; - case TypeKind.Class: - color = referenceTypeColor; - break; - case TypeKind.Interface: - color = interfaceTypeColor; - break; - case TypeKind.Enum: - color = enumerationTypeColor; - break; - case TypeKind.Struct: - color = valueTypeColor; - break; - } - break; - case IMethod m: - color = methodDeclarationColor; - break; - case IField f: - color = fieldDeclarationColor; - break; - } - switch (GetCurrentMemberReference()) { - case IType t: - switch (t.Kind) { - case TypeKind.Delegate: - color = delegateTypeColor; - break; - case TypeKind.Class: - color = referenceTypeColor; - break; - case TypeKind.Interface: - color = interfaceTypeColor; - break; - case TypeKind.Enum: - color = enumerationTypeColor; - break; - case TypeKind.Struct: - color = valueTypeColor; - break; - } - break; - case IMethod m: - color = methodCallColor; - break; - case IField f: - color = fieldAccessColor; - break; - } - if (color != null) { - textOutput.BeginSpan(color); - } - base.WriteIdentifier(identifier); - if (color != null) { - textOutput.EndSpan(); - } - } - - public override void WritePrimitiveValue(object value, string literalValue = null) - { - HighlightingColor color = null; - if (value is null) { - color = valueKeywordColor; - } - if (value is true || value is false) { - color = trueKeywordColor; - } - if (color != null) { - textOutput.BeginSpan(color); - } - base.WritePrimitiveValue(value, literalValue); - if (color != null) { - textOutput.EndSpan(); - } - } - - ISymbol GetCurrentDefinition() - { - if (nodeStack == null || nodeStack.Count == 0) - return null; - - var node = nodeStack.Peek(); - if (node is Identifier) - node = node.Parent; - if (IsDefinition(ref node)) - return node.GetSymbol(); - - return null; - } - - static bool IsDefinition(ref AstNode node) - { - if (node is EntityDeclaration) - return true; - if (node is VariableInitializer && node.Parent is FieldDeclaration) { - node = node.Parent; - return true; - } - if (node is FixedVariableInitializer) - return true; - return false; - } - - ISymbol GetCurrentMemberReference() - { - AstNode node = nodeStack.Peek(); - var symbol = node.GetSymbol(); - if (symbol == null && node.Role == Roles.TargetExpression && node.Parent is InvocationExpression) { - symbol = node.Parent.GetSymbol(); - } - if (symbol != null && node.Parent is ObjectCreateExpression) { - symbol = node.Parent.GetSymbol(); - } - if (node is IdentifierExpression && node.Role == Roles.TargetExpression && node.Parent is InvocationExpression && symbol is IMember member) { - var declaringType = member.DeclaringType; - if (declaringType != null && declaringType.Kind == TypeKind.Delegate) - return null; - } - return symbol; - } - - Stack nodeStack = new Stack(); - - public override void StartNode(AstNode node) - { - nodeStack.Push(node); - base.StartNode(node); - } - - public override void EndNode(AstNode node) - { - base.EndNode(node); - nodeStack.Pop(); - } - } } } diff --git a/ILSpy/Languages/CSharpLexer.cs b/ILSpy/Languages/CSharpLexer.cs index 42bab3925..4d839adee 100644 --- a/ILSpy/Languages/CSharpLexer.cs +++ b/ILSpy/Languages/CSharpLexer.cs @@ -101,35 +101,11 @@ namespace ICSharpCode.ILSpy protected Literal curToken = null; protected Literal peekToken = null; - string[] specialCommentTags = null; protected StringBuilder sb = new StringBuilder(); // used for the original value of strings (with escape sequences). protected StringBuilder originalValue = new StringBuilder(); - - public bool SkipAllComments { get; set; } - public bool EvaluateConditionalCompilation { get; set; } - public virtual IDictionary ConditionalCompilationSymbols { - get { throw new NotSupportedException(); } - } - - protected static IEnumerable GetSymbols(string symbols) - { - if (!string.IsNullOrEmpty(symbols)) { - foreach (string symbol in symbols.Split(';', ' ', '\t')) { - string s = symbol.Trim(); - if (s.Length == 0) - continue; - yield return s; - } - } - } - - public virtual void SetConditionalCompilationSymbols(string symbols) - { - throw new NotSupportedException(); - } - + protected int Line { get { return line; @@ -367,8 +343,6 @@ namespace ICSharpCode.ILSpy internal sealed class Lexer : AbstractLexer { - bool isAtLineBegin = true; - public Lexer(TextReader reader) : base(reader) { } @@ -376,10 +350,6 @@ namespace ICSharpCode.ILSpy protected override Literal Next() { char ch; - if (Line == 1 && Col == 1) { - isAtLineBegin = true; - } - while (true) { int nextChar = ReaderRead(); if (nextChar == -1) @@ -394,18 +364,36 @@ namespace ICSharpCode.ILSpy case '\r': case '\n': HandleLineEnd((char)nextChar); - isAtLineBegin = true; continue; case '"': token = ReadString(); - isAtLineBegin = false; break; case '\'': token = ReadChar(); - isAtLineBegin = false; break; - default: - isAtLineBegin = false; // non-ws chars are handled here + case '@': + int next = ReaderRead(); + if (next == -1) { + Error(Line, Col, String.Format("EOF after @")); + continue; + } else { + int x = Col - 1; + int y = Line; + ch = (char)next; + if (ch == '"') { + token = ReadVerbatimString(); + } else if (Char.IsLetterOrDigit(ch) || ch == '_') { + bool canBeKeyword; + string s = ReadIdent(ch, out canBeKeyword); + return new Literal(null, null, LiteralFormat.None); + } else { + HandleLineEnd(ch); + Error(y, x, String.Format("Unexpected char in Lexer.Next() : {0}", ch)); + continue; + } + } + break; + default: // non-ws chars are handled here ch = (char)nextChar; if (Char.IsLetter(ch) || ch == '_' || ch == '\\') { int x = Col - 1; // Col was incremented above, but we want the start of the identifier @@ -441,16 +429,26 @@ namespace ICSharpCode.ILSpy while (true) { if (ch == '\\') { peek = ReaderPeek(); + if (peek != 'u' && peek != 'U') { + Error(Line, Col, "Identifiers can only contain unicode escape sequences"); + } canBeKeyword = false; string surrogatePair; ReadEscapeSequence(out ch, out surrogatePair); if (surrogatePair != null) { + if (!char.IsLetterOrDigit(surrogatePair, 0)) { + Error(Line, Col, "Unicode escape sequences in identifiers cannot be used to represent characters that are invalid in identifiers"); + } for (int i = 0; i < surrogatePair.Length - 1; i++) { if (curPos < MAX_IDENTIFIER_LENGTH) { identBuffer[curPos++] = surrogatePair[i]; } } ch = surrogatePair[surrogatePair.Length - 1]; + } else { + if (!IsIdentifierPart(ch)) { + Error(Line, Col, "Unicode escape sequences in identifiers cannot be used to represent characters that are invalid in identifiers"); + } } } @@ -459,6 +457,7 @@ namespace ICSharpCode.ILSpy // prevents \ from being added identBuffer[curPos++] = ch; } else { + Error(Line, Col, String.Format("Identifier too long")); while (IsIdentifierPart(ReaderPeek())) { ReaderRead(); } @@ -507,6 +506,7 @@ namespace ICSharpCode.ILSpy } if (sb.Length == 0) { sb.Append('0'); // dummy value to prevent exception + Error(y, x, "Invalid hexadecimal integer literal"); } ishex = true; prefix = "0x"; @@ -527,6 +527,9 @@ namespace ICSharpCode.ILSpy peek = '.'; } else { isdouble = true; // double is default + if (ishex) { + Error(y, x, "No hexadecimal floating point values allowed"); + } sb.Append('.'); while (Char.IsDigit((char)ReaderPeek())) { // read decimal digits beyond the dot @@ -592,6 +595,7 @@ namespace ICSharpCode.ILSpy if (float.TryParse(digit, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) { return new Literal(stringValue, num, LiteralFormat.DecimalNumber); } else { + Error(y, x, String.Format("Can't parse float {0}", digit)); return new Literal(stringValue, 0f, LiteralFormat.DecimalNumber); } } @@ -600,6 +604,7 @@ namespace ICSharpCode.ILSpy if (decimal.TryParse(digit, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) { return new Literal(stringValue, num, LiteralFormat.DecimalNumber); } else { + Error(y, x, String.Format("Can't parse decimal {0}", digit)); return new Literal(stringValue, 0m, LiteralFormat.DecimalNumber); } } @@ -608,7 +613,7 @@ namespace ICSharpCode.ILSpy if (double.TryParse(digit, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) { return new Literal(stringValue, num, LiteralFormat.DecimalNumber); } else { - + Error(y, x, String.Format("Can't parse double {0}", digit)); return new Literal(stringValue, 0d, LiteralFormat.DecimalNumber); } } @@ -617,12 +622,12 @@ namespace ICSharpCode.ILSpy ulong result; if (ishex) { if (!ulong.TryParse(digit, NumberStyles.HexNumber, null, out result)) { - + Error(y, x, String.Format("Can't parse hexadecimal constant {0}", digit)); return new Literal(stringValue.ToString(), 0, LiteralFormat.HexadecimalNumber); } } else { if (!ulong.TryParse(digit, NumberStyles.Integer, null, out result)) { - + Error(y, x, String.Format("Can't parse integral constant {0}", digit)); return new Literal(stringValue.ToString(), 0, LiteralFormat.DecimalNumber); } } @@ -645,7 +650,7 @@ namespace ICSharpCode.ILSpy if (ulong.TryParse(digit, ishex ? NumberStyles.HexNumber : NumberStyles.Number, CultureInfo.InvariantCulture, out num)) { token = new Literal(stringValue, num, literalFormat); } else { - + Error(y, x, String.Format("Can't parse unsigned long {0}", digit)); token = new Literal(stringValue, 0UL, literalFormat); } } else { @@ -653,7 +658,7 @@ namespace ICSharpCode.ILSpy if (long.TryParse(digit, ishex ? NumberStyles.HexNumber : NumberStyles.Number, CultureInfo.InvariantCulture, out num)) { token = new Literal(stringValue, num, literalFormat); } else { - + Error(y, x, String.Format("Can't parse long {0}", digit)); token = new Literal(stringValue, 0L, literalFormat); } } @@ -663,7 +668,7 @@ namespace ICSharpCode.ILSpy if (uint.TryParse(digit, ishex ? NumberStyles.HexNumber : NumberStyles.Number, CultureInfo.InvariantCulture, out num)) { token = new Literal(stringValue, num, literalFormat); } else { - + Error(y, x, String.Format("Can't parse unsigned int {0}", digit)); token = new Literal(stringValue, (uint)0, literalFormat); } } else { @@ -671,7 +676,7 @@ namespace ICSharpCode.ILSpy if (int.TryParse(digit, ishex ? NumberStyles.HexNumber : NumberStyles.Number, CultureInfo.InvariantCulture, out num)) { token = new Literal(stringValue, num, literalFormat); } else { - + Error(y, x, String.Format("Can't parse int {0}", digit)); token = new Literal(stringValue, 0, literalFormat); } } @@ -711,7 +716,7 @@ namespace ICSharpCode.ILSpy } } else if (HandleLineEnd(ch)) { // call HandleLineEnd to ensure line numbers are still correct after the error - + Error(y, x, "No new line is allowed inside a string literal"); break; } else { originalValue.Append(ch); @@ -720,7 +725,7 @@ namespace ICSharpCode.ILSpy } if (!doneNormally) { - + Error(y, x, "End of file reached inside string literal"); } return new Literal(originalValue.ToString(), sb.ToString(), LiteralFormat.StringLiteral); @@ -753,7 +758,7 @@ namespace ICSharpCode.ILSpy } if (nextChar == -1) { - + Error(Line, Col, "End of file reached inside verbatim string literal"); } return new Literal(originalValue.ToString(), sb.ToString(), LiteralFormat.VerbatimStringLiteral); @@ -777,6 +782,7 @@ namespace ICSharpCode.ILSpy int nextChar = ReaderRead(); if (nextChar == -1) { + Error(Line, Col, "End of file reached inside escape sequence"); ch = '\0'; return String.Empty; } @@ -825,6 +831,9 @@ namespace ICSharpCode.ILSpy number = GetHexNumber(c); escapeSequenceBuffer[curPos++] = c; + if (number < 0) { + Error(Line, Col - 1, String.Format("Invalid char in literal : {0}", c)); + } for (int i = 0; i < 3; ++i) { if (IsHex((char)ReaderPeek())) { c = (char)ReaderRead(); @@ -847,6 +856,7 @@ namespace ICSharpCode.ILSpy escapeSequenceBuffer[curPos++] = c; number = 16 * number + idx; } else { + Error(Line, Col - 1, String.Format("Invalid char in literal : {0}", (char)ReaderPeek())); break; } } @@ -858,6 +868,7 @@ namespace ICSharpCode.ILSpy } break; default: + Error(Line, Col, String.Format("Unexpected escape sequence : {0}", c)); ch = '\0'; break; } @@ -879,16 +890,20 @@ namespace ICSharpCode.ILSpy string surrogatePair; escapeSequence = ReadEscapeSequence(out chValue, out surrogatePair); if (surrogatePair != null) { - + Error(y, x, "The unicode character must be represented by a surrogate pair and does not fit into a System.Char"); } } unchecked { if ((char)ReaderRead() != '\'') { - + Error(y, x, "Char not terminated"); } } return new Literal("'" + ch + escapeSequence + "'", chValue, LiteralFormat.CharLiteral); } + + void Error(int y, int x, string message) + { + } } } diff --git a/ILSpy/Languages/ILAstLanguage.cs b/ILSpy/Languages/ILAstLanguage.cs index 488926a76..88a6601e6 100644 --- a/ILSpy/Languages/ILAstLanguage.cs +++ b/ILSpy/Languages/ILAstLanguage.cs @@ -53,47 +53,6 @@ namespace ICSharpCode.ILSpy } public override string Name { get { return name; } } - /* - public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options) - { - if (!method.HasBody) { - return; - } - - ILAstBuilder astBuilder = new ILAstBuilder(); - ILBlock ilMethod = new ILBlock(); - DecompilerContext context = new DecompilerContext(method.Module) { CurrentType = method.DeclaringType, CurrentMethod = method }; - ilMethod.Body = astBuilder.Build(method, inlineVariables, context); - - if (abortBeforeStep != null) { - new ILAstOptimizer().Optimize(context, ilMethod, abortBeforeStep.Value); - } - - if (context.CurrentMethodIsAsync) - output.WriteLine("async/await"); - - var allVariables = ilMethod.GetSelfAndChildrenRecursive().Select(e => e.Operand as ILVariable) - .Where(v => v != null && !v.IsParameter).Distinct(); - foreach (ILVariable v in allVariables) { - output.WriteDefinition(v.Name, v); - if (v.Type != null) { - output.Write(" : "); - if (v.IsPinned) - output.Write("pinned "); - v.Type.WriteTo(output, ILNameSyntax.ShortTypeName); - } - if (v.IsGenerated) { - output.Write(" [generated]"); - } - output.WriteLine(); - } - output.WriteLine(); - - foreach (ILNode node in ilMethod.Body) { - node.WriteTo(output); - output.WriteLine(); - } - }*/ internal static IEnumerable GetDebugLanguages() { @@ -118,7 +77,7 @@ namespace ICSharpCode.ILSpy public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options) { base.DecompileMethod(method, output, options); - new ReflectionDisassembler(output, false, options.CancellationToken).DisassembleMethodHeader(method); + new ReflectionDisassembler(output, options.CancellationToken).DisassembleMethodHeader(method); output.WriteLine(); output.WriteLine(); } @@ -141,10 +100,6 @@ namespace ICSharpCode.ILSpy class BlockIL : ILAstLanguage { readonly IReadOnlyList transforms; - readonly ILAstWritingOptions writingOptions = new ILAstWritingOptions { - UseFieldSugar = true, - UseLogicOperationSugar = true - }; public BlockIL(IReadOnlyList transforms) : base("ILAst") { @@ -169,6 +124,10 @@ namespace ICSharpCode.ILSpy try { il.RunTransforms(transforms, context); } catch (StepLimitReachedException) { + } catch (Exception ex) { + output.WriteLine(ex.ToString()); + output.WriteLine(); + output.WriteLine("ILAst after the crash:"); } finally { // update stepper even if a transform crashed unexpectedly if (options.StepLimit == int.MaxValue) { @@ -176,27 +135,11 @@ namespace ICSharpCode.ILSpy OnStepperUpdated(new EventArgs()); } } - (output as ISmartTextOutput)?.AddUIElement(OptionsCheckBox(nameof(writingOptions.UseFieldSugar))); - output.WriteLine(); - (output as ISmartTextOutput)?.AddUIElement(OptionsCheckBox(nameof(writingOptions.UseLogicOperationSugar))); - output.WriteLine(); (output as ISmartTextOutput)?.AddButton(Images.ViewCode, "Show Steps", delegate { DebugSteps.Show(); }); output.WriteLine(); - il.WriteTo(output, writingOptions); - } - - Func OptionsCheckBox(string propertyName) - { - return () => { - var checkBox = new System.Windows.Controls.CheckBox(); - checkBox.Content = propertyName; - checkBox.Cursor = System.Windows.Input.Cursors.Arrow; - checkBox.SetBinding(System.Windows.Controls.CheckBox.IsCheckedProperty, - new System.Windows.Data.Binding(propertyName) { Source = writingOptions }); - return checkBox; - }; + il.WriteTo(output, DebugSteps.Options); } } } diff --git a/ILSpy/Languages/ILLanguage.cs b/ILSpy/Languages/ILLanguage.cs index 817586d95..9e618150a 100644 --- a/ILSpy/Languages/ILLanguage.cs +++ b/ILSpy/Languages/ILLanguage.cs @@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy [Export(typeof(Language))] public class ILLanguage : Language { - private readonly bool detectControlStructure = true; + protected bool detectControlStructure = true; public override string Name { get { return "IL"; } @@ -44,21 +44,29 @@ namespace ICSharpCode.ILSpy get { return ".il"; } } + protected virtual ReflectionDisassembler CreateDisassembler(ITextOutput output, DecompilationOptions options) + { + return new ReflectionDisassembler(output, options.CancellationToken) { + DetectControlStructure = detectControlStructure, + ShowSequencePoints = options.DecompilerSettings.ShowDebugInfo + }; + } + public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options) { - var dis = new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken); + var dis = CreateDisassembler(output, options); dis.DisassembleMethod(method); } public override void DecompileField(FieldDefinition field, ITextOutput output, DecompilationOptions options) { - var dis = new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken); + var dis = CreateDisassembler(output, options); dis.DisassembleField(field); } public override void DecompileProperty(PropertyDefinition property, ITextOutput output, DecompilationOptions options) { - ReflectionDisassembler rd = new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken); + ReflectionDisassembler rd = CreateDisassembler(output, options); rd.DisassembleProperty(property); if (property.GetMethod != null) { output.WriteLine(); @@ -76,7 +84,7 @@ namespace ICSharpCode.ILSpy public override void DecompileEvent(EventDefinition ev, ITextOutput output, DecompilationOptions options) { - ReflectionDisassembler rd = new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken); + ReflectionDisassembler rd = CreateDisassembler(output, options); rd.DisassembleEvent(ev); if (ev.AddMethod != null) { output.WriteLine(); @@ -94,13 +102,14 @@ namespace ICSharpCode.ILSpy public override void DecompileType(TypeDefinition type, ITextOutput output, DecompilationOptions options) { - var dis = new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken); + var dis = CreateDisassembler(output, options); dis.DisassembleType(type); } public override void DecompileNamespace(string nameSpace, IEnumerable types, ITextOutput output, DecompilationOptions options) { - new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken).DisassembleNamespace(nameSpace, types); + var dis = CreateDisassembler(output, options); + dis.DisassembleNamespace(nameSpace, types); } public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options) @@ -108,17 +117,17 @@ namespace ICSharpCode.ILSpy output.WriteLine("// " + assembly.FileName); output.WriteLine(); - ReflectionDisassembler rd = new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken); + var dis = CreateDisassembler(output, options); if (options.FullDecompilation) - rd.WriteAssemblyReferences(assembly.ModuleDefinition); + dis.WriteAssemblyReferences(assembly.ModuleDefinition); if (assembly.AssemblyDefinition != null) - rd.WriteAssemblyHeader(assembly.AssemblyDefinition); + dis.WriteAssemblyHeader(assembly.AssemblyDefinition); output.WriteLine(); - rd.WriteModuleHeader(assembly.ModuleDefinition); + dis.WriteModuleHeader(assembly.ModuleDefinition); if (options.FullDecompilation) { output.WriteLine(); output.WriteLine(); - rd.WriteModuleContents(assembly.ModuleDefinition); + dis.WriteModuleContents(assembly.ModuleDefinition); } } diff --git a/ILSpy/Languages/Languages.cs b/ILSpy/Languages/Languages.cs index 2cf2e5632..2312f7ec5 100644 --- a/ILSpy/Languages/Languages.cs +++ b/ILSpy/Languages/Languages.cs @@ -43,6 +43,7 @@ namespace ICSharpCode.ILSpy { List languages = new List(); languages.AddRange(composition.GetExportedValues()); + languages.Sort((a, b) => a.Name.CompareTo(b.Name)); #if DEBUG languages.AddRange(ILAstLanguage.GetDebugLanguages()); languages.AddRange(CSharpLanguage.GetDebugLanguages()); diff --git a/ILSpy/LoadedAssembly.cs b/ILSpy/LoadedAssembly.cs index 3b89c1951..e37683f02 100644 --- a/ILSpy/LoadedAssembly.cs +++ b/ILSpy/LoadedAssembly.cs @@ -51,13 +51,14 @@ namespace ICSharpCode.ILSpy this.assemblyTask = Task.Factory.StartNew(LoadAssembly, stream); // requires that this.fileName is set this.shortName = Path.GetFileNameWithoutExtension(fileName); - this.targetFrameworkId = new Lazy(AssemblyDefinition.DetectTargetFrameworkId, false); + this.targetFrameworkId = new Lazy(() => AssemblyDefinition?.DetectTargetFrameworkId(), false); } /// /// Returns a target framework identifier in the form '<framework>Version=v<version>'. + /// Returns an empty string if no TargetFrameworkAttribute was found or the file doesn't contain an assembly header, i.e., is only a module. /// - public string TargetFrameworkId => targetFrameworkId.Value; + public string TargetFrameworkId => targetFrameworkId.Value ?? string.Empty; public Dictionary LoadedAssemblyReferencesInfo => loadedAssemblyReferences; diff --git a/ILSpy/OpenListDialog.xaml b/ILSpy/OpenListDialog.xaml index edac744f6..8428df3fa 100644 --- a/ILSpy/OpenListDialog.xaml +++ b/ILSpy/OpenListDialog.xaml @@ -28,14 +28,14 @@ - + - - - - + + + + diff --git a/ILSpy/Options/DecompilerSettingsPanel.xaml b/ILSpy/Options/DecompilerSettingsPanel.xaml index ecad2b28b..e43c553d3 100644 --- a/ILSpy/Options/DecompilerSettingsPanel.xaml +++ b/ILSpy/Options/DecompilerSettingsPanel.xaml @@ -11,6 +11,7 @@ Decompile expression trees Decompile automatic properties Use variable names from debug symbols, if available + Show info from debug symbols, if available Show XML documentation in decompiled code Enable folding on all blocks in braces diff --git a/ILSpy/Options/DecompilerSettingsPanel.xaml.cs b/ILSpy/Options/DecompilerSettingsPanel.xaml.cs index b013aa708..8541be53d 100644 --- a/ILSpy/Options/DecompilerSettingsPanel.xaml.cs +++ b/ILSpy/Options/DecompilerSettingsPanel.xaml.cs @@ -58,6 +58,7 @@ namespace ICSharpCode.ILSpy.Options s.QueryExpressions = (bool?)e.Attribute("queryExpressions") ?? s.QueryExpressions; s.ExpressionTrees = (bool?)e.Attribute("expressionTrees") ?? s.ExpressionTrees; s.UseDebugSymbols = (bool?)e.Attribute("useDebugSymbols") ?? s.UseDebugSymbols; + s.ShowDebugInfo = (bool?)e.Attribute("showDebugInfo") ?? s.ShowDebugInfo; s.ShowXmlDocumentation = (bool?)e.Attribute("xmlDoc") ?? s.ShowXmlDocumentation; s.FoldBraces = (bool?)e.Attribute("foldBraces") ?? s.FoldBraces; return s; @@ -75,6 +76,7 @@ namespace ICSharpCode.ILSpy.Options section.SetAttributeValue("queryExpressions", s.QueryExpressions); section.SetAttributeValue("expressionTrees", s.ExpressionTrees); section.SetAttributeValue("useDebugSymbols", s.UseDebugSymbols); + section.SetAttributeValue("showDebugInfo", s.ShowDebugInfo); section.SetAttributeValue("xmlDoc", s.ShowXmlDocumentation); section.SetAttributeValue("foldBraces", s.FoldBraces); diff --git a/ILSpy/Properties/AssemblyInfo.template.cs b/ILSpy/Properties/AssemblyInfo.template.cs index b40fac15c..140434136 100644 --- a/ILSpy/Properties/AssemblyInfo.template.cs +++ b/ILSpy/Properties/AssemblyInfo.template.cs @@ -42,7 +42,7 @@ internal static class RevisionClass public const string Minor = "0"; public const string Build = "0"; public const string Revision = "$INSERTREVISION$"; - public const string VersionName = null; + public const string VersionName = "beta1"; public const string FullVersion = Major + "." + Minor + "." + Build + ".$INSERTREVISION$$INSERTBRANCHPOSTFIX$$INSERTVERSIONNAMEPOSTFIX$"; } diff --git a/ILSpy/TextView/DecompilerTextView.cs b/ILSpy/TextView/DecompilerTextView.cs index ad52a7046..b8fea2606 100644 --- a/ILSpy/TextView/DecompilerTextView.cs +++ b/ILSpy/TextView/DecompilerTextView.cs @@ -106,7 +106,8 @@ namespace ICSharpCode.ILSpy.TextView textEditor.Options.RequireControlModifierForHyperlinkClick = false; textEditor.TextArea.TextView.MouseHover += TextViewMouseHover; textEditor.TextArea.TextView.MouseHoverStopped += TextViewMouseHoverStopped; - textEditor.TextArea.TextView.MouseDown += TextViewMouseDown; + textEditor.TextArea.PreviewMouseDown += TextAreaMouseDown; + textEditor.TextArea.PreviewMouseUp += TextAreaMouseUp; textEditor.SetBinding(Control.FontFamilyProperty, new Binding { Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("SelectedFont") }); textEditor.SetBinding(Control.FontSizeProperty, new Binding { Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("SelectedFontSize") }); textEditor.SetBinding(TextEditor.WordWrapProperty, new Binding { Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("EnableWordWrap") }); @@ -602,12 +603,36 @@ namespace ICSharpCode.ILSpy.TextView MainWindow.Instance.JumpToReference(reference); } - void TextViewMouseDown(object sender, MouseButtonEventArgs e) + Point? mouseDownPos; + + void TextAreaMouseDown(object sender, MouseButtonEventArgs e) { - if (GetReferenceSegmentAtMousePosition() == null) - ClearLocalReferenceMarks(); + mouseDownPos = e.GetPosition(this); } - + + void TextAreaMouseUp(object sender, MouseButtonEventArgs e) + { + if (mouseDownPos == null) + return; + Vector dragDistance = e.GetPosition(this) - mouseDownPos.Value; + if (Math.Abs(dragDistance.X) < SystemParameters.MinimumHorizontalDragDistance + && Math.Abs(dragDistance.Y) < SystemParameters.MinimumVerticalDragDistance + && e.ChangedButton == MouseButton.Left) + { + // click without moving mouse + var referenceSegment = GetReferenceSegmentAtMousePosition(); + if (referenceSegment == null) { + ClearLocalReferenceMarks(); + } else { + JumpToReference(referenceSegment); + textEditor.TextArea.ClearSelection(); + } + // cancel mouse selection to avoid AvalonEdit selecting between the new + // cursor position and the mouse position. + textEditor.TextArea.MouseSelectionMode = MouseSelectionMode.None; + } + } + void ClearLocalReferenceMarks() { foreach (var mark in localReferenceMarks) { diff --git a/ILSpy/TextView/ReferenceElementGenerator.cs b/ILSpy/TextView/ReferenceElementGenerator.cs index 3e4e88ca0..262f7d598 100644 --- a/ILSpy/TextView/ReferenceElementGenerator.cs +++ b/ILSpy/TextView/ReferenceElementGenerator.cs @@ -105,16 +105,6 @@ namespace ICSharpCode.ILSpy.TextView e.Cursor = referenceSegment.IsLocal ? Cursors.Arrow : Cursors.Hand; } - /// - protected override void OnMouseDown(MouseButtonEventArgs e) - { - if (e.ChangedButton == MouseButton.Left && !e.Handled) { - parent.JumpToReference(referenceSegment); - if(!referenceSegment.IsLocal) - e.Handled = true; - } - } - /// protected override VisualLineText CreateInstance(int length) { diff --git a/README.md b/README.md index 3e86b98a8..e825513df 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ILSpy is the open-source .NET assembly browser and decompiler. -Download: [latest release](https://github.com/icsharpcode/ILSpy/releases) | [latest CI build](https://ci.appveyor.com/api/projects/icsharpcode/ilspy/artifacts/ILSpy_binaries.zip?branch=master&job=Configuration%3A+Release) +Download: [latest release](https://github.com/icsharpcode/ILSpy/releases) | [latest CI build (master)](https://ci.appveyor.com/api/projects/icsharpcode/ilspy/artifacts/ILSpy_binaries.zip?branch=master&job=Configuration%3A+Release) Note: Only the CI builds support .NET Standard/Core assemblies. However, those builds are not yet at feature parity with the released bits, see [C# language support status](https://github.com/icsharpcode/ILSpy/issues/829) for details. diff --git a/appveyor.yml b/appveyor.yml index 33d571e9d..ad8006791 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,4 +20,6 @@ after_test: - python BuildTools\tidy.py artifacts: - path: ILSpy_binaries.zip - name: ILSpy %APPVEYOR_REPO_BRANCH% %ILSPY_VERSION_NUMBER% binaries \ No newline at end of file + name: ILSpy %APPVEYOR_REPO_BRANCH% %ILSPY_VERSION_NUMBER% binaries + - path: '**\*.nupkg' + name: ICSharpCode.Decompiler %APPVEYOR_REPO_BRANCH% %ILSPY_VERSION_NUMBER% NuGet \ No newline at end of file