diff --git a/source/NetFramework/Tests/Decompilation/TestCode/Cast.ExplicitOperatorOnNull.cs b/source/NetFramework/Tests/Decompilation/TestCode/Cast.ExplicitOperatorOnNull.cs index 9b522e2e..2d8b958b 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/Cast.ExplicitOperatorOnNull.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/Cast.ExplicitOperatorOnNull.cs @@ -1,66 +1,66 @@ -public class Foo { - public static explicit operator uint? (Foo foo) => 1; -} - -public class Bar { - public void Baz() { - var x = (uint?)((Foo)null); - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: RefSafetyRules(11)] -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} -public class Foo -{ - public static explicit operator Nullable(Foo foo) - { - return 1u; - } -} -public class Bar -{ - public void Baz() - { - Nullable num = (Nullable)(Foo)null; - } -} - +public class Foo { + public static explicit operator uint? (Foo foo) => 1; +} + +public class Bar { + public void Baz() { + var x = (uint?)((Foo)null); + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; +using Microsoft.CodeAnalysis; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] +namespace Microsoft.CodeAnalysis +{ + [CompilerGenerated] + [Embedded] + internal sealed class EmbeddedAttribute : Attribute + { + } +} +namespace System.Runtime.CompilerServices +{ + [CompilerGenerated] + [Embedded] + [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] + internal sealed class RefSafetyRulesAttribute : Attribute + { + public readonly int Version; + + public RefSafetyRulesAttribute(int P_0) + { + Version = P_0; + } + } +} +public class Foo +{ + public static explicit operator Nullable(Foo foo) + { + return 1u; + } +} +public class Bar +{ + public void Baz() + { + Nullable num = (Nullable)(Foo)null; + } +} + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/Condition.SimpleSwitch.cs b/source/NetFramework/Tests/Decompilation/TestCode/Condition.SimpleSwitch.cs index d6fb73cb..e5d76e56 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/Condition.SimpleSwitch.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/Condition.SimpleSwitch.cs @@ -1,59 +1,59 @@ -public class C { - public void M(string n) { - switch(n) { - case "foo": break; - } - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: RefSafetyRules(11)] -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} -public class C -{ - public void M(string n) - { - if (n == "foo") - { - } - } -} - +public class C { + public void M(string n) { + switch(n) { + case "foo": break; + } + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; +using Microsoft.CodeAnalysis; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] +namespace Microsoft.CodeAnalysis +{ + [CompilerGenerated] + [Embedded] + internal sealed class EmbeddedAttribute : Attribute + { + } +} +namespace System.Runtime.CompilerServices +{ + [CompilerGenerated] + [Embedded] + [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] + internal sealed class RefSafetyRulesAttribute : Attribute + { + public readonly int Version; + + public RefSafetyRulesAttribute(int P_0) + { + Version = P_0; + } + } +} +public class C +{ + public void M(string n) + { + if (n == "foo") + { + } + } +} + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/Constructor.BaseCall.cs b/source/NetFramework/Tests/Decompilation/TestCode/Constructor.BaseCall.cs index 9d0e8295..e8e955c6 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/Constructor.BaseCall.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/Constructor.BaseCall.cs @@ -1,66 +1,66 @@ -public class MyBase { - public MyBase(string name) { - } -} - - -public class MyClass : MyBase { - public MyClass(string name) : base(name) { - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: RefSafetyRules(11)] -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} -public class MyBase -{ - public MyBase(string name) - { - } -} -public class MyClass : MyBase -{ - public MyClass(string name) - : base(name) - { - } -} - +public class MyBase { + public MyBase(string name) { + } +} + + +public class MyClass : MyBase { + public MyClass(string name) : base(name) { + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; +using Microsoft.CodeAnalysis; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] +namespace Microsoft.CodeAnalysis +{ + [CompilerGenerated] + [Embedded] + internal sealed class EmbeddedAttribute : Attribute + { + } +} +namespace System.Runtime.CompilerServices +{ + [CompilerGenerated] + [Embedded] + [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] + internal sealed class RefSafetyRulesAttribute : Attribute + { + public readonly int Version; + + public RefSafetyRulesAttribute(int P_0) + { + Version = P_0; + } + } +} +public class MyBase +{ + public MyBase(string name) + { + } +} +public class MyClass : MyBase +{ + public MyClass(string name) + : base(name) + { + } +} + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/Finalizer.Exception.cs b/source/NetFramework/Tests/Decompilation/TestCode/Finalizer.Exception.cs index 9e475731..7f5b46c8 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/Finalizer.Exception.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/Finalizer.Exception.cs @@ -1,144 +1,144 @@ -using System; -public class C { - ~C() { - throw new Exception(); - } -} - -/* il - -.assembly _ -{ - .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 - 63 65 70 74 69 6f 6e 54 68 72 6f 77 73 01 - ) - .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( - 01 00 02 00 00 00 00 00 - ) - .permissionset reqmin = ( - 2e 01 80 84 53 79 73 74 65 6d 2e 53 65 63 75 72 - 69 74 79 2e 50 65 72 6d 69 73 73 69 6f 6e 73 2e - 53 65 63 75 72 69 74 79 50 65 72 6d 69 73 73 69 - 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 6d 73 63 - 6f 72 6c 69 62 2c 20 56 65 72 73 69 6f 6e 3d 34 - 2e 30 2e 30 2e 30 2c 20 43 75 6c 74 75 72 65 3d - 6e 65 75 74 72 61 6c 2c 20 50 75 62 6c 69 63 4b - 65 79 54 6f 6b 65 6e 3d 62 37 37 61 35 63 35 36 - 31 39 33 34 65 30 38 39 15 01 54 02 10 53 6b 69 - 70 56 65 72 69 66 69 63 61 74 69 6f 6e 01 - ) - .hash algorithm 0x // SHA1 - .ver 0:0:0:0 -} - -.class private auto ansi '' -{ -} // end of class - -.class private auto ansi sealed beforefieldinit Microsoft.CodeAnalysis.EmbeddedAttribute - extends [mscorlib]System.Attribute -{ - .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( - 01 00 00 00 - ) - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor () cil managed - { - // Method begins at RVA 0x2050 - // Code size 7 (0x7) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [mscorlib]System.Attribute::.ctor() - IL_0006: ret - } // end of method EmbeddedAttribute::.ctor - -} // end of class Microsoft.CodeAnalysis.EmbeddedAttribute - -.class private auto ansi sealed beforefieldinit System.Runtime.CompilerServices.RefSafetyRulesAttribute - extends [mscorlib]System.Attribute -{ - .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void [mscorlib]System.AttributeUsageAttribute::.ctor(valuetype [mscorlib]System.AttributeTargets) = ( - 01 00 02 00 00 00 02 00 54 02 0d 41 6c 6c 6f 77 - 4d 75 6c 74 69 70 6c 65 00 54 02 09 49 6e 68 65 - 72 69 74 65 64 00 - ) - // Fields - .field public initonly int32 Version - - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor ( - int32 '' - ) cil managed - { - // Method begins at RVA 0x2058 - // Code size 14 (0xe) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [mscorlib]System.Attribute::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld int32 System.Runtime.CompilerServices.RefSafetyRulesAttribute::Version - IL_000d: ret - } // end of method RefSafetyRulesAttribute::.ctor - -} // end of class System.Runtime.CompilerServices.RefSafetyRulesAttribute - -.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 0x2068 - // Code size 13 (0xd) - .maxstack 1 - - .try - { - // sequence point: (line 4, col 9) to (line 4, col 31) in _ - IL_0000: newobj instance void [mscorlib]System.Exception::.ctor() - IL_0005: throw - } // end .try - finally - { - // sequence point: (line 5, col 5) to (line 5, col 6) in _ - IL_0006: ldarg.0 - IL_0007: call instance void [mscorlib]System.Object::Finalize() - IL_000c: endfinally - } // end handler - } // end of method C::Finalize - - .method public hidebysig specialname rtspecialname - instance void .ctor () cil managed - { - // Method begins at RVA 0x2094 - // 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 - +using System; +public class C { + ~C() { + throw new Exception(); + } +} + +/* il + +.assembly _ +{ + .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 + 63 65 70 74 69 6f 6e 54 68 72 6f 77 73 01 + ) + .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( + 01 00 02 00 00 00 00 00 + ) + .permissionset reqmin = ( + 2e 01 80 84 53 79 73 74 65 6d 2e 53 65 63 75 72 + 69 74 79 2e 50 65 72 6d 69 73 73 69 6f 6e 73 2e + 53 65 63 75 72 69 74 79 50 65 72 6d 69 73 73 69 + 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 6d 73 63 + 6f 72 6c 69 62 2c 20 56 65 72 73 69 6f 6e 3d 34 + 2e 30 2e 30 2e 30 2c 20 43 75 6c 74 75 72 65 3d + 6e 65 75 74 72 61 6c 2c 20 50 75 62 6c 69 63 4b + 65 79 54 6f 6b 65 6e 3d 62 37 37 61 35 63 35 36 + 31 39 33 34 65 30 38 39 15 01 54 02 10 53 6b 69 + 70 56 65 72 69 66 69 63 61 74 69 6f 6e 01 + ) + .hash algorithm 0x // SHA1 + .ver 0:0:0:0 +} + +.class private auto ansi '' +{ +} // end of class + +.class private auto ansi sealed beforefieldinit Microsoft.CodeAnalysis.EmbeddedAttribute + extends [mscorlib]System.Attribute +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( + 01 00 00 00 + ) + .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( + 01 00 00 00 + ) + // Methods + .method public hidebysig specialname rtspecialname + instance void .ctor () cil managed + { + // Method begins at RVA 0x2050 + // Code size 7 (0x7) + .maxstack 8 + + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Attribute::.ctor() + IL_0006: ret + } // end of method EmbeddedAttribute::.ctor + +} // end of class Microsoft.CodeAnalysis.EmbeddedAttribute + +.class private auto ansi sealed beforefieldinit System.Runtime.CompilerServices.RefSafetyRulesAttribute + extends [mscorlib]System.Attribute +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( + 01 00 00 00 + ) + .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( + 01 00 00 00 + ) + .custom instance void [mscorlib]System.AttributeUsageAttribute::.ctor(valuetype [mscorlib]System.AttributeTargets) = ( + 01 00 02 00 00 00 02 00 54 02 0d 41 6c 6c 6f 77 + 4d 75 6c 74 69 70 6c 65 00 54 02 09 49 6e 68 65 + 72 69 74 65 64 00 + ) + // Fields + .field public initonly int32 Version + + // Methods + .method public hidebysig specialname rtspecialname + instance void .ctor ( + int32 '' + ) cil managed + { + // Method begins at RVA 0x2058 + // Code size 14 (0xe) + .maxstack 8 + + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 System.Runtime.CompilerServices.RefSafetyRulesAttribute::Version + IL_000d: ret + } // end of method RefSafetyRulesAttribute::.ctor + +} // end of class System.Runtime.CompilerServices.RefSafetyRulesAttribute + +.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 0x2068 + // Code size 13 (0xd) + .maxstack 1 + + .try + { + // sequence point: (line 4, col 9) to (line 4, col 31) in _ + IL_0000: newobj instance void [mscorlib]System.Exception::.ctor() + IL_0005: throw + } // end .try + finally + { + // sequence point: (line 5, col 5) to (line 5, col 6) in _ + IL_0006: ldarg.0 + IL_0007: call instance void [mscorlib]System.Object::Finalize() + IL_000c: endfinally + } // end handler + } // end of method C::Finalize + + .method public hidebysig specialname rtspecialname + instance void .ctor () cil managed + { + // Method begins at RVA 0x2094 + // 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 diff --git a/source/NetFramework/Tests/Decompilation/TestCode/Goto.TryWhile.cs b/source/NetFramework/Tests/Decompilation/TestCode/Goto.TryWhile.cs index bff47f05..9e1246fe 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/Goto.TryWhile.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/Goto.TryWhile.cs @@ -1,72 +1,72 @@ -using System; -public class C { - void M() { - again: try { - while(true) {} - } - catch { - goto again; - } - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: RefSafetyRules(11)] -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} -public class C -{ - private void M() - { - while (true) - { - try - { - while (true) - { - } - } - catch - { - } - } - } -} - +using System; +public class C { + void M() { + again: try { + while(true) {} + } + catch { + goto again; + } + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; +using Microsoft.CodeAnalysis; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] +namespace Microsoft.CodeAnalysis +{ + [CompilerGenerated] + [Embedded] + internal sealed class EmbeddedAttribute : Attribute + { + } +} +namespace System.Runtime.CompilerServices +{ + [CompilerGenerated] + [Embedded] + [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] + internal sealed class RefSafetyRulesAttribute : Attribute + { + public readonly int Version; + + public RefSafetyRulesAttribute(int P_0) + { + Version = P_0; + } + } +} +public class C +{ + private void M() + { + while (true) + { + try + { + while (true) + { + } + } + catch + { + } + } + } +} + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/ArrayElement.cs b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/ArrayElement.cs index 4966dd85..3ee34e29 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/ArrayElement.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/ArrayElement.cs @@ -1,28 +1,28 @@ -static class C { - static int M(int[] x) { - return x[0]; - } -} - -/* asm - -; Desktop CLR on amd64 - -Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() - L0000: ret - -System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) - L0000: mov [rcx+0x8], edx - L0003: ret - -C.M(Int32[]) - L0000: sub rsp, 0x28 - L0004: cmp dword [rcx+0x8], 0x0 - L0008: jbe L0012 - L000a: mov eax, [rcx+0x10] - L000d: add rsp, 0x28 - L0011: ret - L0012: call 0x - L0017: int3 - +static class C { + static int M(int[] x) { + return x[0]; + } +} + +/* asm + +; Desktop CLR on amd64 + +Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() + L0000: ret + +System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) + L0000: mov [rcx+0x8], edx + L0003: ret + +C.M(Int32[]) + L0000: sub rsp, 0x28 + L0004: cmp dword [rcx+0x8], 0x0 + L0008: jbe L0012 + L000a: mov eax, [rcx+0x10] + L000d: add rsp, 0x28 + L0011: ret + L0012: call 0x + L0017: int3 + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Delegate.cs b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Delegate.cs index 3e267b27..e95aea6f 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Delegate.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Delegate.cs @@ -1,26 +1,26 @@ -delegate void D(); - -/* asm - -; Desktop CLR on amd64 - -Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() - L0000: ret - -System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) - L0000: mov [rcx+0x8], edx - L0003: ret - -D..ctor(System.Object, IntPtr) - ; Cannot produce JIT assembly for runtime-implemented method. - -D.Invoke() - ; Cannot produce JIT assembly for runtime-implemented method. - -D.BeginInvoke(System.AsyncCallback, System.Object) - ; Cannot produce JIT assembly for runtime-implemented method. - -D.EndInvoke(System.IAsyncResult) - ; Cannot produce JIT assembly for runtime-implemented method. - +delegate void D(); + +/* asm + +; Desktop CLR on amd64 + +Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() + L0000: ret + +System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) + L0000: mov [rcx+0x8], edx + L0003: ret + +D..ctor(System.Object, IntPtr) + ; Cannot produce JIT assembly for runtime-implemented method. + +D.Invoke() + ; Cannot produce JIT assembly for runtime-implemented method. + +D.BeginInvoke(System.AsyncCallback, System.Object) + ; Cannot produce JIT assembly for runtime-implemented method. + +D.EndInvoke(System.IAsyncResult) + ; Cannot produce JIT assembly for runtime-implemented method. + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Generic.MethodWithAttribute.cs b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Generic.MethodWithAttribute.cs index 8050ce85..2ae1ad73 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Generic.MethodWithAttribute.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Generic.MethodWithAttribute.cs @@ -1,37 +1,37 @@ -using SharpLab.Runtime; -static class C { - [JitGeneric(typeof(int))] - [JitGeneric(typeof(decimal))] - [JitGeneric(typeof(string))] - static T M() { - return default(T); - } -} - -/* asm - -; Desktop CLR on amd64 - -Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() - L0000: ret - -System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) - L0000: mov [rcx+0x8], edx - L0003: ret - -C.M[[System.Int32, mscorlib]]() - L0000: xor eax, eax - L0002: ret - -C.M[[System.Decimal, mscorlib]]() - L0000: vzeroupper - L0003: vxorps xmm0, xmm0, xmm0 - L0008: vmovdqu [rcx], xmm0 - L000d: mov rax, rcx - L0010: ret - -C.M[[System.String, mscorlib]]() - ; Failed to find JIT output for generic method (reference types?). - ; If you know a solution, please comment at https://github.com/ashmind/SharpLab/issues/99. - +using SharpLab.Runtime; +static class C { + [JitGeneric(typeof(int))] + [JitGeneric(typeof(decimal))] + [JitGeneric(typeof(string))] + static T M() { + return default(T); + } +} + +/* asm + +; Desktop CLR on amd64 + +Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() + L0000: ret + +System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) + L0000: mov [rcx+0x8], edx + L0003: ret + +C.M[[System.Int32, mscorlib]]() + L0000: xor eax, eax + L0002: ret + +C.M[[System.Decimal, mscorlib]]() + L0000: vzeroupper + L0003: vxorps xmm0, xmm0, xmm0 + L0008: vmovdqu [rcx], xmm0 + L000d: mov rax, rcx + L0010: ret + +C.M[[System.String, mscorlib]]() + ; Failed to find JIT output for generic method (reference types?). + ; If you know a solution, please comment at https://github.com/ashmind/SharpLab/issues/99. + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Generic.Open.Multiple.cs b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Generic.Open.Multiple.cs index 8e364a64..ec3f3f2b 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Generic.Open.Multiple.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Generic.Open.Multiple.cs @@ -1,50 +1,50 @@ -using SharpLab.Runtime; - -static class C { - static void M() {} - - static class N { - static void M() {} - } -} - -static class C { - static void M() {} - - static class N { - static void M() {} - } -} - -/* asm - -; Desktop CLR on amd64 - -Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() - L0000: ret - -System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) - L0000: mov [rcx+0x8], edx - L0003: ret - -C`1.M() - ; Open generics cannot be JIT-compiled. - ; However you can use attribute SharpLab.Runtime.JitGeneric to specify argument types. - ; Example: [JitGeneric(typeof(int)), JitGeneric(typeof(string))] void M() { ... }. - -C`1+N.M() - ; Open generics cannot be JIT-compiled. - ; However you can use attribute SharpLab.Runtime.JitGeneric to specify argument types. - ; Example: [JitGeneric(typeof(int)), JitGeneric(typeof(string))] void M() { ... }. - -C.M() - ; Open generics cannot be JIT-compiled. - ; However you can use attribute SharpLab.Runtime.JitGeneric to specify argument types. - ; Example: [JitGeneric(typeof(int)), JitGeneric(typeof(string))] void M() { ... }. - -C+N`1.M() - ; Open generics cannot be JIT-compiled. - ; However you can use attribute SharpLab.Runtime.JitGeneric to specify argument types. - ; Example: [JitGeneric(typeof(int)), JitGeneric(typeof(string))] void M() { ... }. - +using SharpLab.Runtime; + +static class C { + static void M() {} + + static class N { + static void M() {} + } +} + +static class C { + static void M() {} + + static class N { + static void M() {} + } +} + +/* asm + +; Desktop CLR on amd64 + +Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() + L0000: ret + +System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) + L0000: mov [rcx+0x8], edx + L0003: ret + +C`1.M() + ; Open generics cannot be JIT-compiled. + ; However you can use attribute SharpLab.Runtime.JitGeneric to specify argument types. + ; Example: [JitGeneric(typeof(int)), JitGeneric(typeof(string))] void M() { ... }. + +C`1+N.M() + ; Open generics cannot be JIT-compiled. + ; However you can use attribute SharpLab.Runtime.JitGeneric to specify argument types. + ; Example: [JitGeneric(typeof(int)), JitGeneric(typeof(string))] void M() { ... }. + +C.M() + ; Open generics cannot be JIT-compiled. + ; However you can use attribute SharpLab.Runtime.JitGeneric to specify argument types. + ; Example: [JitGeneric(typeof(int)), JitGeneric(typeof(string))] void M() { ... }. + +C+N`1.M() + ; Open generics cannot be JIT-compiled. + ; However you can use attribute SharpLab.Runtime.JitGeneric to specify argument types. + ; Example: [JitGeneric(typeof(int)), JitGeneric(typeof(string))] void M() { ... }. + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/JumpBack.cs b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/JumpBack.cs index 033a2428..327e2e54 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/JumpBack.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/JumpBack.cs @@ -1,34 +1,34 @@ -// https://github.com/ashmind/SharpLab/issues/229 -public class C -{ - public int M(int a) { - back: - a += 1; - if (a == 0) - goto back; - return a; - } -} - -/* asm - -; Desktop CLR on amd64 - -Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() - L0000: ret - -System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) - L0000: mov [rcx+0x8], edx - L0003: ret - -C..ctor() - L0000: ret - -C.M(Int32) - L0000: inc edx - L0002: test edx, edx - L0004: jz L0000 - L0006: mov eax, edx - L0008: ret - +// https://github.com/ashmind/SharpLab/issues/229 +public class C +{ + public int M(int a) { + back: + a += 1; + if (a == 0) + goto back; + return a; + } +} + +/* asm + +; Desktop CLR on amd64 + +Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() + L0000: ret + +System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) + L0000: mov [rcx+0x8], edx + L0003: ret + +C..ctor() + L0000: ret + +C.M(Int32) + L0000: inc edx + L0002: test edx, edx + L0004: jz L0000 + L0006: mov eax, edx + L0008: ret + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/MultipleReturns.cs b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/MultipleReturns.cs index 86d217e6..5cdbca93 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/MultipleReturns.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/MultipleReturns.cs @@ -1,26 +1,26 @@ -static class C { - static int M(bool x) { - return x ? 1 : 2; - } -} - -/* asm - -; Desktop CLR on amd64 - -Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() - L0000: ret - -System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) - L0000: mov [rcx+0x8], edx - L0003: ret - -C.M(Boolean) - L0000: test cl, cl - L0002: jnz L000a - L0004: mov eax, 0x2 - L0009: ret - L000a: mov eax, 0x1 - L000f: ret - +static class C { + static int M(bool x) { + return x ? 1 : 2; + } +} + +/* asm + +; Desktop CLR on amd64 + +Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() + L0000: ret + +System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) + L0000: mov [rcx+0x8], edx + L0003: ret + +C.M(Boolean) + L0000: test cl, cl + L0002: jnz L000a + L0004: mov eax, 0x2 + L0009: ret + L000a: mov eax, 0x1 + L000f: ret + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Nested.Simple.cs b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Nested.Simple.cs index d706ea8f..1678f113 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Nested.Simple.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Nested.Simple.cs @@ -1,22 +1,22 @@ -static class C { - static class N { - static int M() => 0x12345; - } -} - -/* asm - -; Desktop CLR on amd64 - -Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() - L0000: ret - -System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) - L0000: mov [rcx+0x8], edx - L0003: ret - -C+N.M() - L0000: mov eax, 0x12345 - L0005: ret - +static class C { + static class N { + static int M() => 0x12345; + } +} + +/* asm + +; Desktop CLR on amd64 + +Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() + L0000: ret + +System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) + L0000: mov [rcx+0x8], edx + L0003: ret + +C+N.M() + L0000: mov eax, 0x12345 + L0005: ret + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Simple.cs b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Simple.cs index d6b55b0b..1c234d71 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Simple.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/JitAsm/Simple.cs @@ -1,20 +1,20 @@ -static class C { - static int M() => 0x12345; -} - -/* asm - -; Desktop CLR on amd64 - -Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() - L0000: ret - -System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) - L0000: mov [rcx+0x8], edx - L0003: ret - -C.M() - L0000: mov eax, 0x12345 - L0005: ret - +static class C { + static int M() => 0x12345; +} + +/* asm + +; Desktop CLR on amd64 + +Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() + L0000: ret + +System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) + L0000: mov [rcx+0x8], edx + L0003: ret + +C.M() + L0000: mov eax, 0x12345 + L0005: ret + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/Lambda.CallInArray.cs b/source/NetFramework/Tests/Decompilation/TestCode/Lambda.CallInArray.cs index f66e86aa..dd8c7ea3 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/Lambda.CallInArray.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/Lambda.CallInArray.cs @@ -1,87 +1,87 @@ -using System; -public class C { - public void M() { - Func getInt = s => s; - var list = new [] { 1, 2, 3, getInt(1) }; - Console.WriteLine(list[3]); - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: RefSafetyRules(11)] -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} -public class C -{ - [Serializable] - [CompilerGenerated] - private sealed class <>c - { - public static readonly <>c <>9 = new <>c(); - - public static Func <>9__0_0; - - internal int b__0_0(int s) - { - return s; - } - } - - public void M() - { - Func func = <>c.<>9__0_0 ?? (<>c.<>9__0_0 = new Func(<>c.<>9.b__0_0)); - int[] array = new int[4]; - RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); - array[3] = func(1); - Console.WriteLine(array[3]); - } -} -[CompilerGenerated] -internal sealed class -{ - [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 16)] - private struct __StaticArrayInitTypeSize=16 - { - } - - internal static readonly __StaticArrayInitTypeSize=16 81C1A5A2F482E82CA2C66653482AB24E6D90944BF183C8164E8F8F8D72DB60DB/* Not supported: data(01 00 00 00 02 00 00 00 03 00 00 00 00 00 00 00) */; -} - +using System; +public class C { + public void M() { + Func getInt = s => s; + var list = new [] { 1, 2, 3, getInt(1) }; + Console.WriteLine(list[3]); + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Security.Permissions; +using Microsoft.CodeAnalysis; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] +namespace Microsoft.CodeAnalysis +{ + [CompilerGenerated] + [Embedded] + internal sealed class EmbeddedAttribute : Attribute + { + } +} +namespace System.Runtime.CompilerServices +{ + [CompilerGenerated] + [Embedded] + [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] + internal sealed class RefSafetyRulesAttribute : Attribute + { + public readonly int Version; + + public RefSafetyRulesAttribute(int P_0) + { + Version = P_0; + } + } +} +public class C +{ + [Serializable] + [CompilerGenerated] + private sealed class <>c + { + public static readonly <>c <>9 = new <>c(); + + public static Func <>9__0_0; + + internal int b__0_0(int s) + { + return s; + } + } + + public void M() + { + Func func = <>c.<>9__0_0 ?? (<>c.<>9__0_0 = new Func(<>c.<>9.b__0_0)); + int[] array = new int[4]; + RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); + array[3] = func(1); + Console.WriteLine(array[3]); + } +} +[CompilerGenerated] +internal sealed class +{ + [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 16)] + private struct __StaticArrayInitTypeSize=16 + { + } + + internal static readonly __StaticArrayInitTypeSize=16 81C1A5A2F482E82CA2C66653482AB24E6D90944BF183C8164E8F8F8D72DB60DB/* Not supported: data(01 00 00 00 02 00 00 00 03 00 00 00 00 00 00 00) */; +} + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/NullPropagation.ToTernary.cs b/source/NetFramework/Tests/Decompilation/TestCode/NullPropagation.ToTernary.cs index 6630fe58..89a24039 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/NullPropagation.ToTernary.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/NullPropagation.ToTernary.cs @@ -1,74 +1,74 @@ -public class Point { - public int X { get; set; } - public int M(Point p) { - return (p?.X).GetValueOrDefault(); - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: RefSafetyRules(11)] -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} -public class Point -{ - [CompilerGenerated] - private int k__BackingField; - - public int X - { - [CompilerGenerated] - get - { - return k__BackingField; - } - [CompilerGenerated] - set - { - k__BackingField = value; - } - } - - public int M(Point p) - { - Nullable num = ((p != null) ? new Nullable(p.X) : null); - return num.GetValueOrDefault(); - } -} - +public class Point { + public int X { get; set; } + public int M(Point p) { + return (p?.X).GetValueOrDefault(); + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; +using Microsoft.CodeAnalysis; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] +namespace Microsoft.CodeAnalysis +{ + [CompilerGenerated] + [Embedded] + internal sealed class EmbeddedAttribute : Attribute + { + } +} +namespace System.Runtime.CompilerServices +{ + [CompilerGenerated] + [Embedded] + [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] + internal sealed class RefSafetyRulesAttribute : Attribute + { + public readonly int Version; + + public RefSafetyRulesAttribute(int P_0) + { + Version = P_0; + } + } +} +public class Point +{ + [CompilerGenerated] + private int k__BackingField; + + public int X + { + [CompilerGenerated] + get + { + return k__BackingField; + } + [CompilerGenerated] + set + { + k__BackingField = value; + } + } + + public int M(Point p) + { + Nullable num = ((p != null) ? new Nullable(p.X) : null); + return num.GetValueOrDefault(); + } +} + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/Nullable.OperatorLifting.cs b/source/NetFramework/Tests/Decompilation/TestCode/Nullable.OperatorLifting.cs index b63592e6..1765e468 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/Nullable.OperatorLifting.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/Nullable.OperatorLifting.cs @@ -1,62 +1,62 @@ -using System; -public class C { - public bool M(DateTime? d) { - return d > DateTime.Now; - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: RefSafetyRules(11)] -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} -public class C -{ - public bool M(Nullable d) - { - Nullable dateTime = d; - DateTime now = DateTime.Now; - if (!dateTime.HasValue) - { - return false; - } - return dateTime.GetValueOrDefault() > now; - } -} - +using System; +public class C { + public bool M(DateTime? d) { + return d > DateTime.Now; + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; +using Microsoft.CodeAnalysis; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] +namespace Microsoft.CodeAnalysis +{ + [CompilerGenerated] + [Embedded] + internal sealed class EmbeddedAttribute : Attribute + { + } +} +namespace System.Runtime.CompilerServices +{ + [CompilerGenerated] + [Embedded] + [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] + internal sealed class RefSafetyRulesAttribute : Attribute + { + public readonly int Version; + + public RefSafetyRulesAttribute(int P_0) + { + Version = P_0; + } + } +} +public class C +{ + public bool M(Nullable d) + { + Nullable dateTime = d; + DateTime now = DateTime.Now; + if (!dateTime.HasValue) + { + return false; + } + return dateTime.GetValueOrDefault() > now; + } +} + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/Parameters.Optional.Decimal.cs b/source/NetFramework/Tests/Decompilation/TestCode/Parameters.Optional.Decimal.cs index bb2557fb..194d0444 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/Parameters.Optional.Decimal.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/Parameters.Optional.Decimal.cs @@ -1,54 +1,54 @@ -public class C { - public void M(decimal d = 5.0m) { - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: RefSafetyRules(11)] -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} -public class C -{ - public void M([Optional][DecimalConstant(1, 0, 0u, 0u, 50u)] decimal d) - { - } -} - +public class C { + public void M(decimal d = 5.0m) { + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Security.Permissions; +using Microsoft.CodeAnalysis; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] +namespace Microsoft.CodeAnalysis +{ + [CompilerGenerated] + [Embedded] + internal sealed class EmbeddedAttribute : Attribute + { + } +} +namespace System.Runtime.CompilerServices +{ + [CompilerGenerated] + [Embedded] + [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] + internal sealed class RefSafetyRulesAttribute : Attribute + { + public readonly int Version; + + public RefSafetyRulesAttribute(int P_0) + { + Version = P_0; + } + } +} +public class C +{ + public void M([Optional][DecimalConstant(1, 0, 0u, 0u, 50u)] decimal d) + { + } +} + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/Preprocessor.IfDebug.cs b/source/NetFramework/Tests/Decompilation/TestCode/Preprocessor.IfDebug.cs index aea71a48..1dded18a 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/Preprocessor.IfDebug.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/Preprocessor.IfDebug.cs @@ -1,60 +1,60 @@ -using System; -public class C { - public string M() { - #if DEBUG - return "Debug"; - #else - return "Release"; - #endif - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: RefSafetyRules(11)] -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} -public class C -{ - public string M() - { - return "Debug"; - } -} - +using System; +public class C { + public string M() { + #if DEBUG + return "Debug"; + #else + return "Release"; + #endif + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; +using Microsoft.CodeAnalysis; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] +namespace Microsoft.CodeAnalysis +{ + [CompilerGenerated] + [Embedded] + internal sealed class EmbeddedAttribute : Attribute + { + } +} +namespace System.Runtime.CompilerServices +{ + [CompilerGenerated] + [Embedded] + [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] + internal sealed class RefSafetyRulesAttribute : Attribute + { + public readonly int Version; + + public RefSafetyRulesAttribute(int P_0) + { + Version = P_0; + } + } +} +public class C +{ + public string M() + { + return "Debug"; + } +} + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/Simple.cs b/source/NetFramework/Tests/Decompilation/TestCode/Simple.cs index 09adb27c..dd0e1dd3 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/Simple.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/Simple.cs @@ -1,117 +1,117 @@ -public class Simple { -} - -/* il - -.assembly _ -{ - .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 - 63 65 70 74 69 6f 6e 54 68 72 6f 77 73 01 - ) - .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( - 01 00 02 00 00 00 00 00 - ) - .permissionset reqmin = ( - 2e 01 80 84 53 79 73 74 65 6d 2e 53 65 63 75 72 - 69 74 79 2e 50 65 72 6d 69 73 73 69 6f 6e 73 2e - 53 65 63 75 72 69 74 79 50 65 72 6d 69 73 73 69 - 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 6d 73 63 - 6f 72 6c 69 62 2c 20 56 65 72 73 69 6f 6e 3d 34 - 2e 30 2e 30 2e 30 2c 20 43 75 6c 74 75 72 65 3d - 6e 65 75 74 72 61 6c 2c 20 50 75 62 6c 69 63 4b - 65 79 54 6f 6b 65 6e 3d 62 37 37 61 35 63 35 36 - 31 39 33 34 65 30 38 39 15 01 54 02 10 53 6b 69 - 70 56 65 72 69 66 69 63 61 74 69 6f 6e 01 - ) - .hash algorithm 0x // SHA1 - .ver 0:0:0:0 -} - -.class private auto ansi '' -{ -} // end of class - -.class private auto ansi sealed beforefieldinit Microsoft.CodeAnalysis.EmbeddedAttribute - extends [mscorlib]System.Attribute -{ - .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( - 01 00 00 00 - ) - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor () cil managed - { - // Method begins at RVA 0x2050 - // Code size 7 (0x7) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [mscorlib]System.Attribute::.ctor() - IL_0006: ret - } // end of method EmbeddedAttribute::.ctor - -} // end of class Microsoft.CodeAnalysis.EmbeddedAttribute - -.class private auto ansi sealed beforefieldinit System.Runtime.CompilerServices.RefSafetyRulesAttribute - extends [mscorlib]System.Attribute -{ - .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void [mscorlib]System.AttributeUsageAttribute::.ctor(valuetype [mscorlib]System.AttributeTargets) = ( - 01 00 02 00 00 00 02 00 54 02 0d 41 6c 6c 6f 77 - 4d 75 6c 74 69 70 6c 65 00 54 02 09 49 6e 68 65 - 72 69 74 65 64 00 - ) - // Fields - .field public initonly int32 Version - - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor ( - int32 '' - ) cil managed - { - // Method begins at RVA 0x2058 - // Code size 14 (0xe) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [mscorlib]System.Attribute::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld int32 System.Runtime.CompilerServices.RefSafetyRulesAttribute::Version - IL_000d: ret - } // end of method RefSafetyRulesAttribute::.ctor - -} // end of class System.Runtime.CompilerServices.RefSafetyRulesAttribute - -.class public auto ansi beforefieldinit Simple - extends [mscorlib]System.Object -{ - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor () cil managed - { - // Method begins at RVA 0x2067 - // 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 Simple::.ctor - -} // end of class Simple - +public class Simple { +} + +/* il + +.assembly _ +{ + .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 + 63 65 70 74 69 6f 6e 54 68 72 6f 77 73 01 + ) + .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( + 01 00 02 00 00 00 00 00 + ) + .permissionset reqmin = ( + 2e 01 80 84 53 79 73 74 65 6d 2e 53 65 63 75 72 + 69 74 79 2e 50 65 72 6d 69 73 73 69 6f 6e 73 2e + 53 65 63 75 72 69 74 79 50 65 72 6d 69 73 73 69 + 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 6d 73 63 + 6f 72 6c 69 62 2c 20 56 65 72 73 69 6f 6e 3d 34 + 2e 30 2e 30 2e 30 2c 20 43 75 6c 74 75 72 65 3d + 6e 65 75 74 72 61 6c 2c 20 50 75 62 6c 69 63 4b + 65 79 54 6f 6b 65 6e 3d 62 37 37 61 35 63 35 36 + 31 39 33 34 65 30 38 39 15 01 54 02 10 53 6b 69 + 70 56 65 72 69 66 69 63 61 74 69 6f 6e 01 + ) + .hash algorithm 0x // SHA1 + .ver 0:0:0:0 +} + +.class private auto ansi '' +{ +} // end of class + +.class private auto ansi sealed beforefieldinit Microsoft.CodeAnalysis.EmbeddedAttribute + extends [mscorlib]System.Attribute +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( + 01 00 00 00 + ) + .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( + 01 00 00 00 + ) + // Methods + .method public hidebysig specialname rtspecialname + instance void .ctor () cil managed + { + // Method begins at RVA 0x2050 + // Code size 7 (0x7) + .maxstack 8 + + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Attribute::.ctor() + IL_0006: ret + } // end of method EmbeddedAttribute::.ctor + +} // end of class Microsoft.CodeAnalysis.EmbeddedAttribute + +.class private auto ansi sealed beforefieldinit System.Runtime.CompilerServices.RefSafetyRulesAttribute + extends [mscorlib]System.Attribute +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( + 01 00 00 00 + ) + .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( + 01 00 00 00 + ) + .custom instance void [mscorlib]System.AttributeUsageAttribute::.ctor(valuetype [mscorlib]System.AttributeTargets) = ( + 01 00 02 00 00 00 02 00 54 02 0d 41 6c 6c 6f 77 + 4d 75 6c 74 69 70 6c 65 00 54 02 09 49 6e 68 65 + 72 69 74 65 64 00 + ) + // Fields + .field public initonly int32 Version + + // Methods + .method public hidebysig specialname rtspecialname + instance void .ctor ( + int32 '' + ) cil managed + { + // Method begins at RVA 0x2058 + // Code size 14 (0xe) + .maxstack 8 + + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 System.Runtime.CompilerServices.RefSafetyRulesAttribute::Version + IL_000d: ret + } // end of method RefSafetyRulesAttribute::.ctor + +} // end of class System.Runtime.CompilerServices.RefSafetyRulesAttribute + +.class public auto ansi beforefieldinit Simple + extends [mscorlib]System.Object +{ + // Methods + .method public hidebysig specialname rtspecialname + instance void .ctor () cil managed + { + // Method begins at RVA 0x2067 + // 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 Simple::.ctor + +} // end of class Simple + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/Unsafe.FixedBuffer.cs b/source/NetFramework/Tests/Decompilation/TestCode/Unsafe.FixedBuffer.cs index 8be0bc4d..342b837a 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/Unsafe.FixedBuffer.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/Unsafe.FixedBuffer.cs @@ -1,61 +1,61 @@ -internal unsafe struct MyBuffer -{ - public fixed char fixedBuffer[128]; -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: RefSafetyRules(11)] -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} -internal struct MyBuffer -{ - [StructLayout(LayoutKind.Sequential, Size = 256)] - [CompilerGenerated] - [UnsafeValueType] - public struct e__FixedBuffer - { - public char FixedElementField; - } - - [FixedBuffer(typeof(char), 128)] - public e__FixedBuffer fixedBuffer; -} - +internal unsafe struct MyBuffer +{ + public fixed char fixedBuffer[128]; +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Security.Permissions; +using Microsoft.CodeAnalysis; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] +namespace Microsoft.CodeAnalysis +{ + [CompilerGenerated] + [Embedded] + internal sealed class EmbeddedAttribute : Attribute + { + } +} +namespace System.Runtime.CompilerServices +{ + [CompilerGenerated] + [Embedded] + [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] + internal sealed class RefSafetyRulesAttribute : Attribute + { + public readonly int Version; + + public RefSafetyRulesAttribute(int P_0) + { + Version = P_0; + } + } +} +internal struct MyBuffer +{ + [StructLayout(LayoutKind.Sequential, Size = 256)] + [CompilerGenerated] + [UnsafeValueType] + public struct e__FixedBuffer + { + public char FixedElementField; + } + + [FixedBuffer(typeof(char), 128)] + public e__FixedBuffer fixedBuffer; +} + */ \ No newline at end of file diff --git a/source/NetFramework/Tests/Decompilation/TestCode/Using.Simple.cs b/source/NetFramework/Tests/Decompilation/TestCode/Using.Simple.cs index 53baf42a..32768dd9 100644 --- a/source/NetFramework/Tests/Decompilation/TestCode/Using.Simple.cs +++ b/source/NetFramework/Tests/Decompilation/TestCode/Using.Simple.cs @@ -1,67 +1,67 @@ -public class C { - public void M() { - using (new System.IO.MemoryStream()) { - } - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.IO; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: RefSafetyRules(11)] -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} -public class C -{ - public void M() - { - MemoryStream memoryStream = new MemoryStream(); - try - { - } - finally - { - if (memoryStream != null) - { - ((IDisposable)memoryStream).Dispose(); - } - } - } -} - +public class C { + public void M() { + using (new System.IO.MemoryStream()) { + } + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; +using Microsoft.CodeAnalysis; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] +namespace Microsoft.CodeAnalysis +{ + [CompilerGenerated] + [Embedded] + internal sealed class EmbeddedAttribute : Attribute + { + } +} +namespace System.Runtime.CompilerServices +{ + [CompilerGenerated] + [Embedded] + [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] + internal sealed class RefSafetyRulesAttribute : Attribute + { + public readonly int Version; + + public RefSafetyRulesAttribute(int P_0) + { + Version = P_0; + } + } +} +public class C +{ + public void M() + { + MemoryStream memoryStream = new MemoryStream(); + try + { + } + finally + { + if (memoryStream != null) + { + ((IDisposable)memoryStream).Dispose(); + } + } + } +} + */ \ No newline at end of file diff --git a/source/Server/Execution/Internal/FSharpEntryPointRewriter.cs b/source/Server/Execution/Internal/FSharpEntryPointRewriter.cs index 448c1bc3..af801d4f 100644 --- a/source/Server/Execution/Internal/FSharpEntryPointRewriter.cs +++ b/source/Server/Execution/Internal/FSharpEntryPointRewriter.cs @@ -2,12 +2,18 @@ using MirrorSharp.Advanced; using MirrorSharp.FSharp.Advanced; using Mono.Cecil; +using Mono.Cecil.Cil; +using System.Runtime.CompilerServices; +using MethodInfo = System.Reflection.MethodInfo; namespace SharpLab.Server.Execution.Internal { // There are some weird problems when I try to compile F# code as an exe (e.g. it tries to // do filesystem operations without using the virtual filesystem), so instead I compile // it as a library and then fake the entry point. public class FSharpEntryPointRewriter : IAssemblyRewriter { + private static readonly MethodInfo RunClassConstructorMethod = + typeof(RuntimeHelpers).GetMethod(nameof(RuntimeHelpers.RunClassConstructor))!; + public void Rewrite(ModuleDefinition module, IWorkSession session) { if (!session.IsFSharp()) return; @@ -19,13 +25,31 @@ public void Rewrite(ModuleDefinition module, IWorkSession session) { if (entryPoint == null) return; - if (isStaticConstructor) { - entryPoint.Attributes &= ~MethodAttributes.SpecialName & ~MethodAttributes.RTSpecialName; - entryPoint.Name = "cctor_rewritten_to_method_by_sharplab"; - } + if (isStaticConstructor) + entryPoint = CreateEntryPointForStaticConstructor(entryPoint); module.EntryPoint = entryPoint; } + private MethodDefinition CreateEntryPointForStaticConstructor(MethodDefinition constructor) { + var module = constructor.Module; + var entryPoint = new MethodDefinition( + "entrypoint_generated_by_sharplab", + MethodAttributes.Static, + module.ImportReference(typeof(void)) + ); + entryPoint.Body = new MethodBody(entryPoint); + + var runClassConstructor = module.ImportReference(RunClassConstructorMethod); + var entryPointIL = entryPoint.Body.GetILProcessor(); + entryPoint.Body.MaxStackSize = 1; + entryPoint.Body.Instructions.Add(entryPointIL.Create(OpCodes.Ldtoken, constructor.DeclaringType)); + entryPoint.Body.Instructions.Add(entryPointIL.CreateCall(runClassConstructor)); + entryPoint.Body.Instructions.Add(entryPointIL.Create(OpCodes.Ret)); + + constructor.DeclaringType.Methods.Add(entryPoint); + return entryPoint; + } + private (MethodDefinition? method, bool isStaticConstructor) FindBestEntryPointCandidate(ModuleDefinition module) { if (!module.HasTypes) return (null, false); diff --git a/source/Tests/Decompilation/TestCode/Ast/EmptyClass.cs b/source/Tests/Decompilation/TestCode/Ast/EmptyClass.cs index 5a0e7df0..b9c6b19f 100644 --- a/source/Tests/Decompilation/TestCode/Ast/EmptyClass.cs +++ b/source/Tests/Decompilation/TestCode/Ast/EmptyClass.cs @@ -1,112 +1,112 @@ -public class C { -} - -/* ast - -[ - { - "type": "node", - "kind": "CompilationUnit", - "range": "0-19", - "children": [ - { - "type": "node", - "kind": "ClassDeclaration", - "range": "0-19", - "children": [ - { - "type": "token", - "kind": "PublicKeyword", - "range": "0-7", - "children": [ - { - "type": "value", - "value": "public", - "range": "0-6" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "6-7", - "value": " " - } - ] - }, - { - "type": "token", - "kind": "ClassKeyword", - "property": "Keyword", - "range": "7-13", - "children": [ - { - "type": "value", - "value": "class", - "range": "7-12" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "12-13", - "value": " " - } - ] - }, - { - "type": "token", - "kind": "IdentifierToken", - "property": "Identifier", - "range": "13-15", - "children": [ - { - "type": "value", - "value": "C", - "range": "13-14" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "14-15", - "value": " " - } - ] - }, - { - "type": "token", - "kind": "OpenBraceToken", - "property": "OpenBraceToken", - "range": "15-18", - "children": [ - { - "type": "value", - "value": "{", - "range": "15-16" - }, - { - "type": "trivia", - "kind": "EndOfLineTrivia", - "range": "16-18", - "value": "\r\n" - } - ] - }, - { - "type": "token", - "kind": "CloseBraceToken", - "property": "CloseBraceToken", - "range": "18-19", - "value": "}" - } - ] - }, - { - "type": "token", - "kind": "EndOfFileToken", - "property": "EndOfFileToken", - "range": "19-19", - "value": "" - } - ] - } -] - +public class C { +} + +/* ast + +[ + { + "type": "node", + "kind": "CompilationUnit", + "range": "0-19", + "children": [ + { + "type": "node", + "kind": "ClassDeclaration", + "range": "0-19", + "children": [ + { + "type": "token", + "kind": "PublicKeyword", + "range": "0-7", + "children": [ + { + "type": "value", + "value": "public", + "range": "0-6" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "6-7", + "value": " " + } + ] + }, + { + "type": "token", + "kind": "ClassKeyword", + "property": "Keyword", + "range": "7-13", + "children": [ + { + "type": "value", + "value": "class", + "range": "7-12" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "12-13", + "value": " " + } + ] + }, + { + "type": "token", + "kind": "IdentifierToken", + "property": "Identifier", + "range": "13-15", + "children": [ + { + "type": "value", + "value": "C", + "range": "13-14" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "14-15", + "value": " " + } + ] + }, + { + "type": "token", + "kind": "OpenBraceToken", + "property": "OpenBraceToken", + "range": "15-18", + "children": [ + { + "type": "value", + "value": "{", + "range": "15-16" + }, + { + "type": "trivia", + "kind": "EndOfLineTrivia", + "range": "16-18", + "value": "\r\n" + } + ] + }, + { + "type": "token", + "kind": "CloseBraceToken", + "property": "CloseBraceToken", + "range": "18-19", + "value": "}" + } + ] + }, + { + "type": "token", + "kind": "EndOfFileToken", + "property": "EndOfFileToken", + "range": "19-19", + "value": "" + } + ] + } +] + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Ast/LiteralTokens.cs b/source/Tests/Decompilation/TestCode/Ast/LiteralTokens.cs index b8d7a181..deadb96b 100644 --- a/source/Tests/Decompilation/TestCode/Ast/LiteralTokens.cs +++ b/source/Tests/Decompilation/TestCode/Ast/LiteralTokens.cs @@ -1,878 +1,878 @@ -class C { - int i = 1; - char c = 'c'; - - string s1 = "a\r\nb"; - string s2 = @"a -b"; - - object o = null; -} - -/* ast - -[ - { - "type": "node", - "kind": "CompilationUnit", - "range": "0-126", - "children": [ - { - "type": "node", - "kind": "ClassDeclaration", - "range": "0-126", - "children": [ - { - "type": "token", - "kind": "ClassKeyword", - "property": "Keyword", - "range": "0-6", - "children": [ - { - "type": "value", - "value": "class", - "range": "0-5" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "5-6", - "value": " " - } - ] - }, - { - "type": "token", - "kind": "IdentifierToken", - "property": "Identifier", - "range": "6-8", - "children": [ - { - "type": "value", - "value": "C", - "range": "6-7" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "7-8", - "value": " " - } - ] - }, - { - "type": "token", - "kind": "OpenBraceToken", - "property": "OpenBraceToken", - "range": "8-11", - "children": [ - { - "type": "value", - "value": "{", - "range": "8-9" - }, - { - "type": "trivia", - "kind": "EndOfLineTrivia", - "range": "9-11", - "value": "\r\n" - } - ] - }, - { - "type": "node", - "kind": "FieldDeclaration", - "range": "11-27", - "children": [ - { - "type": "node", - "kind": "VariableDeclaration", - "property": "Declaration", - "range": "11-24", - "children": [ - { - "type": "node", - "kind": "PredefinedType", - "property": "Type", - "range": "11-19", - "children": [ - { - "type": "token", - "kind": "IntKeyword", - "property": "Keyword", - "range": "11-19", - "children": [ - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "11-15", - "value": " " - }, - { - "type": "value", - "value": "int", - "range": "15-18" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "18-19", - "value": " " - } - ] - } - ] - }, - { - "type": "node", - "kind": "VariableDeclarator", - "range": "19-24", - "children": [ - { - "type": "token", - "kind": "IdentifierToken", - "property": "Identifier", - "range": "19-21", - "children": [ - { - "type": "value", - "value": "i", - "range": "19-20" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "20-21", - "value": " " - } - ] - }, - { - "type": "node", - "kind": "EqualsValueClause", - "property": "Initializer", - "range": "21-24", - "children": [ - { - "type": "operation", - "property": "Operation", - "kind": "FieldInitializer", - "properties": { - "InitializedFields": "", - "Locals": "" - } - }, - { - "type": "token", - "kind": "EqualsToken", - "property": "EqualsToken", - "range": "21-23", - "children": [ - { - "type": "value", - "value": "=", - "range": "21-22" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "22-23", - "value": " " - } - ] - }, - { - "type": "node", - "kind": "NumericLiteralExpression", - "property": "Value", - "range": "23-24", - "children": [ - { - "type": "operation", - "property": "Operation", - "kind": "Literal", - "properties": { - "ConstantValue": "1", - "Type": "int" - } - }, - { - "type": "token", - "kind": "NumericLiteralToken", - "property": "Token", - "range": "23-24", - "value": "1" - } - ] - } - ] - } - ] - } - ] - }, - { - "type": "token", - "kind": "SemicolonToken", - "property": "SemicolonToken", - "range": "24-27", - "children": [ - { - "type": "value", - "value": ";", - "range": "24-25" - }, - { - "type": "trivia", - "kind": "EndOfLineTrivia", - "range": "25-27", - "value": "\r\n" - } - ] - } - ] - }, - { - "type": "node", - "kind": "FieldDeclaration", - "range": "27-46", - "children": [ - { - "type": "node", - "kind": "VariableDeclaration", - "property": "Declaration", - "range": "27-43", - "children": [ - { - "type": "node", - "kind": "PredefinedType", - "property": "Type", - "range": "27-36", - "children": [ - { - "type": "token", - "kind": "CharKeyword", - "property": "Keyword", - "range": "27-36", - "children": [ - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "27-31", - "value": " " - }, - { - "type": "value", - "value": "char", - "range": "31-35" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "35-36", - "value": " " - } - ] - } - ] - }, - { - "type": "node", - "kind": "VariableDeclarator", - "range": "36-43", - "children": [ - { - "type": "token", - "kind": "IdentifierToken", - "property": "Identifier", - "range": "36-38", - "children": [ - { - "type": "value", - "value": "c", - "range": "36-37" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "37-38", - "value": " " - } - ] - }, - { - "type": "node", - "kind": "EqualsValueClause", - "property": "Initializer", - "range": "38-43", - "children": [ - { - "type": "operation", - "property": "Operation", - "kind": "FieldInitializer", - "properties": { - "InitializedFields": "", - "Locals": "" - } - }, - { - "type": "token", - "kind": "EqualsToken", - "property": "EqualsToken", - "range": "38-40", - "children": [ - { - "type": "value", - "value": "=", - "range": "38-39" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "39-40", - "value": " " - } - ] - }, - { - "type": "node", - "kind": "CharacterLiteralExpression", - "property": "Value", - "range": "40-43", - "children": [ - { - "type": "operation", - "property": "Operation", - "kind": "Literal", - "properties": { - "ConstantValue": "c", - "Type": "char" - } - }, - { - "type": "token", - "kind": "CharacterLiteralToken", - "property": "Token", - "range": "40-43", - "value": "'c'" - } - ] - } - ] - } - ] - } - ] - }, - { - "type": "token", - "kind": "SemicolonToken", - "property": "SemicolonToken", - "range": "43-46", - "children": [ - { - "type": "value", - "value": ";", - "range": "43-44" - }, - { - "type": "trivia", - "kind": "EndOfLineTrivia", - "range": "44-46", - "value": "\r\n" - } - ] - } - ] - }, - { - "type": "node", - "kind": "FieldDeclaration", - "range": "46-75", - "children": [ - { - "type": "node", - "kind": "VariableDeclaration", - "property": "Declaration", - "range": "46-72", - "children": [ - { - "type": "node", - "kind": "PredefinedType", - "property": "Type", - "range": "46-59", - "children": [ - { - "type": "token", - "kind": "StringKeyword", - "property": "Keyword", - "range": "46-59", - "children": [ - { - "type": "trivia", - "kind": "EndOfLineTrivia", - "range": "46-48", - "value": "\r\n" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "48-52", - "value": " " - }, - { - "type": "value", - "value": "string", - "range": "52-58" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "58-59", - "value": " " - } - ] - } - ] - }, - { - "type": "node", - "kind": "VariableDeclarator", - "range": "59-72", - "children": [ - { - "type": "token", - "kind": "IdentifierToken", - "property": "Identifier", - "range": "59-62", - "children": [ - { - "type": "value", - "value": "s1", - "range": "59-61" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "61-62", - "value": " " - } - ] - }, - { - "type": "node", - "kind": "EqualsValueClause", - "property": "Initializer", - "range": "62-72", - "children": [ - { - "type": "operation", - "property": "Operation", - "kind": "FieldInitializer", - "properties": { - "InitializedFields": "", - "Locals": "" - } - }, - { - "type": "token", - "kind": "EqualsToken", - "property": "EqualsToken", - "range": "62-64", - "children": [ - { - "type": "value", - "value": "=", - "range": "62-63" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "63-64", - "value": " " - } - ] - }, - { - "type": "node", - "kind": "StringLiteralExpression", - "property": "Value", - "range": "64-72", - "children": [ - { - "type": "operation", - "property": "Operation", - "kind": "Literal", - "properties": { - "ConstantValue": "a\r\nb", - "Type": "string" - } - }, - { - "type": "token", - "kind": "StringLiteralToken", - "property": "Token", - "range": "64-72", - "value": "\"a\\r\\nb\"" - } - ] - } - ] - } - ] - } - ] - }, - { - "type": "token", - "kind": "SemicolonToken", - "property": "SemicolonToken", - "range": "72-75", - "children": [ - { - "type": "value", - "value": ";", - "range": "72-73" - }, - { - "type": "trivia", - "kind": "EndOfLineTrivia", - "range": "73-75", - "value": "\r\n" - } - ] - } - ] - }, - { - "type": "node", - "kind": "FieldDeclaration", - "range": "75-101", - "children": [ - { - "type": "node", - "kind": "VariableDeclaration", - "property": "Declaration", - "range": "75-98", - "children": [ - { - "type": "node", - "kind": "PredefinedType", - "property": "Type", - "range": "75-86", - "children": [ - { - "type": "token", - "kind": "StringKeyword", - "property": "Keyword", - "range": "75-86", - "children": [ - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "75-79", - "value": " " - }, - { - "type": "value", - "value": "string", - "range": "79-85" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "85-86", - "value": " " - } - ] - } - ] - }, - { - "type": "node", - "kind": "VariableDeclarator", - "range": "86-98", - "children": [ - { - "type": "token", - "kind": "IdentifierToken", - "property": "Identifier", - "range": "86-89", - "children": [ - { - "type": "value", - "value": "s2", - "range": "86-88" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "88-89", - "value": " " - } - ] - }, - { - "type": "node", - "kind": "EqualsValueClause", - "property": "Initializer", - "range": "89-98", - "children": [ - { - "type": "operation", - "property": "Operation", - "kind": "FieldInitializer", - "properties": { - "InitializedFields": "", - "Locals": "" - } - }, - { - "type": "token", - "kind": "EqualsToken", - "property": "EqualsToken", - "range": "89-91", - "children": [ - { - "type": "value", - "value": "=", - "range": "89-90" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "90-91", - "value": " " - } - ] - }, - { - "type": "node", - "kind": "StringLiteralExpression", - "property": "Value", - "range": "91-98", - "children": [ - { - "type": "operation", - "property": "Operation", - "kind": "Literal", - "properties": { - "ConstantValue": "a\r\nb", - "Type": "string" - } - }, - { - "type": "token", - "kind": "StringLiteralToken", - "property": "Token", - "range": "91-98", - "value": "@\"a\r\nb\"" - } - ] - } - ] - } - ] - } - ] - }, - { - "type": "token", - "kind": "SemicolonToken", - "property": "SemicolonToken", - "range": "98-101", - "children": [ - { - "type": "value", - "value": ";", - "range": "98-99" - }, - { - "type": "trivia", - "kind": "EndOfLineTrivia", - "range": "99-101", - "value": "\r\n" - } - ] - } - ] - }, - { - "type": "node", - "kind": "FieldDeclaration", - "range": "101-125", - "children": [ - { - "type": "node", - "kind": "VariableDeclaration", - "property": "Declaration", - "range": "101-122", - "children": [ - { - "type": "node", - "kind": "PredefinedType", - "property": "Type", - "range": "101-114", - "children": [ - { - "type": "token", - "kind": "ObjectKeyword", - "property": "Keyword", - "range": "101-114", - "children": [ - { - "type": "trivia", - "kind": "EndOfLineTrivia", - "range": "101-103", - "value": "\r\n" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "103-107", - "value": " " - }, - { - "type": "value", - "value": "object", - "range": "107-113" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "113-114", - "value": " " - } - ] - } - ] - }, - { - "type": "node", - "kind": "VariableDeclarator", - "range": "114-122", - "children": [ - { - "type": "token", - "kind": "IdentifierToken", - "property": "Identifier", - "range": "114-116", - "children": [ - { - "type": "value", - "value": "o", - "range": "114-115" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "115-116", - "value": " " - } - ] - }, - { - "type": "node", - "kind": "EqualsValueClause", - "property": "Initializer", - "range": "116-122", - "children": [ - { - "type": "operation", - "property": "Operation", - "kind": "FieldInitializer", - "properties": { - "InitializedFields": "", - "Locals": "" - } - }, - { - "type": "token", - "kind": "EqualsToken", - "property": "EqualsToken", - "range": "116-118", - "children": [ - { - "type": "value", - "value": "=", - "range": "116-117" - }, - { - "type": "trivia", - "kind": "WhitespaceTrivia", - "range": "117-118", - "value": " " - } - ] - }, - { - "type": "node", - "kind": "NullLiteralExpression", - "property": "Value", - "range": "118-122", - "children": [ - { - "type": "operation", - "property": "Operation", - "kind": "Literal", - "properties": { - "ConstantValue": null - } - }, - { - "type": "token", - "kind": "NullKeyword", - "property": "Token", - "range": "118-122", - "value": "null" - } - ] - } - ] - } - ] - } - ] - }, - { - "type": "token", - "kind": "SemicolonToken", - "property": "SemicolonToken", - "range": "122-125", - "children": [ - { - "type": "value", - "value": ";", - "range": "122-123" - }, - { - "type": "trivia", - "kind": "EndOfLineTrivia", - "range": "123-125", - "value": "\r\n" - } - ] - } - ] - }, - { - "type": "token", - "kind": "CloseBraceToken", - "property": "CloseBraceToken", - "range": "125-126", - "value": "}" - } - ] - }, - { - "type": "token", - "kind": "EndOfFileToken", - "property": "EndOfFileToken", - "range": "126-126", - "value": "" - } - ] - } -] - +class C { + int i = 1; + char c = 'c'; + + string s1 = "a\r\nb"; + string s2 = @"a +b"; + + object o = null; +} + +/* ast + +[ + { + "type": "node", + "kind": "CompilationUnit", + "range": "0-126", + "children": [ + { + "type": "node", + "kind": "ClassDeclaration", + "range": "0-126", + "children": [ + { + "type": "token", + "kind": "ClassKeyword", + "property": "Keyword", + "range": "0-6", + "children": [ + { + "type": "value", + "value": "class", + "range": "0-5" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "5-6", + "value": " " + } + ] + }, + { + "type": "token", + "kind": "IdentifierToken", + "property": "Identifier", + "range": "6-8", + "children": [ + { + "type": "value", + "value": "C", + "range": "6-7" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "7-8", + "value": " " + } + ] + }, + { + "type": "token", + "kind": "OpenBraceToken", + "property": "OpenBraceToken", + "range": "8-11", + "children": [ + { + "type": "value", + "value": "{", + "range": "8-9" + }, + { + "type": "trivia", + "kind": "EndOfLineTrivia", + "range": "9-11", + "value": "\r\n" + } + ] + }, + { + "type": "node", + "kind": "FieldDeclaration", + "range": "11-27", + "children": [ + { + "type": "node", + "kind": "VariableDeclaration", + "property": "Declaration", + "range": "11-24", + "children": [ + { + "type": "node", + "kind": "PredefinedType", + "property": "Type", + "range": "11-19", + "children": [ + { + "type": "token", + "kind": "IntKeyword", + "property": "Keyword", + "range": "11-19", + "children": [ + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "11-15", + "value": " " + }, + { + "type": "value", + "value": "int", + "range": "15-18" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "18-19", + "value": " " + } + ] + } + ] + }, + { + "type": "node", + "kind": "VariableDeclarator", + "range": "19-24", + "children": [ + { + "type": "token", + "kind": "IdentifierToken", + "property": "Identifier", + "range": "19-21", + "children": [ + { + "type": "value", + "value": "i", + "range": "19-20" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "20-21", + "value": " " + } + ] + }, + { + "type": "node", + "kind": "EqualsValueClause", + "property": "Initializer", + "range": "21-24", + "children": [ + { + "type": "operation", + "property": "Operation", + "kind": "FieldInitializer", + "properties": { + "InitializedFields": "", + "Locals": "" + } + }, + { + "type": "token", + "kind": "EqualsToken", + "property": "EqualsToken", + "range": "21-23", + "children": [ + { + "type": "value", + "value": "=", + "range": "21-22" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "22-23", + "value": " " + } + ] + }, + { + "type": "node", + "kind": "NumericLiteralExpression", + "property": "Value", + "range": "23-24", + "children": [ + { + "type": "operation", + "property": "Operation", + "kind": "Literal", + "properties": { + "ConstantValue": "1", + "Type": "int" + } + }, + { + "type": "token", + "kind": "NumericLiteralToken", + "property": "Token", + "range": "23-24", + "value": "1" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "token", + "kind": "SemicolonToken", + "property": "SemicolonToken", + "range": "24-27", + "children": [ + { + "type": "value", + "value": ";", + "range": "24-25" + }, + { + "type": "trivia", + "kind": "EndOfLineTrivia", + "range": "25-27", + "value": "\r\n" + } + ] + } + ] + }, + { + "type": "node", + "kind": "FieldDeclaration", + "range": "27-46", + "children": [ + { + "type": "node", + "kind": "VariableDeclaration", + "property": "Declaration", + "range": "27-43", + "children": [ + { + "type": "node", + "kind": "PredefinedType", + "property": "Type", + "range": "27-36", + "children": [ + { + "type": "token", + "kind": "CharKeyword", + "property": "Keyword", + "range": "27-36", + "children": [ + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "27-31", + "value": " " + }, + { + "type": "value", + "value": "char", + "range": "31-35" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "35-36", + "value": " " + } + ] + } + ] + }, + { + "type": "node", + "kind": "VariableDeclarator", + "range": "36-43", + "children": [ + { + "type": "token", + "kind": "IdentifierToken", + "property": "Identifier", + "range": "36-38", + "children": [ + { + "type": "value", + "value": "c", + "range": "36-37" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "37-38", + "value": " " + } + ] + }, + { + "type": "node", + "kind": "EqualsValueClause", + "property": "Initializer", + "range": "38-43", + "children": [ + { + "type": "operation", + "property": "Operation", + "kind": "FieldInitializer", + "properties": { + "InitializedFields": "", + "Locals": "" + } + }, + { + "type": "token", + "kind": "EqualsToken", + "property": "EqualsToken", + "range": "38-40", + "children": [ + { + "type": "value", + "value": "=", + "range": "38-39" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "39-40", + "value": " " + } + ] + }, + { + "type": "node", + "kind": "CharacterLiteralExpression", + "property": "Value", + "range": "40-43", + "children": [ + { + "type": "operation", + "property": "Operation", + "kind": "Literal", + "properties": { + "ConstantValue": "c", + "Type": "char" + } + }, + { + "type": "token", + "kind": "CharacterLiteralToken", + "property": "Token", + "range": "40-43", + "value": "'c'" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "token", + "kind": "SemicolonToken", + "property": "SemicolonToken", + "range": "43-46", + "children": [ + { + "type": "value", + "value": ";", + "range": "43-44" + }, + { + "type": "trivia", + "kind": "EndOfLineTrivia", + "range": "44-46", + "value": "\r\n" + } + ] + } + ] + }, + { + "type": "node", + "kind": "FieldDeclaration", + "range": "46-75", + "children": [ + { + "type": "node", + "kind": "VariableDeclaration", + "property": "Declaration", + "range": "46-72", + "children": [ + { + "type": "node", + "kind": "PredefinedType", + "property": "Type", + "range": "46-59", + "children": [ + { + "type": "token", + "kind": "StringKeyword", + "property": "Keyword", + "range": "46-59", + "children": [ + { + "type": "trivia", + "kind": "EndOfLineTrivia", + "range": "46-48", + "value": "\r\n" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "48-52", + "value": " " + }, + { + "type": "value", + "value": "string", + "range": "52-58" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "58-59", + "value": " " + } + ] + } + ] + }, + { + "type": "node", + "kind": "VariableDeclarator", + "range": "59-72", + "children": [ + { + "type": "token", + "kind": "IdentifierToken", + "property": "Identifier", + "range": "59-62", + "children": [ + { + "type": "value", + "value": "s1", + "range": "59-61" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "61-62", + "value": " " + } + ] + }, + { + "type": "node", + "kind": "EqualsValueClause", + "property": "Initializer", + "range": "62-72", + "children": [ + { + "type": "operation", + "property": "Operation", + "kind": "FieldInitializer", + "properties": { + "InitializedFields": "", + "Locals": "" + } + }, + { + "type": "token", + "kind": "EqualsToken", + "property": "EqualsToken", + "range": "62-64", + "children": [ + { + "type": "value", + "value": "=", + "range": "62-63" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "63-64", + "value": " " + } + ] + }, + { + "type": "node", + "kind": "StringLiteralExpression", + "property": "Value", + "range": "64-72", + "children": [ + { + "type": "operation", + "property": "Operation", + "kind": "Literal", + "properties": { + "ConstantValue": "a\r\nb", + "Type": "string" + } + }, + { + "type": "token", + "kind": "StringLiteralToken", + "property": "Token", + "range": "64-72", + "value": "\"a\\r\\nb\"" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "token", + "kind": "SemicolonToken", + "property": "SemicolonToken", + "range": "72-75", + "children": [ + { + "type": "value", + "value": ";", + "range": "72-73" + }, + { + "type": "trivia", + "kind": "EndOfLineTrivia", + "range": "73-75", + "value": "\r\n" + } + ] + } + ] + }, + { + "type": "node", + "kind": "FieldDeclaration", + "range": "75-101", + "children": [ + { + "type": "node", + "kind": "VariableDeclaration", + "property": "Declaration", + "range": "75-98", + "children": [ + { + "type": "node", + "kind": "PredefinedType", + "property": "Type", + "range": "75-86", + "children": [ + { + "type": "token", + "kind": "StringKeyword", + "property": "Keyword", + "range": "75-86", + "children": [ + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "75-79", + "value": " " + }, + { + "type": "value", + "value": "string", + "range": "79-85" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "85-86", + "value": " " + } + ] + } + ] + }, + { + "type": "node", + "kind": "VariableDeclarator", + "range": "86-98", + "children": [ + { + "type": "token", + "kind": "IdentifierToken", + "property": "Identifier", + "range": "86-89", + "children": [ + { + "type": "value", + "value": "s2", + "range": "86-88" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "88-89", + "value": " " + } + ] + }, + { + "type": "node", + "kind": "EqualsValueClause", + "property": "Initializer", + "range": "89-98", + "children": [ + { + "type": "operation", + "property": "Operation", + "kind": "FieldInitializer", + "properties": { + "InitializedFields": "", + "Locals": "" + } + }, + { + "type": "token", + "kind": "EqualsToken", + "property": "EqualsToken", + "range": "89-91", + "children": [ + { + "type": "value", + "value": "=", + "range": "89-90" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "90-91", + "value": " " + } + ] + }, + { + "type": "node", + "kind": "StringLiteralExpression", + "property": "Value", + "range": "91-98", + "children": [ + { + "type": "operation", + "property": "Operation", + "kind": "Literal", + "properties": { + "ConstantValue": "a\r\nb", + "Type": "string" + } + }, + { + "type": "token", + "kind": "StringLiteralToken", + "property": "Token", + "range": "91-98", + "value": "@\"a\r\nb\"" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "token", + "kind": "SemicolonToken", + "property": "SemicolonToken", + "range": "98-101", + "children": [ + { + "type": "value", + "value": ";", + "range": "98-99" + }, + { + "type": "trivia", + "kind": "EndOfLineTrivia", + "range": "99-101", + "value": "\r\n" + } + ] + } + ] + }, + { + "type": "node", + "kind": "FieldDeclaration", + "range": "101-125", + "children": [ + { + "type": "node", + "kind": "VariableDeclaration", + "property": "Declaration", + "range": "101-122", + "children": [ + { + "type": "node", + "kind": "PredefinedType", + "property": "Type", + "range": "101-114", + "children": [ + { + "type": "token", + "kind": "ObjectKeyword", + "property": "Keyword", + "range": "101-114", + "children": [ + { + "type": "trivia", + "kind": "EndOfLineTrivia", + "range": "101-103", + "value": "\r\n" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "103-107", + "value": " " + }, + { + "type": "value", + "value": "object", + "range": "107-113" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "113-114", + "value": " " + } + ] + } + ] + }, + { + "type": "node", + "kind": "VariableDeclarator", + "range": "114-122", + "children": [ + { + "type": "token", + "kind": "IdentifierToken", + "property": "Identifier", + "range": "114-116", + "children": [ + { + "type": "value", + "value": "o", + "range": "114-115" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "115-116", + "value": " " + } + ] + }, + { + "type": "node", + "kind": "EqualsValueClause", + "property": "Initializer", + "range": "116-122", + "children": [ + { + "type": "operation", + "property": "Operation", + "kind": "FieldInitializer", + "properties": { + "InitializedFields": "", + "Locals": "" + } + }, + { + "type": "token", + "kind": "EqualsToken", + "property": "EqualsToken", + "range": "116-118", + "children": [ + { + "type": "value", + "value": "=", + "range": "116-117" + }, + { + "type": "trivia", + "kind": "WhitespaceTrivia", + "range": "117-118", + "value": " " + } + ] + }, + { + "type": "node", + "kind": "NullLiteralExpression", + "property": "Value", + "range": "118-122", + "children": [ + { + "type": "operation", + "property": "Operation", + "kind": "Literal", + "properties": { + "ConstantValue": null + } + }, + { + "type": "token", + "kind": "NullKeyword", + "property": "Token", + "range": "118-122", + "value": "null" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "token", + "kind": "SemicolonToken", + "property": "SemicolonToken", + "range": "122-125", + "children": [ + { + "type": "value", + "value": ";", + "range": "122-123" + }, + { + "type": "trivia", + "kind": "EndOfLineTrivia", + "range": "123-125", + "value": "\r\n" + } + ] + } + ] + }, + { + "type": "token", + "kind": "CloseBraceToken", + "property": "CloseBraceToken", + "range": "125-126", + "value": "}" + } + ] + }, + { + "type": "token", + "kind": "EndOfFileToken", + "property": "EndOfFileToken", + "range": "126-126", + "value": "" + } + ] + } +] + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Ast/StructuredTrivia.cs b/source/Tests/Decompilation/TestCode/Ast/StructuredTrivia.cs index 0d83df01..773c4708 100644 --- a/source/Tests/Decompilation/TestCode/Ast/StructuredTrivia.cs +++ b/source/Tests/Decompilation/TestCode/Ast/StructuredTrivia.cs @@ -1,169 +1,169 @@ -/// Test - -/* ast - -[ - { - "type": "node", - "kind": "CompilationUnit", - "range": "0-27", - "children": [ - { - "type": "token", - "kind": "EndOfFileToken", - "property": "EndOfFileToken", - "range": "0-27", - "children": [ - { - "type": "trivia", - "kind": "SingleLineDocumentationCommentTrivia", - "range": "0-27", - "children": [ - { - "type": "node", - "kind": "SingleLineDocumentationCommentTrivia", - "property": "Structure", - "range": "0-27", - "children": [ - { - "type": "node", - "kind": "XmlText", - "range": "0-4", - "children": [ - { - "type": "token", - "kind": "XmlTextLiteralToken", - "range": "0-4", - "children": [ - { - "type": "trivia", - "kind": "DocumentationCommentExteriorTrivia", - "range": "0-3", - "value": "///" - }, - { - "type": "value", - "value": " ", - "range": "3-4" - } - ] - } - ] - }, - { - "type": "node", - "kind": "XmlElement", - "range": "4-27", - "children": [ - { - "type": "node", - "kind": "XmlElementStartTag", - "property": "StartTag", - "range": "4-13", - "children": [ - { - "type": "token", - "kind": "LessThanToken", - "property": "LessThanToken", - "range": "4-5", - "value": "<" - }, - { - "type": "node", - "kind": "XmlName", - "property": "Name", - "range": "5-12", - "children": [ - { - "type": "token", - "kind": "IdentifierToken", - "property": "LocalName", - "range": "5-12", - "value": "summary" - } - ] - }, - { - "type": "token", - "kind": "GreaterThanToken", - "property": "GreaterThanToken", - "range": "12-13", - "value": ">" - } - ] - }, - { - "type": "node", - "kind": "XmlText", - "range": "13-17", - "children": [ - { - "type": "token", - "kind": "XmlTextLiteralToken", - "range": "13-17", - "value": "Test" - } - ] - }, - { - "type": "node", - "kind": "XmlElementEndTag", - "property": "EndTag", - "range": "17-27", - "children": [ - { - "type": "token", - "kind": "LessThanSlashToken", - "property": "LessThanSlashToken", - "range": "17-19", - "value": "" - } - ] - } - ] - }, - { - "type": "token", - "kind": "EndOfDocumentationCommentToken", - "property": "EndOfComment", - "range": "27-27", - "value": "" - } - ] - } - ] - }, - { - "type": "value", - "value": "", - "range": "27-27" - } - ] - } - ] - } -] - +/// Test + +/* ast + +[ + { + "type": "node", + "kind": "CompilationUnit", + "range": "0-27", + "children": [ + { + "type": "token", + "kind": "EndOfFileToken", + "property": "EndOfFileToken", + "range": "0-27", + "children": [ + { + "type": "trivia", + "kind": "SingleLineDocumentationCommentTrivia", + "range": "0-27", + "children": [ + { + "type": "node", + "kind": "SingleLineDocumentationCommentTrivia", + "property": "Structure", + "range": "0-27", + "children": [ + { + "type": "node", + "kind": "XmlText", + "range": "0-4", + "children": [ + { + "type": "token", + "kind": "XmlTextLiteralToken", + "range": "0-4", + "children": [ + { + "type": "trivia", + "kind": "DocumentationCommentExteriorTrivia", + "range": "0-3", + "value": "///" + }, + { + "type": "value", + "value": " ", + "range": "3-4" + } + ] + } + ] + }, + { + "type": "node", + "kind": "XmlElement", + "range": "4-27", + "children": [ + { + "type": "node", + "kind": "XmlElementStartTag", + "property": "StartTag", + "range": "4-13", + "children": [ + { + "type": "token", + "kind": "LessThanToken", + "property": "LessThanToken", + "range": "4-5", + "value": "<" + }, + { + "type": "node", + "kind": "XmlName", + "property": "Name", + "range": "5-12", + "children": [ + { + "type": "token", + "kind": "IdentifierToken", + "property": "LocalName", + "range": "5-12", + "value": "summary" + } + ] + }, + { + "type": "token", + "kind": "GreaterThanToken", + "property": "GreaterThanToken", + "range": "12-13", + "value": ">" + } + ] + }, + { + "type": "node", + "kind": "XmlText", + "range": "13-17", + "children": [ + { + "type": "token", + "kind": "XmlTextLiteralToken", + "range": "13-17", + "value": "Test" + } + ] + }, + { + "type": "node", + "kind": "XmlElementEndTag", + "property": "EndTag", + "range": "17-27", + "children": [ + { + "type": "token", + "kind": "LessThanSlashToken", + "property": "LessThanSlashToken", + "range": "17-19", + "value": "" + } + ] + } + ] + }, + { + "type": "token", + "kind": "EndOfDocumentationCommentToken", + "property": "EndOfComment", + "range": "27-27", + "value": "" + } + ] + } + ] + }, + { + "type": "value", + "value": "", + "range": "27-27" + } + ] + } + ] + } +] + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Cast.ExplicitOperatorOnNull.cs b/source/Tests/Decompilation/TestCode/Cast.ExplicitOperatorOnNull.cs index dd2ed6b3..7de021ac 100644 --- a/source/Tests/Decompilation/TestCode/Cast.ExplicitOperatorOnNull.cs +++ b/source/Tests/Decompilation/TestCode/Cast.ExplicitOperatorOnNull.cs @@ -1,104 +1,45 @@ -public class Foo { - public static explicit operator uint? (Foo foo) => 1; -} - -public class Bar { - public void Baz() { - var x = (uint?)((Foo)null); - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] - -public class Foo -{ - [System.Runtime.CompilerServices.NullableContext(1)] - public static explicit operator Nullable(Foo foo) - { - return 1u; - } -} - -public class Bar -{ - public void Baz() - { - Nullable num = (Nullable)(Foo)null; - } -} - -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] - internal sealed class NullableAttribute : Attribute - { - public readonly byte[] NullableFlags; - - public NullableAttribute(byte P_0) - { - byte[] array = new byte[1]; - array[0] = P_0; - NullableFlags = array; - } - - public NullableAttribute(byte[] P_0) - { - NullableFlags = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] - internal sealed class NullableContextAttribute : Attribute - { - public readonly byte Flag; - - public NullableContextAttribute(byte P_0) - { - Flag = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - +public class Foo { + public static explicit operator uint? (Foo foo) => 1; +} + +public class Bar { + public void Baz() { + var x = (uint?)((Foo)null); + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] + +public class Foo +{ + [NullableContext(1)] + public static explicit operator Nullable(Foo foo) + { + return 1u; + } +} + +public class Bar +{ + public void Baz() + { + Nullable num = (Nullable)(Foo)null; + } +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Condition.SimpleSwitch.cs b/source/Tests/Decompilation/TestCode/Condition.SimpleSwitch.cs index 8a838b70..addc434d 100644 --- a/source/Tests/Decompilation/TestCode/Condition.SimpleSwitch.cs +++ b/source/Tests/Decompilation/TestCode/Condition.SimpleSwitch.cs @@ -8,13 +8,11 @@ public void M(string n) { /* cs -using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; -using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] @@ -22,11 +20,11 @@ public void M(string n) { [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] +[module: RefSafetyRules(11)] public class C { - [System.Runtime.CompilerServices.NullableContext(1)] + [NullableContext(1)] public void M(string n) { if (n == "foo") @@ -35,62 +33,4 @@ public void M(string n) } } -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] - internal sealed class NullableAttribute : Attribute - { - public readonly byte[] NullableFlags; - - public NullableAttribute(byte P_0) - { - byte[] array = new byte[1]; - array[0] = P_0; - NullableFlags = array; - } - - public NullableAttribute(byte[] P_0) - { - NullableFlags = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] - internal sealed class NullableContextAttribute : Attribute - { - public readonly byte Flag; - - public NullableContextAttribute(byte P_0) - { - Flag = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Constructor.BaseCall.cs b/source/Tests/Decompilation/TestCode/Constructor.BaseCall.cs index fb392697..03a18969 100644 --- a/source/Tests/Decompilation/TestCode/Constructor.BaseCall.cs +++ b/source/Tests/Decompilation/TestCode/Constructor.BaseCall.cs @@ -1,105 +1,45 @@ -public class MyBase { - public MyBase(string name) { - } -} - - -public class MyClass : MyBase { - public MyClass(string name) : base(name) { - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] - -public class MyBase -{ - [System.Runtime.CompilerServices.NullableContext(1)] - public MyBase(string name) - { - } -} - -public class MyClass : MyBase -{ - [System.Runtime.CompilerServices.NullableContext(1)] - public MyClass(string name) - : base(name) - { - } -} - -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] - internal sealed class NullableAttribute : Attribute - { - public readonly byte[] NullableFlags; - - public NullableAttribute(byte P_0) - { - byte[] array = new byte[1]; - array[0] = P_0; - NullableFlags = array; - } - - public NullableAttribute(byte[] P_0) - { - NullableFlags = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] - internal sealed class NullableContextAttribute : Attribute - { - public readonly byte Flag; - - public NullableContextAttribute(byte P_0) - { - Flag = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - +public class MyBase { + public MyBase(string name) { + } +} + + +public class MyClass : MyBase { + public MyClass(string name) : base(name) { + } +} + +/* cs + +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] + +public class MyBase +{ + [NullableContext(1)] + public MyBase(string name) + { + } +} + +public class MyClass : MyBase +{ + [NullableContext(1)] + public MyClass(string name) + : base(name) + { + } +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/FSharp/NotNull.fs b/source/Tests/Decompilation/TestCode/FSharp/NotNull.fs index 20c8a982..d0162907 100644 --- a/source/Tests/Decompilation/TestCode/FSharp/NotNull.fs +++ b/source/Tests/Decompilation/TestCode/FSharp/NotNull.fs @@ -1,40 +1,40 @@ -open System - -type C() = - member __.notNull x = not (isNull x) - -(* cs - -using System; -using System.Reflection; -using Microsoft.FSharp.Core; - -[assembly: FSharpInterfaceDataVersion(2, 0, 0)] -[assembly: AssemblyVersion("0.0.0.0")] - -[CompilationMapping(SourceConstructFlags.Module)] -public static class @_ -{ - [Serializable] - [CompilationMapping(SourceConstructFlags.ObjectType)] - public class C - { - public bool notNull(a x) where a : class - { - if (x == null) - { - return false; - } - return true; - } - } -} - -namespace -{ - internal static class $_ - { - } -} - +open System + +type C() = + member __.notNull x = not (isNull x) + +(* cs + +using System; +using System.Reflection; +using Microsoft.FSharp.Core; + +[assembly: FSharpInterfaceDataVersion(2, 0, 0)] +[assembly: AssemblyVersion("0.0.0.0")] + +[CompilationMapping(SourceConstructFlags.Module)] +public static class @_ +{ + [Serializable] + [CompilationMapping(SourceConstructFlags.ObjectType)] + public class C + { + public bool notNull(a x) where a : class + { + if (x == null) + { + return false; + } + return true; + } + } +} + +namespace +{ + internal static class $_ + { + } +} + *) \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/FSharp/SimpleMethod.fs b/source/Tests/Decompilation/TestCode/FSharp/SimpleMethod.fs index 4a001887..d032273f 100644 --- a/source/Tests/Decompilation/TestCode/FSharp/SimpleMethod.fs +++ b/source/Tests/Decompilation/TestCode/FSharp/SimpleMethod.fs @@ -1,35 +1,35 @@ -open System -type C() = - member this.M() = 5 - -(* cs - -using System; -using System.Reflection; -using Microsoft.FSharp.Core; - -[assembly: FSharpInterfaceDataVersion(2, 0, 0)] -[assembly: AssemblyVersion("0.0.0.0")] - -[CompilationMapping(SourceConstructFlags.Module)] -public static class @_ -{ - [Serializable] - [CompilationMapping(SourceConstructFlags.ObjectType)] - public class C - { - public int M() - { - return 5; - } - } -} - -namespace -{ - internal static class $_ - { - } -} - +open System +type C() = + member this.M() = 5 + +(* cs + +using System; +using System.Reflection; +using Microsoft.FSharp.Core; + +[assembly: FSharpInterfaceDataVersion(2, 0, 0)] +[assembly: AssemblyVersion("0.0.0.0")] + +[CompilationMapping(SourceConstructFlags.Module)] +public static class @_ +{ + [Serializable] + [CompilationMapping(SourceConstructFlags.ObjectType)] + public class C + { + public int M() + { + return 5; + } + } +} + +namespace +{ + internal static class $_ + { + } +} + *) \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Finalizer.Exception.cs b/source/Tests/Decompilation/TestCode/Finalizer.Exception.cs index b5eb2556..1244af9c 100644 --- a/source/Tests/Decompilation/TestCode/Finalizer.Exception.cs +++ b/source/Tests/Decompilation/TestCode/Finalizer.Exception.cs @@ -25,7 +25,7 @@ 69 74 79 2e 50 65 72 6d 69 73 73 69 6f 6e 73 2e 53 65 63 75 72 69 74 79 50 65 72 6d 69 73 73 69 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 53 79 73 74 65 6d 2e 52 75 6e 74 69 6d 65 2c 20 56 65 72 - 73 69 6f 6e 3d 37 2e 30 2e 30 2e 30 2c 20 43 75 + 73 69 6f 6e 3d 38 2e 30 2e 30 2e 30 2c 20 43 75 6c 74 75 72 65 3d 6e 65 75 74 72 61 6c 2c 20 50 75 62 6c 69 63 4b 65 79 54 6f 6b 65 6e 3d 62 30 33 66 35 66 37 66 31 31 64 35 30 61 33 61 15 01 @@ -48,7 +48,7 @@ .method family hidebysig virtual instance void Finalize () cil managed { .override method instance void [System.Runtime]System.Object::Finalize() - // Method begins at RVA 0x2068 + // Method begins at RVA 0x2050 // Code size 13 (0xd) .maxstack 1 @@ -70,7 +70,7 @@ .maxstack 1 .method public hidebysig specialname rtspecialname instance void .ctor () cil managed { - // Method begins at RVA 0x2094 + // Method begins at RVA 0x207c // Code size 7 (0x7) .maxstack 8 @@ -81,65 +81,4 @@ .maxstack 8 } // end of class C -.class private auto ansi sealed beforefieldinit Microsoft.CodeAnalysis.EmbeddedAttribute - extends [System.Runtime]System.Attribute -{ - .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( - 01 00 00 00 - ) - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor () cil managed - { - // Method begins at RVA 0x2050 - // Code size 7 (0x7) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [System.Runtime]System.Attribute::.ctor() - IL_0006: ret - } // end of method EmbeddedAttribute::.ctor - -} // end of class Microsoft.CodeAnalysis.EmbeddedAttribute - -.class private auto ansi sealed beforefieldinit System.Runtime.CompilerServices.RefSafetyRulesAttribute - extends [System.Runtime]System.Attribute -{ - .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void [System.Runtime]System.AttributeUsageAttribute::.ctor(valuetype [System.Runtime]System.AttributeTargets) = ( - 01 00 02 00 00 00 02 00 54 02 0d 41 6c 6c 6f 77 - 4d 75 6c 74 69 70 6c 65 00 54 02 09 49 6e 68 65 - 72 69 74 65 64 00 - ) - // Fields - .field public initonly int32 Version - - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor ( - int32 '' - ) cil managed - { - // Method begins at RVA 0x2058 - // Code size 14 (0xe) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [System.Runtime]System.Attribute::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld int32 System.Runtime.CompilerServices.RefSafetyRulesAttribute::Version - IL_000d: ret - } // end of method RefSafetyRulesAttribute::.ctor - -} // end of class System.Runtime.CompilerServices.RefSafetyRulesAttribute - */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Goto.TryWhile.cs b/source/Tests/Decompilation/TestCode/Goto.TryWhile.cs index aff0f59d..673b0ca4 100644 --- a/source/Tests/Decompilation/TestCode/Goto.TryWhile.cs +++ b/source/Tests/Decompilation/TestCode/Goto.TryWhile.cs @@ -1,75 +1,48 @@ -using System; -public class C { - void M() { - again: try { - while(true) {} - } - catch { - goto again; - } - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] - -public class C -{ - private void M() - { - while (true) - { - try - { - while (true) - { - } - } - catch - { - } - } - } -} - -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - +using System; +public class C { + void M() { + again: try { + while(true) {} + } + catch { + goto again; + } + } +} + +/* cs + +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] + +public class C +{ + private void M() + { + while (true) + { + try + { + while (true) + { + } + } + catch + { + } + } + } +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/JitAsm/Delegate.cs b/source/Tests/Decompilation/TestCode/JitAsm/Delegate.cs index a66e56c0..6359004c 100644 --- a/source/Tests/Decompilation/TestCode/JitAsm/Delegate.cs +++ b/source/Tests/Decompilation/TestCode/JitAsm/Delegate.cs @@ -1,26 +1,19 @@ -delegate void D(); - -/* asm - -; Core CLR on x64 - -D..ctor(System.Object, IntPtr) - ; Cannot produce JIT assembly for runtime-implemented method. - -D.Invoke() - ; Cannot produce JIT assembly for runtime-implemented method. - -D.BeginInvoke(System.AsyncCallback, System.Object) - ; Cannot produce JIT assembly for runtime-implemented method. - -D.EndInvoke(System.IAsyncResult) - ; Cannot produce JIT assembly for runtime-implemented method. - -Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() - L0000: ret - -System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) - L0000: mov [rcx+8], edx - L0003: ret - +delegate void D(); + +/* asm + +; Core CLR on x64 + +D..ctor(System.Object, IntPtr) + ; Cannot produce JIT assembly for runtime-implemented method. + +D.Invoke() + ; Cannot produce JIT assembly for runtime-implemented method. + +D.BeginInvoke(System.AsyncCallback, System.Object) + ; Cannot produce JIT assembly for runtime-implemented method. + +D.EndInvoke(System.IAsyncResult) + ; Cannot produce JIT assembly for runtime-implemented method. + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/JitAsm/DllImport.cs b/source/Tests/Decompilation/TestCode/JitAsm/DllImport.cs index 17e6dcf5..583b7804 100644 --- a/source/Tests/Decompilation/TestCode/JitAsm/DllImport.cs +++ b/source/Tests/Decompilation/TestCode/JitAsm/DllImport.cs @@ -13,11 +13,4 @@ public static class NativeMethods NativeMethods.GetLastError() ; Cannot produce JIT assembly for a P/Invoke method. -Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() - L0000: ret - -System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) - L0000: mov [rcx+8], edx - L0003: ret - */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/JitAsm/MethodImpl.InternalCall.cs b/source/Tests/Decompilation/TestCode/JitAsm/MethodImpl.InternalCall.cs index 200c9818..56eab67b 100644 --- a/source/Tests/Decompilation/TestCode/JitAsm/MethodImpl.InternalCall.cs +++ b/source/Tests/Decompilation/TestCode/JitAsm/MethodImpl.InternalCall.cs @@ -1,22 +1,15 @@ -using System.Runtime.CompilerServices; - -public static class C { - [MethodImpl(MethodImplOptions.InternalCall)] - public static extern void M(); -} - -/* asm - -; Core CLR on x64 - -C.M() - ; Cannot produce JIT assembly for an internal call method. - -Microsoft.CodeAnalysis.EmbeddedAttribute..ctor() - L0000: ret - -System.Runtime.CompilerServices.RefSafetyRulesAttribute..ctor(Int32) - L0000: mov [rcx+8], edx - L0003: ret - +using System.Runtime.CompilerServices; + +public static class C { + [MethodImpl(MethodImplOptions.InternalCall)] + public static extern void M(); +} + +/* asm + +; Core CLR on x64 + +C.M() + ; Cannot produce JIT assembly for an internal call method. + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Lambda.CallInArray.cs b/source/Tests/Decompilation/TestCode/Lambda.CallInArray.cs index eeb5ef67..be84244c 100644 --- a/source/Tests/Decompilation/TestCode/Lambda.CallInArray.cs +++ b/source/Tests/Decompilation/TestCode/Lambda.CallInArray.cs @@ -1,91 +1,65 @@ -using System; -public class C { - public void M() { - Func getInt = s => s; - var list = new [] { 1, 2, 3, getInt(1) }; - Console.WriteLine(list[3]); - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] - -public class C -{ - [Serializable] - [CompilerGenerated] - private sealed class <>c - { - public static readonly <>c <>9 = new <>c(); - - public static Func <>9__0_0; - - internal int b__0_0(int s) - { - return s; - } - } - - public void M() - { - Func func = <>c.<>9__0_0 ?? (<>c.<>9__0_0 = new Func(<>c.<>9.b__0_0)); - int[] array = new int[4]; - RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); - array[3] = func(1); - Console.WriteLine(array[3]); - } -} - -[CompilerGenerated] -internal sealed class -{ - [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 16)] - private struct __StaticArrayInitTypeSize=16 - { - } - - internal static readonly __StaticArrayInitTypeSize=16 81C1A5A2F482E82CA2C66653482AB24E6D90944BF183C8164E8F8F8D72DB60DB/* Not supported: data(01 00 00 00 02 00 00 00 03 00 00 00 00 00 00 00) */; -} - -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - +using System; +public class C { + public void M() { + Func getInt = s => s; + var list = new [] { 1, 2, 3, getInt(1) }; + Console.WriteLine(list[3]); + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Security.Permissions; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] + +public class C +{ + [Serializable] + [CompilerGenerated] + private sealed class <>c + { + public static readonly <>c <>9 = new <>c(); + + public static Func <>9__0_0; + + internal int b__0_0(int s) + { + return s; + } + } + + public void M() + { + Func func = <>c.<>9__0_0 ?? (<>c.<>9__0_0 = new Func(<>c.<>9.b__0_0)); + int[] array = new int[4]; + RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); + array[3] = func(1); + Console.WriteLine(array[3]); + } +} + +[CompilerGenerated] +internal sealed class +{ + [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 16)] + private struct __StaticArrayInitTypeSize=16 + { + } + + internal static readonly __StaticArrayInitTypeSize=16 81C1A5A2F482E82CA2C66653482AB24E6D90944BF183C8164E8F8F8D72DB60DB/* Not supported: data(01 00 00 00 02 00 00 00 03 00 00 00 00 00 00 00) */; +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Lock.Simple.cs b/source/Tests/Decompilation/TestCode/Lock.Simple.cs index 5df6ad55..d5715250 100644 --- a/source/Tests/Decompilation/TestCode/Lock.Simple.cs +++ b/source/Tests/Decompilation/TestCode/Lock.Simple.cs @@ -1,110 +1,51 @@ -// https://github.com/ashmind/SharpLab/issues/521 -using System; - -public class C { - public void M(object o) { - lock (o) { - Console.WriteLine(); - } - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using System.Threading; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] - -public class C -{ - [System.Runtime.CompilerServices.NullableContext(1)] - public void M(object o) - { - bool lockTaken = false; - try - { - Monitor.Enter(o, ref lockTaken); - Console.WriteLine(); - } - finally - { - if (lockTaken) - { - Monitor.Exit(o); - } - } - } -} - -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] - internal sealed class NullableAttribute : Attribute - { - public readonly byte[] NullableFlags; - - public NullableAttribute(byte P_0) - { - byte[] array = new byte[1]; - array[0] = P_0; - NullableFlags = array; - } - - public NullableAttribute(byte[] P_0) - { - NullableFlags = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] - internal sealed class NullableContextAttribute : Attribute - { - public readonly byte Flag; - - public NullableContextAttribute(byte P_0) - { - Flag = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - +// https://github.com/ashmind/SharpLab/issues/521 +using System; + +public class C { + public void M(object o) { + lock (o) { + Console.WriteLine(); + } + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; +using System.Threading; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] + +public class C +{ + [NullableContext(1)] + public void M(object o) + { + bool lockTaken = false; + try + { + Monitor.Enter(o, ref lockTaken); + Console.WriteLine(); + } + finally + { + if (lockTaken) + { + Monitor.Exit(o); + } + } + } +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Module.vb b/source/Tests/Decompilation/TestCode/Module.vb index 25437f68..326343df 100644 --- a/source/Tests/Decompilation/TestCode/Module.vb +++ b/source/Tests/Decompilation/TestCode/Module.vb @@ -1,21 +1,21 @@ -Public Module M -End Module - -/* cs - -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using Microsoft.VisualBasic.CompilerServices; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: AssemblyVersion("0.0.0.0")] - -[StandardModule] -public sealed class M -{ -} - +Public Module M +End Module + +/* cs + +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using Microsoft.VisualBasic.CompilerServices; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: AssemblyVersion("0.0.0.0")] + +[StandardModule] +public sealed class M +{ +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/NullPropagation.ToTernary.cs b/source/Tests/Decompilation/TestCode/NullPropagation.ToTernary.cs index 1dbc3b42..078d4c1d 100644 --- a/source/Tests/Decompilation/TestCode/NullPropagation.ToTernary.cs +++ b/source/Tests/Decompilation/TestCode/NullPropagation.ToTernary.cs @@ -1,111 +1,52 @@ -public class Point { - public int X { get; set; } - public int M(Point p) { - return (p?.X).GetValueOrDefault(); - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] - -public class Point -{ - [CompilerGenerated] - private int k__BackingField; - - public int X - { - [CompilerGenerated] - get - { - return k__BackingField; - } - [CompilerGenerated] - set - { - k__BackingField = value; - } - } - - [System.Runtime.CompilerServices.NullableContext(1)] - public int M(Point p) - { - Nullable num = ((p != null) ? new Nullable(p.X) : null); - return num.GetValueOrDefault(); - } -} - -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] - internal sealed class NullableAttribute : Attribute - { - public readonly byte[] NullableFlags; - - public NullableAttribute(byte P_0) - { - byte[] array = new byte[1]; - array[0] = P_0; - NullableFlags = array; - } - - public NullableAttribute(byte[] P_0) - { - NullableFlags = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] - internal sealed class NullableContextAttribute : Attribute - { - public readonly byte Flag; - - public NullableContextAttribute(byte P_0) - { - Flag = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - +public class Point { + public int X { get; set; } + public int M(Point p) { + return (p?.X).GetValueOrDefault(); + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] + +public class Point +{ + [CompilerGenerated] + private int k__BackingField; + + public int X + { + [CompilerGenerated] + get + { + return k__BackingField; + } + [CompilerGenerated] + set + { + k__BackingField = value; + } + } + + [NullableContext(1)] + public int M(Point p) + { + Nullable num = ((p != null) ? new Nullable(p.X) : null); + return num.GetValueOrDefault(); + } +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Nullable.OperatorLifting.cs b/source/Tests/Decompilation/TestCode/Nullable.OperatorLifting.cs index 23883316..9244c5d3 100644 --- a/source/Tests/Decompilation/TestCode/Nullable.OperatorLifting.cs +++ b/source/Tests/Decompilation/TestCode/Nullable.OperatorLifting.cs @@ -1,65 +1,39 @@ -using System; -public class C { - public bool M(DateTime? d) { - return d > DateTime.Now; - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] - -public class C -{ - public bool M(Nullable d) - { - Nullable dateTime = d; - DateTime now = DateTime.Now; - if (!dateTime.HasValue) - { - return false; - } - return dateTime.GetValueOrDefault() > now; - } -} - -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - +using System; +public class C { + public bool M(DateTime? d) { + return d > DateTime.Now; + } +} + +/* cs + +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] + +public class C +{ + public bool M(Nullable d) + { + Nullable dateTime = d; + DateTime now = DateTime.Now; + if (!dateTime.HasValue) + { + return false; + } + return dateTime.GetValueOrDefault() > now; + } +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Nullable.Reference.Simple.IL.cs b/source/Tests/Decompilation/TestCode/Nullable.Reference.Simple.IL.cs index ac240008..9a2692a9 100644 --- a/source/Tests/Decompilation/TestCode/Nullable.Reference.Simple.IL.cs +++ b/source/Tests/Decompilation/TestCode/Nullable.Reference.Simple.IL.cs @@ -1,249 +1,92 @@ -void M(object? value) { -} - -/* il - -.assembly _ -{ - .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( - 01 00 08 00 00 00 00 00 - ) - .custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( - 01 00 01 00 54 02 16 57 72 61 70 4e 6f 6e 45 78 - 63 65 70 74 69 6f 6e 54 68 72 6f 77 73 01 - ) - .custom instance void [System.Runtime]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( - 01 00 02 00 00 00 00 00 - ) - .permissionset reqmin = ( - 2e 01 80 8a 53 79 73 74 65 6d 2e 53 65 63 75 72 - 69 74 79 2e 50 65 72 6d 69 73 73 69 6f 6e 73 2e - 53 65 63 75 72 69 74 79 50 65 72 6d 69 73 73 69 - 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 53 79 73 - 74 65 6d 2e 52 75 6e 74 69 6d 65 2c 20 56 65 72 - 73 69 6f 6e 3d 37 2e 30 2e 30 2e 30 2c 20 43 75 - 6c 74 75 72 65 3d 6e 65 75 74 72 61 6c 2c 20 50 - 75 62 6c 69 63 4b 65 79 54 6f 6b 65 6e 3d 62 30 - 33 66 35 66 37 66 31 31 64 35 30 61 33 61 15 01 - 54 02 10 53 6b 69 70 56 65 72 69 66 69 63 61 74 - 69 6f 6e 01 - ) - .hash algorithm 0x // SHA1 - .ver 0:0:0:0 -} - -.class private auto ansi '' -{ -} // end of class - -.class private auto ansi beforefieldinit Program - extends [System.Runtime]System.Object -{ - .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - // Methods - .method private hidebysig static - void '
$' ( - string[] args - ) cil managed - { - // Method begins at RVA 0x209d - // Code size 1 (0x1) - .maxstack 8 - .entrypoint - - IL_0000: ret - } // end of method Program::'
$' - - .method public hidebysig specialname rtspecialname - instance void .ctor () cil managed - { - // Method begins at RVA 0x209f - // Code size 7 (0x7) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [System.Runtime]System.Object::.ctor() - IL_0006: ret - } // end of method Program::.ctor - - .method assembly hidebysig static - void '<
$>g__M|0_0' ( - object 'value' - ) cil managed - { - .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( - 01 00 02 00 00 - ) - .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - // Method begins at RVA 0x209d - // Code size 1 (0x1) - .maxstack 8 - - // sequence point: (line 2, col 1) to (line 2, col 2) in _ - IL_0000: ret - } // end of method Program::'<
$>g__M|0_0' - -} // end of class Program - -.class private auto ansi sealed beforefieldinit Microsoft.CodeAnalysis.EmbeddedAttribute - extends [System.Runtime]System.Attribute -{ - .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( - 01 00 00 00 - ) - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor () cil managed - { - // Method begins at RVA 0x2050 - // Code size 7 (0x7) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [System.Runtime]System.Attribute::.ctor() - IL_0006: ret - } // end of method EmbeddedAttribute::.ctor - -} // end of class Microsoft.CodeAnalysis.EmbeddedAttribute - -.class private auto ansi sealed beforefieldinit System.Runtime.CompilerServices.NullableAttribute - extends [System.Runtime]System.Attribute -{ - .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void [System.Runtime]System.AttributeUsageAttribute::.ctor(valuetype [System.Runtime]System.AttributeTargets) = ( - 01 00 84 6b 00 00 02 00 54 02 0d 41 6c 6c 6f 77 - 4d 75 6c 74 69 70 6c 65 00 54 02 09 49 6e 68 65 - 72 69 74 65 64 00 - ) - // Fields - .field public initonly uint8[] NullableFlags - - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor ( - uint8 '' - ) cil managed - { - // Method begins at RVA 0x2058 - // Code size 23 (0x17) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [System.Runtime]System.Attribute::.ctor() - IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [System.Runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret - } // end of method NullableAttribute::.ctor - - .method public hidebysig specialname rtspecialname - instance void .ctor ( - uint8[] '' - ) cil managed - { - // Method begins at RVA 0x2070 - // Code size 14 (0xe) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [System.Runtime]System.Attribute::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret - } // end of method NullableAttribute::.ctor - -} // end of class System.Runtime.CompilerServices.NullableAttribute - -.class private auto ansi sealed beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute - extends [System.Runtime]System.Attribute -{ - .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void [System.Runtime]System.AttributeUsageAttribute::.ctor(valuetype [System.Runtime]System.AttributeTargets) = ( - 01 00 4c 14 00 00 02 00 54 02 0d 41 6c 6c 6f 77 - 4d 75 6c 74 69 70 6c 65 00 54 02 09 49 6e 68 65 - 72 69 74 65 64 00 - ) - // Fields - .field public initonly uint8 Flag - - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor ( - uint8 '' - ) cil managed - { - // Method begins at RVA 0x207f - // Code size 14 (0xe) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [System.Runtime]System.Attribute::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag - IL_000d: ret - } // end of method NullableContextAttribute::.ctor - -} // end of class System.Runtime.CompilerServices.NullableContextAttribute - -.class private auto ansi sealed beforefieldinit System.Runtime.CompilerServices.RefSafetyRulesAttribute - extends [System.Runtime]System.Attribute -{ - .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void [System.Runtime]System.AttributeUsageAttribute::.ctor(valuetype [System.Runtime]System.AttributeTargets) = ( - 01 00 02 00 00 00 02 00 54 02 0d 41 6c 6c 6f 77 - 4d 75 6c 74 69 70 6c 65 00 54 02 09 49 6e 68 65 - 72 69 74 65 64 00 - ) - // Fields - .field public initonly int32 Version - - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor ( - int32 '' - ) cil managed - { - // Method begins at RVA 0x208e - // Code size 14 (0xe) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [System.Runtime]System.Attribute::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld int32 System.Runtime.CompilerServices.RefSafetyRulesAttribute::Version - IL_000d: ret - } // end of method RefSafetyRulesAttribute::.ctor - -} // end of class System.Runtime.CompilerServices.RefSafetyRulesAttribute - +void M(object? value) { +} + +/* il + +.assembly _ +{ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( + 01 00 08 00 00 00 00 00 + ) + .custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( + 01 00 01 00 54 02 16 57 72 61 70 4e 6f 6e 45 78 + 63 65 70 74 69 6f 6e 54 68 72 6f 77 73 01 + ) + .custom instance void [System.Runtime]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( + 01 00 02 00 00 00 00 00 + ) + .permissionset reqmin = ( + 2e 01 80 8a 53 79 73 74 65 6d 2e 53 65 63 75 72 + 69 74 79 2e 50 65 72 6d 69 73 73 69 6f 6e 73 2e + 53 65 63 75 72 69 74 79 50 65 72 6d 69 73 73 69 + 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 53 79 73 + 74 65 6d 2e 52 75 6e 74 69 6d 65 2c 20 56 65 72 + 73 69 6f 6e 3d 38 2e 30 2e 30 2e 30 2c 20 43 75 + 6c 74 75 72 65 3d 6e 65 75 74 72 61 6c 2c 20 50 + 75 62 6c 69 63 4b 65 79 54 6f 6b 65 6e 3d 62 30 + 33 66 35 66 37 66 31 31 64 35 30 61 33 61 15 01 + 54 02 10 53 6b 69 70 56 65 72 69 66 69 63 61 74 + 69 6f 6e 01 + ) + .hash algorithm 0x // SHA1 + .ver 0:0:0:0 +} + +.class private auto ansi '' +{ +} // end of class + +.class private auto ansi beforefieldinit Program + extends [System.Runtime]System.Object +{ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( + 01 00 00 00 + ) + // Methods + .method private hidebysig static + void '
$' ( + string[] args + ) cil managed + { + // Method begins at RVA 0x2050 + // Code size 1 (0x1) + .maxstack 8 + .entrypoint + + IL_0000: ret + } // end of method Program::'
$' + + .method public hidebysig specialname rtspecialname + instance void .ctor () cil managed + { + // Method begins at RVA 0x2052 + // Code size 7 (0x7) + .maxstack 8 + + IL_0000: ldarg.0 + IL_0001: call instance void [System.Runtime]System.Object::.ctor() + IL_0006: ret + } // end of method Program::.ctor + + .method assembly hidebysig static + void '<
$>g__M|0_0' ( + object 'value' + ) cil managed + { + .custom instance void [System.Runtime]System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( + 01 00 02 00 00 + ) + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( + 01 00 00 00 + ) + // Method begins at RVA 0x2050 + // Code size 1 (0x1) + .maxstack 8 + + // sequence point: (line 2, col 1) to (line 2, col 2) in _ + IL_0000: ret + } // end of method Program::'<
$>g__M|0_0' + +} // end of class Program + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Parameters.Optional.Decimal.cs b/source/Tests/Decompilation/TestCode/Parameters.Optional.Decimal.cs index 7c3c6612..37886335 100644 --- a/source/Tests/Decompilation/TestCode/Parameters.Optional.Decimal.cs +++ b/source/Tests/Decompilation/TestCode/Parameters.Optional.Decimal.cs @@ -1,57 +1,30 @@ -public class C { - public void M(decimal d = 5.0m) { - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] - -public class C -{ - public void M([Optional][DecimalConstant(1, 0, 0u, 0u, 50u)] decimal d) - { - } -} - -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - +public class C { + public void M(decimal d = 5.0m) { + } +} + +/* cs + +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Security.Permissions; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] + +public class C +{ + public void M([Optional][DecimalConstant(1, 0, 0u, 0u, 50u)] decimal d) + { + } +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Preprocessor.IfDebug.cs b/source/Tests/Decompilation/TestCode/Preprocessor.IfDebug.cs index a8f39aa7..b0d28030 100644 --- a/source/Tests/Decompilation/TestCode/Preprocessor.IfDebug.cs +++ b/source/Tests/Decompilation/TestCode/Preprocessor.IfDebug.cs @@ -11,13 +11,11 @@ public string M() { /* cs -using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; -using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] @@ -25,73 +23,15 @@ public string M() { [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] +[module: RefSafetyRules(11)] public class C { - [System.Runtime.CompilerServices.NullableContext(1)] + [NullableContext(1)] public string M() { return "Debug"; } } -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] - internal sealed class NullableAttribute : Attribute - { - public readonly byte[] NullableFlags; - - public NullableAttribute(byte P_0) - { - byte[] array = new byte[1]; - array[0] = P_0; - NullableFlags = array; - } - - public NullableAttribute(byte[] P_0) - { - NullableFlags = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] - internal sealed class NullableContextAttribute : Attribute - { - public readonly byte Flag; - - public NullableContextAttribute(byte P_0) - { - Flag = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Preprocessor.IfDebug.vb b/source/Tests/Decompilation/TestCode/Preprocessor.IfDebug.vb index 6f7de8f8..237f3e4d 100644 --- a/source/Tests/Decompilation/TestCode/Preprocessor.IfDebug.vb +++ b/source/Tests/Decompilation/TestCode/Preprocessor.IfDebug.vb @@ -1,30 +1,30 @@ -Public Class C - Public Function M() As String - #If DEBUG Then - Return "Debug" - #Else - Return "Release" - #End If - End Function -End Class - -/* cs - -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue | DebuggableAttribute.DebuggingModes.DisableOptimizations)] -[assembly: AssemblyVersion("0.0.0.0")] - -public class C -{ - public string M() - { - return "Debug"; - } -} - +Public Class C + Public Function M() As String + #If DEBUG Then + Return "Debug" + #Else + Return "Release" + #End If + End Function +End Class + +/* cs + +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue | DebuggableAttribute.DebuggingModes.DisableOptimizations)] +[assembly: AssemblyVersion("0.0.0.0")] + +public class C +{ + public string M() + { + return "Debug"; + } +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Property.InitOnly.cs b/source/Tests/Decompilation/TestCode/Property.InitOnly.cs index a000bafe..cd85b933 100644 --- a/source/Tests/Decompilation/TestCode/Property.InitOnly.cs +++ b/source/Tests/Decompilation/TestCode/Property.InitOnly.cs @@ -1,68 +1,41 @@ -public class C { - public int P { get; init; } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] - -public class C -{ - [CompilerGenerated] - private readonly int

k__BackingField; - - public int P - { - [CompilerGenerated] - get - { - return

k__BackingField; - } - [CompilerGenerated] - init - { -

k__BackingField = value; - } - } -} - -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - +public class C { + public int P { get; init; } +} + +/* cs + +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] + +public class C +{ + [CompilerGenerated] + private readonly int

k__BackingField; + + public int P + { + [CompilerGenerated] + get + { + return

k__BackingField; + } + [CompilerGenerated] + init + { +

k__BackingField = value; + } + } +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Scopes.File.cs b/source/Tests/Decompilation/TestCode/Scopes.File.cs index 6688f537..cf976963 100644 --- a/source/Tests/Decompilation/TestCode/Scopes.File.cs +++ b/source/Tests/Decompilation/TestCode/Scopes.File.cs @@ -1,50 +1,23 @@ -file class C {} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] - -internal class <_>FD2E2ADF7177B7A8AFDDBC12D1634CF23EA1A71020F6A1308070A16400FB68FDE__C -{ -} - -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - +file class C {} + +/* cs + +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] + +internal class <_>FD2E2ADF7177B7A8AFDDBC12D1634CF23EA1A71020F6A1308070A16400FB68FDE__C +{ +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Simple.cs b/source/Tests/Decompilation/TestCode/Simple.cs index 0977dbbe..575d15d0 100644 --- a/source/Tests/Decompilation/TestCode/Simple.cs +++ b/source/Tests/Decompilation/TestCode/Simple.cs @@ -21,7 +21,7 @@ 69 74 79 2e 50 65 72 6d 69 73 73 69 6f 6e 73 2e 53 65 63 75 72 69 74 79 50 65 72 6d 69 73 73 69 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 53 79 73 74 65 6d 2e 52 75 6e 74 69 6d 65 2c 20 56 65 72 - 73 69 6f 6e 3d 37 2e 30 2e 30 2e 30 2c 20 43 75 + 73 69 6f 6e 3d 38 2e 30 2e 30 2e 30 2c 20 43 75 6c 74 75 72 65 3d 6e 65 75 74 72 61 6c 2c 20 50 75 62 6c 69 63 4b 65 79 54 6f 6b 65 6e 3d 62 30 33 66 35 66 37 66 31 31 64 35 30 61 33 61 15 01 @@ -43,7 +43,7 @@ extends [System.Runtime]System.Object .method public hidebysig specialname rtspecialname instance void .ctor () cil managed { - // Method begins at RVA 0x2067 + // Method begins at RVA 0x2050 // Code size 7 (0x7) .maxstack 8 @@ -54,65 +54,4 @@ .maxstack 8 } // end of class Simple -.class private auto ansi sealed beforefieldinit Microsoft.CodeAnalysis.EmbeddedAttribute - extends [System.Runtime]System.Attribute -{ - .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( - 01 00 00 00 - ) - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor () cil managed - { - // Method begins at RVA 0x2050 - // Code size 7 (0x7) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [System.Runtime]System.Attribute::.ctor() - IL_0006: ret - } // end of method EmbeddedAttribute::.ctor - -} // end of class Microsoft.CodeAnalysis.EmbeddedAttribute - -.class private auto ansi sealed beforefieldinit System.Runtime.CompilerServices.RefSafetyRulesAttribute - extends [System.Runtime]System.Attribute -{ - .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor() = ( - 01 00 00 00 - ) - .custom instance void [System.Runtime]System.AttributeUsageAttribute::.ctor(valuetype [System.Runtime]System.AttributeTargets) = ( - 01 00 02 00 00 00 02 00 54 02 0d 41 6c 6c 6f 77 - 4d 75 6c 74 69 70 6c 65 00 54 02 09 49 6e 68 65 - 72 69 74 65 64 00 - ) - // Fields - .field public initonly int32 Version - - // Methods - .method public hidebysig specialname rtspecialname - instance void .ctor ( - int32 '' - ) cil managed - { - // Method begins at RVA 0x2058 - // Code size 14 (0xe) - .maxstack 8 - - IL_0000: ldarg.0 - IL_0001: call instance void [System.Runtime]System.Attribute::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld int32 System.Runtime.CompilerServices.RefSafetyRulesAttribute::Version - IL_000d: ret - } // end of method RefSafetyRulesAttribute::.ctor - -} // end of class System.Runtime.CompilerServices.RefSafetyRulesAttribute - */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Simple.vb b/source/Tests/Decompilation/TestCode/Simple.vb index 5477a99e..15bee169 100644 --- a/source/Tests/Decompilation/TestCode/Simple.vb +++ b/source/Tests/Decompilation/TestCode/Simple.vb @@ -1,24 +1,24 @@ -Public Class C - Public Sub M() - End Sub -End Class - -/* cs - -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: AssemblyVersion("0.0.0.0")] - -public class C -{ - public void M() - { - } -} - +Public Class C + Public Sub M() + End Sub +End Class + +/* cs + +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: AssemblyVersion("0.0.0.0")] + +public class C +{ + public void M() + { + } +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/StringInterpolation.Simple.cs b/source/Tests/Decompilation/TestCode/StringInterpolation.Simple.cs index 6cdd8e58..e6f6c87a 100644 --- a/source/Tests/Decompilation/TestCode/StringInterpolation.Simple.cs +++ b/source/Tests/Decompilation/TestCode/StringInterpolation.Simple.cs @@ -9,13 +9,11 @@ public void M() /* cs -using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; -using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] @@ -23,7 +21,7 @@ public void M() [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] +[module: RefSafetyRules(11)] public class C { @@ -38,29 +36,4 @@ public void M() } } -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Switch.String.Large.cs b/source/Tests/Decompilation/TestCode/Switch.String.Large.cs index 7a3793b7..bf63229c 100644 --- a/source/Tests/Decompilation/TestCode/Switch.String.Large.cs +++ b/source/Tests/Decompilation/TestCode/Switch.String.Large.cs @@ -1,172 +1,112 @@ -// https://github.com/ashmind/SharpLab/issues/489 -public class C -{ - public string M(string key) - { - switch (key) - { - case "Key1": return "1"; - case "Key2": return "2"; - case "Key3": return "3"; - case "Key4": return "4"; - case "Key5": return "5"; - case "Key6": return "6"; - case "Key7": return "7"; - default: return "?"; - } - } -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] - -public class C -{ - [System.Runtime.CompilerServices.NullableContext(1)] - public string M(string key) - { - uint num = .ComputeStringHash(key); - if (num <= 455788110) - { - if (num != 422232872) - { - if (num != 439010491) - { - if (num == 455788110 && key == "Key6") - { - return "6"; - } - } - else if (key == "Key5") - { - return "5"; - } - } - else if (key == "Key4") - { - return "4"; - } - } - else if (num <= 506120967) - { - if (num != 472565729) - { - if (num == 506120967 && key == "Key1") - { - return "1"; - } - } - else if (key == "Key7") - { - return "7"; - } - } - else if (num != 522898586) - { - if (num == 539676205 && key == "Key3") - { - return "3"; - } - } - else if (key == "Key2") - { - return "2"; - } - return "?"; - } -} - -[CompilerGenerated] -internal sealed class -{ - internal static uint ComputeStringHash(string s) - { - uint num = default(uint); - if (s != null) - { - num = 2166136261u; - int num2 = 0; - while (num2 < s.Length) - { - num = (s[num2] ^ num) * 16777619; - num2++; - } - } - return num; - } -} - -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] - internal sealed class NullableAttribute : Attribute - { - public readonly byte[] NullableFlags; - - public NullableAttribute(byte P_0) - { - byte[] array = new byte[1]; - array[0] = P_0; - NullableFlags = array; - } - - public NullableAttribute(byte[] P_0) - { - NullableFlags = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] - internal sealed class NullableContextAttribute : Attribute - { - public readonly byte Flag; - - public NullableContextAttribute(byte P_0) - { - Flag = P_0; - } - } - - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - +// https://github.com/ashmind/SharpLab/issues/489 +public class C +{ + public string M(string key) + { + switch (key) + { + case "Key1": return "1"; + case "Key2": return "2"; + case "Key3": return "3"; + case "Key4": return "4"; + case "Key5": return "5"; + case "Key6": return "6"; + case "Key7": return "7"; + default: return "?"; + } + } +} + +/* cs + +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Security.Permissions; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] + +public class C +{ + [NullableContext(1)] + public string M(string key) + { + uint num = .ComputeStringHash(key); + if (num <= 455788110) + { + if (num != 422232872) + { + if (num != 439010491) + { + if (num == 455788110 && key == "Key6") + { + return "6"; + } + } + else if (key == "Key5") + { + return "5"; + } + } + else if (key == "Key4") + { + return "4"; + } + } + else if (num <= 506120967) + { + if (num != 472565729) + { + if (num == 506120967 && key == "Key1") + { + return "1"; + } + } + else if (key == "Key7") + { + return "7"; + } + } + else if (num != 522898586) + { + if (num == 539676205 && key == "Key3") + { + return "3"; + } + } + else if (key == "Key2") + { + return "2"; + } + return "?"; + } +} + +[CompilerGenerated] +internal sealed class +{ + internal static uint ComputeStringHash(string s) + { + uint num = default(uint); + if (s != null) + { + num = 2166136261u; + int num2 = 0; + while (num2 < s.Length) + { + num = (s[num2] ^ num) * 16777619; + num2++; + } + } + return num; + } +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Unsafe.FixedBuffer.cs b/source/Tests/Decompilation/TestCode/Unsafe.FixedBuffer.cs index ddfea474..1511d415 100644 --- a/source/Tests/Decompilation/TestCode/Unsafe.FixedBuffer.cs +++ b/source/Tests/Decompilation/TestCode/Unsafe.FixedBuffer.cs @@ -1,64 +1,37 @@ -internal unsafe struct MyBuffer -{ - public fixed char fixedBuffer[128]; -} - -/* cs - -using System; -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.Permissions; -using Microsoft.CodeAnalysis; - -[assembly: CompilationRelaxations(8)] -[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] -[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] -[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] -[assembly: AssemblyVersion("0.0.0.0")] -[module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] - -internal struct MyBuffer -{ - [StructLayout(LayoutKind.Sequential, Size = 256)] - [CompilerGenerated] - [UnsafeValueType] - public struct e__FixedBuffer - { - public char FixedElementField; - } - - [FixedBuffer(typeof(char), 128)] - public e__FixedBuffer fixedBuffer; -} - -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - +internal unsafe struct MyBuffer +{ + public fixed char fixedBuffer[128]; +} + +/* cs + +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Security.Permissions; + +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] +[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +[assembly: AssemblyVersion("0.0.0.0")] +[module: UnverifiableCode] +[module: RefSafetyRules(11)] + +internal struct MyBuffer +{ + [StructLayout(LayoutKind.Sequential, Size = 256)] + [CompilerGenerated] + [UnsafeValueType] + public struct e__FixedBuffer + { + public char FixedElementField; + } + + [FixedBuffer(typeof(char), 128)] + public e__FixedBuffer fixedBuffer; +} + */ \ No newline at end of file diff --git a/source/Tests/Decompilation/TestCode/Using.Simple.cs b/source/Tests/Decompilation/TestCode/Using.Simple.cs index b5727aa5..2c35ab77 100644 --- a/source/Tests/Decompilation/TestCode/Using.Simple.cs +++ b/source/Tests/Decompilation/TestCode/Using.Simple.cs @@ -14,7 +14,6 @@ public void M() { using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; -using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] @@ -22,7 +21,7 @@ public void M() { [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] -[module: System.Runtime.CompilerServices.RefSafetyRules(11)] +[module: RefSafetyRules(11)] public class C { @@ -42,29 +41,4 @@ public void M() } } -namespace Microsoft.CodeAnalysis -{ - [CompilerGenerated] - [Embedded] - internal sealed class EmbeddedAttribute : Attribute - { - } -} - -namespace System.Runtime.CompilerServices -{ - [CompilerGenerated] - [Microsoft.CodeAnalysis.Embedded] - [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] - internal sealed class RefSafetyRulesAttribute : Attribute - { - public readonly int Version; - - public RefSafetyRulesAttribute(int P_0) - { - Version = P_0; - } - } -} - */ \ No newline at end of file diff --git a/source/Tests/Execution/FSharpTests.cs b/source/Tests/Execution/FSharpTests.cs index 3d5b132b..63565a0a 100644 --- a/source/Tests/Execution/FSharpTests.cs +++ b/source/Tests/Execution/FSharpTests.cs @@ -3,10 +3,15 @@ using Xunit; using SharpLab.Tests.Execution.Internal; using SharpLab.Tests.Internal; +using Xunit.Abstractions; namespace SharpLab.Tests.Execution { [Collection(TestCollectionNames.Execution)] public class FSharpTests { + public FSharpTests(ITestOutputHelper output) { + // TestDiagnosticLog.Enable(output); + } + [Fact] public async Task FSharp_Simple() { // Arrange diff --git a/source/Tests/Execution/TestCode/Inspect/Heap/Int32.cs b/source/Tests/Execution/TestCode/Inspect/Heap/Int32.cs index 7aa45fa1..620e06cb 100644 --- a/source/Tests/Execution/TestCode/Inspect/Heap/Int32.cs +++ b/source/Tests/Execution/TestCode/Inspect/Heap/Int32.cs @@ -1,14 +1,14 @@ -using System; -using System.Linq.Expressions; - -public static class Program { - public static void Main() { - Inspect.Heap(5); - } -} - -/* output - -#{"type":"inspection:memory","title":"System.Int32 at 0x","labels":[{"name":"header","offset":0,"length":8},{"name":"type handle","offset":8,"length":8},{"name":"m_value","offset":16,"length":4}],"data":[0,0,0,0,0,0,0,0,,,,,,,,,5,0,0,0,0,0,0,0]} - +using System; +using System.Linq.Expressions; + +public static class Program { + public static void Main() { + Inspect.Heap(5); + } +} + +/* output + +#{"type":"inspection:memory","title":"System.Int32 at 0x","labels":[{"name":"header","offset":0,"length":8},{"name":"type handle","offset":8,"length":8},{"name":"m_value","offset":16,"length":4}],"data":[0,0,0,0,0,0,0,0,,,,,,,,,5,0,0,0,0,0,0,0]} + */ \ No newline at end of file diff --git a/source/Tests/Execution/TestCode/Inspect/Heap/Simple.cs b/source/Tests/Execution/TestCode/Inspect/Heap/Simple.cs index 02a9773a..bc8eedcc 100644 --- a/source/Tests/Execution/TestCode/Inspect/Heap/Simple.cs +++ b/source/Tests/Execution/TestCode/Inspect/Heap/Simple.cs @@ -1,19 +1,19 @@ -using System; -using System.Linq.Expressions; - -public class C { - int a = 1; - byte b = 2; -} - -public static class Program { - public static void Main() { - Inspect.Heap(new C()); - } -} - -/* output - -#{"type":"inspection:memory","title":"C at 0x","labels":[{"name":"header","offset":0,"length":8},{"name":"type handle","offset":8,"length":8},{"name":"a","offset":16,"length":4},{"name":"b","offset":20,"length":1}],"data":[0,0,0,0,0,0,0,0,,,,,,,,,1,0,0,0,2,0,0,0]} - +using System; +using System.Linq.Expressions; + +public class C { + int a = 1; + byte b = 2; +} + +public static class Program { + public static void Main() { + Inspect.Heap(new C()); + } +} + +/* output + +#{"type":"inspection:memory","title":"C at 0x","labels":[{"name":"header","offset":0,"length":8},{"name":"type handle","offset":8,"length":8},{"name":"a","offset":16,"length":4},{"name":"b","offset":20,"length":1}],"data":[0,0,0,0,0,0,0,0,,,,,,,,,1,0,0,0,2,0,0,0]} + */ \ No newline at end of file diff --git a/source/Tests/Execution/TestCode/Inspect/Heap/Struct.Nested.cs b/source/Tests/Execution/TestCode/Inspect/Heap/Struct.Nested.cs index f25fd781..754b3e80 100644 --- a/source/Tests/Execution/TestCode/Inspect/Heap/Struct.Nested.cs +++ b/source/Tests/Execution/TestCode/Inspect/Heap/Struct.Nested.cs @@ -1,25 +1,25 @@ -using System; -using System.Linq.Expressions; - -public struct S { - public int a; - public byte b; - public SN n; -} - -public struct SN { - public int an; - public byte bn; -} - -public static class Program { - public static void Main() { - Inspect.Heap(new S { a = 1, b = 2, n = new SN { an = 3, bn = 4 } }); - } -} - -/* output - -#{"type":"inspection:memory","title":"S at 0x","labels":[{"name":"header","offset":0,"length":8},{"name":"type handle","offset":8,"length":8},{"name":"a","offset":16,"length":4},{"name":"b","offset":20,"length":1},{"name":"n","offset":24,"length":5,"nested":[{"name":"an","offset":24,"length":4},{"name":"bn","offset":28,"length":1}]}],"data":[0,0,0,0,0,0,0,0,,,,,,,,,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0]} - +using System; +using System.Linq.Expressions; + +public struct S { + public int a; + public byte b; + public SN n; +} + +public struct SN { + public int an; + public byte bn; +} + +public static class Program { + public static void Main() { + Inspect.Heap(new S { a = 1, b = 2, n = new SN { an = 3, bn = 4 } }); + } +} + +/* output + +#{"type":"inspection:memory","title":"S at 0x","labels":[{"name":"header","offset":0,"length":8},{"name":"type handle","offset":8,"length":8},{"name":"a","offset":16,"length":4},{"name":"b","offset":20,"length":1},{"name":"n","offset":24,"length":5,"nested":[{"name":"an","offset":24,"length":4},{"name":"bn","offset":28,"length":1}]}],"data":[0,0,0,0,0,0,0,0,,,,,,,,,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0]} + */ \ No newline at end of file diff --git a/source/Tests/Execution/TestCode/Inspect/Heap/Struct.cs b/source/Tests/Execution/TestCode/Inspect/Heap/Struct.cs index 7e83f819..3525df27 100644 --- a/source/Tests/Execution/TestCode/Inspect/Heap/Struct.cs +++ b/source/Tests/Execution/TestCode/Inspect/Heap/Struct.cs @@ -1,19 +1,19 @@ -using System; -using System.Linq.Expressions; - -public struct S { - public int a; - public byte b; -} - -public static class Program { - public static void Main() { - Inspect.Heap(new S { a = 1, b = 2 }); - } -} - -/* output - -#{"type":"inspection:memory","title":"S at 0x","labels":[{"name":"header","offset":0,"length":8},{"name":"type handle","offset":8,"length":8},{"name":"a","offset":16,"length":4},{"name":"b","offset":20,"length":1}],"data":[0,0,0,0,0,0,0,0,,,,,,,,,1,0,0,0,2,0,0,0]} - +using System; +using System.Linq.Expressions; + +public struct S { + public int a; + public byte b; +} + +public static class Program { + public static void Main() { + Inspect.Heap(new S { a = 1, b = 2 }); + } +} + +/* output + +#{"type":"inspection:memory","title":"S at 0x","labels":[{"name":"header","offset":0,"length":8},{"name":"type handle","offset":8,"length":8},{"name":"a","offset":16,"length":4},{"name":"b","offset":20,"length":1}],"data":[0,0,0,0,0,0,0,0,,,,,,,,,1,0,0,0,2,0,0,0]} + */ \ No newline at end of file diff --git a/source/Tests/Execution/TestCode/Inspect/MemoryGraph/DateTime.cs b/source/Tests/Execution/TestCode/Inspect/MemoryGraph/DateTime.cs index c4aecccb..c537c846 100644 --- a/source/Tests/Execution/TestCode/Inspect/MemoryGraph/DateTime.cs +++ b/source/Tests/Execution/TestCode/Inspect/MemoryGraph/DateTime.cs @@ -1,14 +1,14 @@ -using System; -using System.Linq.Expressions; - -public static class Program { - public static void Main() { - Inspect.MemoryGraph(new DateTime(2000, 1, 1)); - } -} - -/* output - -#{"type":"inspection:memory-graph","stack":[{"id":1,"offset":0,"size":8,"title":null,"value":"01.01.2000 00:00:00","nestedNodes":[{"id":2,"title":"_dateData","value":"630822816000000000"}]}],"heap":[],"references":[]} - +using System; +using System.Linq.Expressions; + +public static class Program { + public static void Main() { + Inspect.MemoryGraph(new DateTime(2000, 1, 1)); + } +} + +/* output + +#{"type":"inspection:memory-graph","stack":[{"id":1,"offset":0,"size":8,"title":null,"value":"01.01.2000 00:00:00","nestedNodes":[{"id":2,"title":"_dateData","value":"630822816000000000"}]}],"heap":[],"references":[]} + */ \ No newline at end of file diff --git a/source/Tests/Execution/TestCode/Inspect/MemoryGraph/Int32.cs b/source/Tests/Execution/TestCode/Inspect/MemoryGraph/Int32.cs index b3fa6031..49f6fd53 100644 --- a/source/Tests/Execution/TestCode/Inspect/MemoryGraph/Int32.cs +++ b/source/Tests/Execution/TestCode/Inspect/MemoryGraph/Int32.cs @@ -1,14 +1,14 @@ -using System; -using System.Linq.Expressions; - -public static class Program { - public static void Main() { - Inspect.MemoryGraph(1); - } -} - -/* output - -#{"type":"inspection:memory-graph","stack":[{"id":1,"offset":0,"size":4,"title":null,"value":"1"}],"heap":[],"references":[]} - +using System; +using System.Linq.Expressions; + +public static class Program { + public static void Main() { + Inspect.MemoryGraph(1); + } +} + +/* output + +#{"type":"inspection:memory-graph","stack":[{"id":1,"offset":0,"size":4,"title":null,"value":"1"}],"heap":[],"references":[]} + */ \ No newline at end of file diff --git a/source/Tests/Execution/TestCode/Inspect/MemoryGraph/Null.cs b/source/Tests/Execution/TestCode/Inspect/MemoryGraph/Null.cs index f324b69c..4b9ad5d0 100644 --- a/source/Tests/Execution/TestCode/Inspect/MemoryGraph/Null.cs +++ b/source/Tests/Execution/TestCode/Inspect/MemoryGraph/Null.cs @@ -1,13 +1,13 @@ -using System; - -public static class Program { - public static void Main() { - Inspect.MemoryGraph((object)null); - } -} - -/* output - -#{"type":"inspection:memory-graph","stack":[{"id":1,"offset":0,"size":8,"title":null,"value":"null"}],"heap":[],"references":[]} - +using System; + +public static class Program { + public static void Main() { + Inspect.MemoryGraph((object)null); + } +} + +/* output + +#{"type":"inspection:memory-graph","stack":[{"id":1,"offset":0,"size":8,"title":null,"value":"null"}],"heap":[],"references":[]} + */ \ No newline at end of file diff --git a/source/Tests/Execution/TestCode/Inspect/MemoryGraph/String.cs b/source/Tests/Execution/TestCode/Inspect/MemoryGraph/String.cs index b3c30d4e..3ebadf84 100644 --- a/source/Tests/Execution/TestCode/Inspect/MemoryGraph/String.cs +++ b/source/Tests/Execution/TestCode/Inspect/MemoryGraph/String.cs @@ -1,14 +1,14 @@ -using System; -using System.Linq.Expressions; - -public static class Program { - public static void Main() { - Inspect.MemoryGraph("a"); - } -} - -/* output - -#{"type":"inspection:memory-graph","stack":[{"id":1,"offset":0,"size":8,"title":null,"value":"String ref"}],"heap":[{"id":2,"title":"String","value":"a"}],"references":[{"from":1,"to":2}]} - +using System; +using System.Linq.Expressions; + +public static class Program { + public static void Main() { + Inspect.MemoryGraph("a"); + } +} + +/* output + +#{"type":"inspection:memory-graph","stack":[{"id":1,"offset":0,"size":8,"title":null,"value":"String ref"}],"heap":[{"id":2,"title":"String","value":"a"}],"references":[{"from":1,"to":2}]} + */ \ No newline at end of file diff --git a/source/Tests/Execution/TestCode/Inspect/MemoryGraph/Variables.cs b/source/Tests/Execution/TestCode/Inspect/MemoryGraph/Variables.cs index 045be2de..c8126350 100644 --- a/source/Tests/Execution/TestCode/Inspect/MemoryGraph/Variables.cs +++ b/source/Tests/Execution/TestCode/Inspect/MemoryGraph/Variables.cs @@ -1,19 +1,19 @@ -using System; -using System.Linq.Expressions; - -public static class Program { - public static void Main() { - var a = 1; - var b = 2; - var c = "c"; - Inspect.MemoryGraph(a, c); - Inspect.MemoryGraph(b); - } -} - -/* output - +using System; +using System.Linq.Expressions; + +public static class Program { + public static void Main() { + var a = 1; + var b = 2; + var c = "c"; + Inspect.MemoryGraph(a, c); + Inspect.MemoryGraph(b); + } +} + +/* output + #{"type":"inspection:memory-graph","stack":[{"id":1,"offset":16,"size":4,"title":"a","value":"1"},{"id":2,"offset":0,"size":8,"title":"c","value":"String ref"}],"heap":[{"id":3,"title":"String","value":"c"}],"references":[{"from":2,"to":3}]} -#{"type":"inspection:memory-graph","stack":[{"id":1,"offset":0,"size":4,"title":"b","value":"2"}],"heap":[],"references":[]} - +#{"type":"inspection:memory-graph","stack":[{"id":1,"offset":0,"size":4,"title":"b","value":"2"}],"heap":[],"references":[]} + */ \ No newline at end of file