diff --git a/source/#external/ILSpy b/source/#external/ILSpy index 7360921..16fa076 160000 --- a/source/#external/ILSpy +++ b/source/#external/ILSpy @@ -1 +1 @@ -Subproject commit 73609219823ebc784757699cd54399e2c3ba6380 +Subproject commit 16fa076134a8f4a82b42eb515a660be0fa6f12b8 diff --git a/source/Server/Decompilation/ILDecompiler.cs b/source/Server/Decompilation/ILDecompiler.cs index aecee61..48b522e 100644 --- a/source/Server/Decompilation/ILDecompiler.cs +++ b/source/Server/Decompilation/ILDecompiler.cs @@ -1,4 +1,4 @@ -using System.IO; +using System.IO; using System.Threading; using ICSharpCode.Decompiler.Disassembler; using Mono.Cecil; @@ -8,6 +8,9 @@ namespace SharpLab.Server.Decompilation { public class ILDecompiler : IDecompiler { public void Decompile(Stream assemblyStream, TextWriter codeWriter) { var assembly = AssemblyDefinition.ReadAssembly(assemblyStream); + //#if DEBUG + //assembly.Write(@"d:\Temp\assembly\" + System.DateTime.Now.Ticks + "-il.dll"); + //#endif var output = new CustomizableIndentPlainTextOutput(codeWriter) { IndentationString = " " diff --git a/source/Tests/DecompilationTests.cs b/source/Tests/DecompilationTests.cs index 4d66a50..41ea620 100644 --- a/source/Tests/DecompilationTests.cs +++ b/source/Tests/DecompilationTests.cs @@ -47,8 +47,9 @@ namespace SharpLab.Tests { [InlineData("Module.vb2vb")] [InlineData("Lambda.CallInArray.cs2cs")] // https://github.com/ashmind/SharpLab/issues/9 [InlineData("Cast.ExplicitOperatorOnNull.cs2cs")] // https://github.com/ashmind/SharpLab/issues/20 - [InlineData("Goto.TryWhile.cs2cs")] // https://github.com/ashmind/SharpLab/issues/123 + [InlineData("Goto.TryWhile.cs2cs")] // https://github.com/ashmind/SharpLab/issues/123 [InlineData("Nullable.OperatorLifting.cs2cs")] // https://github.com/ashmind/SharpLab/issues/159 + [InlineData("Finalizer.Exception.cs2il")] // https://github.com/ashmind/SharpLab/issues/205 public async Task SlowUpdate_ReturnsExpectedDecompiledCode(string resourceName) { var data = TestData.FromResource(resourceName); var driver = await NewTestDriverAsync(data); diff --git a/source/Tests/TestCode/Finalizer.Exception.cs2il b/source/Tests/TestCode/Finalizer.Exception.cs2il new file mode 100644 index 0000000..0eb9b69 --- /dev/null +++ b/source/Tests/TestCode/Finalizer.Exception.cs2il @@ -0,0 +1,47 @@ +using System; +public class C { + ~C() { + throw new Exception(); + } +} + +#=> + +.class private auto ansi '' +{ +} // end of class + +.class public auto ansi beforefieldinit C + extends [mscorlib]System.Object +{ + // Methods + .method family hidebysig virtual + instance void Finalize () cil managed + { + .override method instance void [mscorlib]System.Object::Finalize() + // Method begins at RVA 0x2050 + // Code size 13 (0xd) + .maxstack 1 + + IL_0000: newobj instance void [mscorlib]System.Exception::.ctor() + IL_0005: throw + IL_0006: ldarg.0 + IL_0007: call instance void [mscorlib]System.Object::Finalize() + IL_000c: endfinally + + Try IL_0000-IL_0005 Finally IL_0006-IL_000c + } // end of method C::Finalize + + .method public hidebysig specialname rtspecialname + instance void .ctor () cil managed + { + // Method begins at RVA 0x207c + // 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 \ No newline at end of file