diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj index 615ac0d13..741ad9973 100644 --- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj +++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj @@ -80,6 +80,7 @@ + diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs index 20deea256..05fe84c6a 100644 --- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs @@ -257,6 +257,13 @@ namespace ICSharpCode.Decompiler.Tests RunForLibrary(cscOptions: cscOptions); } + [Test] + [Ignore("Special cases not implemented in new decompiler.")] + public void ValueTypes([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions) + { + RunForLibrary(cscOptions: cscOptions); + } + [Test] public void VariableNaming([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions) { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.cs new file mode 100644 index 000000000..b84369d54 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.cs @@ -0,0 +1,186 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty +{ + public static class ValueTypes + { + public struct S + { + public int Field; + + public S(int field) + { + Field = field; + } + + public void SetField() + { + Field = 5; + } + + public void MethodCalls() + { + SetField(); + Test(this); + Test(ref this); + } + + private static void Test(S byVal) + { + } + + private static void Test(ref S byRef) + { + } + } + + private static readonly S ReadOnlyS = default(S); + private static S MutableS = default(S); + private static volatile int VolatileInt; + + public static void CallMethodViaField() + { + ReadOnlyS.SetField(); + MutableS.SetField(); + S mutableS = MutableS; + mutableS.SetField(); + } + + public static S InitObj1() + { + S result = default(S); + MakeArray(); + return result; + } + + public static S InitObj2() + { + return default(S); + } + + public static void InitObj3(out S p) + { + p = default(S); + } + + public static S CallValueTypeCtor1() + { + return new S(10); + } + + public static S CallValueTypeCtor2() + { + S result = new S(10); + return result; + } + + public static S Copy1(S p) + { + return p; + } + + public static S Copy2(ref S p) + { + return p; + } + + public static void Copy3(S p, out S o) + { + o = p; + } + + public static void Copy4(ref S p, out S o) + { + o = p; + } + + public static void Copy4b(ref S p, out S o) + { + // test passing through by-ref arguments + Copy4(ref p, out o); + } + + public static void Issue56(int i, out string str) + { + str = "qq"; + str += i.ToString(); + } + + public static void CopyAroundAndModifyField(S s) + { + S s2 = s; + s2.Field += 10; + s = s2; + } + + private static int[] MakeArray() + { + return null; + } + + public static void IncrementArrayLocation() + { + MakeArray()[Environment.TickCount]++; + } + + public static bool Is(object obj) + { + return obj is S; + } + + public static bool IsNullable(object obj) + { + return obj is S?; + } + + public static S? As(object obj) + { + return obj as S?; + } + + public static S OnlyChangeTheCopy(S p) + { + S s = p; + s.SetField(); + return p; + } + + public static void UseRefBoolInCondition(ref bool x) + { + if (x) { + Console.WriteLine("true"); + } + } + + public static void CompareNotEqual0IsReallyNotEqual(IComparable a) + { + if (a.CompareTo(0) != 0) { + Console.WriteLine("true"); + } + } + + public static void CompareEqual0IsReallyEqual(IComparable a) + { + if (a.CompareTo(0) == 0) { + Console.WriteLine("true"); + } + } + } +} \ No newline at end of file diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.il new file mode 100644 index 000000000..aed36d5ec --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.il @@ -0,0 +1,511 @@ + + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly ValueTypes +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module ValueTypes.dll +.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) +.imagebase 0x10000000 +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 // WINDOWS_CUI +.corflags 0x00000001 // ILONLY + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes + extends [mscorlib]System.Object +{ + .class sequential ansi sealed nested public beforefieldinit S + extends [mscorlib]System.ValueType + { + .field public int32 Field + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 'field') cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_0008: ret + } // end of method S::.ctor + + .method public hidebysig instance void + SetField() cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldc.i4.5 + IL_0003: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_0008: ret + } // end of method S::SetField + + .method public hidebysig instance void + MethodCalls() cil managed + { + // Code size 28 (0x1c) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0007: nop + IL_0008: ldarg.0 + IL_0009: ldobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_000e: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S) + IL_0013: nop + IL_0014: ldarg.0 + IL_0015: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S&) + IL_001a: nop + IL_001b: ret + } // end of method S::MethodCalls + + .method private hidebysig static void + Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S byVal) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method S::Test + + .method private hidebysig static void + Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& byRef) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method S::Test + + } // end of class S + + .field private static initonly valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ReadOnlyS + .field private static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S MutableS + .field private static int32 modreq([mscorlib]System.Runtime.CompilerServices.IsVolatile) VolatileInt + .method public hidebysig static void CallMethodViaField() cil managed + { + // Code size 41 (0x29) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_1) + IL_0000: nop + IL_0001: ldsfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::ReadOnlyS + IL_0006: stloc.1 + IL_0007: ldloca.s V_1 + IL_0009: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_000e: nop + IL_000f: ldsflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MutableS + IL_0014: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0019: nop + IL_001a: ldsfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MutableS + IL_001f: stloc.0 + IL_0020: ldloca.s V_0 + IL_0022: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0027: nop + IL_0028: ret + } // end of method ValueTypes::CallMethodViaField + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + InitObj1() cil managed + { + // Code size 21 (0x15) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_1) + IL_0000: nop + IL_0001: ldloca.s V_0 + IL_0003: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0009: call int32[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MakeArray() + IL_000e: pop + IL_000f: ldloc.0 + IL_0010: stloc.1 + IL_0011: br.s IL_0013 + + IL_0013: ldloc.1 + IL_0014: ret + } // end of method ValueTypes::InitObj1 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + InitObj2() cil managed + { + // Code size 15 (0xf) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_1) + IL_0000: nop + IL_0001: ldloca.s V_1 + IL_0003: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0009: ldloc.1 + IL_000a: stloc.0 + IL_000b: br.s IL_000d + + IL_000d: ldloc.0 + IL_000e: ret + } // end of method ValueTypes::InitObj2 + + .method public hidebysig static void InitObj3([out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p) cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0008: ret + } // end of method ValueTypes::InitObj3 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + CallValueTypeCtor1() cil managed + { + // Code size 13 (0xd) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: nop + IL_0001: ldc.i4.s 10 + IL_0003: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::.ctor(int32) + IL_0008: stloc.0 + IL_0009: br.s IL_000b + + IL_000b: ldloc.0 + IL_000c: ret + } // end of method ValueTypes::CallValueTypeCtor1 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + CallValueTypeCtor2() cil managed + { + // Code size 17 (0x11) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_1) + IL_0000: nop + IL_0001: ldloca.s V_0 + IL_0003: ldc.i4.s 10 + IL_0005: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::.ctor(int32) + IL_000a: nop + IL_000b: ldloc.0 + IL_000c: stloc.1 + IL_000d: br.s IL_000f + + IL_000f: ldloc.1 + IL_0010: ret + } // end of method ValueTypes::CallValueTypeCtor2 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + Copy1(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S p) cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method ValueTypes::Copy1 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + Copy2(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p) cil managed + { + // Code size 12 (0xc) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0007: stloc.0 + IL_0008: br.s IL_000a + + IL_000a: ldloc.0 + IL_000b: ret + } // end of method ValueTypes::Copy2 + + .method public hidebysig static void Copy3(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S p, + [out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& o) cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldarg.0 + IL_0003: stobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0008: ret + } // end of method ValueTypes::Copy3 + + .method public hidebysig static void Copy4(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p, + [out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& o) cil managed + { + // Code size 14 (0xe) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldarg.0 + IL_0003: ldobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0008: stobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_000d: ret + } // end of method ValueTypes::Copy4 + + .method public hidebysig static void Copy4b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p, + [out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& o) cil managed + { + // Code size 10 (0xa) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::Copy4(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S&, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S&) + IL_0008: nop + IL_0009: ret + } // end of method ValueTypes::Copy4b + + .method public hidebysig static void Issue56(int32 i, + [out] string& str) cil managed + { + // Code size 25 (0x19) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldstr "qq" + IL_0007: stind.ref + IL_0008: ldarg.1 + IL_0009: dup + IL_000a: ldind.ref + IL_000b: ldarga.s i + IL_000d: call instance string [mscorlib]System.Int32::ToString() + IL_0012: call string [mscorlib]System.String::Concat(string, + string) + IL_0017: stind.ref + IL_0018: ret + } // end of method ValueTypes::Issue56 + + .method public hidebysig static void CopyAroundAndModifyField(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S s) cil managed + { + // Code size 23 (0x17) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.0 + IL_0003: ldloca.s V_0 + IL_0005: dup + IL_0006: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_000b: ldc.i4.s 10 + IL_000d: add + IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_0013: ldloc.0 + IL_0014: starg.s s + IL_0016: ret + } // end of method ValueTypes::CopyAroundAndModifyField + + .method private hidebysig static int32[] + MakeArray() cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (int32[] V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method ValueTypes::MakeArray + + .method public hidebysig static void IncrementArrayLocation() cil managed + { + // Code size 30 (0x1e) + .maxstack 8 + IL_0000: nop + IL_0001: call int32[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MakeArray() + IL_0006: call int32 [mscorlib]System.Environment::get_TickCount() + IL_000b: ldelema [mscorlib]System.Int32 + IL_0010: dup + IL_0011: ldobj [mscorlib]System.Int32 + IL_0016: ldc.i4.1 + IL_0017: add + IL_0018: stobj [mscorlib]System.Int32 + IL_001d: ret + } // end of method ValueTypes::IncrementArrayLocation + + .method public hidebysig static bool Is(object obj) cil managed + { + // Code size 15 (0xf) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: isinst ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0007: ldnull + IL_0008: cgt.un + IL_000a: stloc.0 + IL_000b: br.s IL_000d + + IL_000d: ldloc.0 + IL_000e: ret + } // end of method ValueTypes::Is + + .method public hidebysig static bool IsNullable(object obj) cil managed + { + // Code size 15 (0xf) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: isinst valuetype [mscorlib]System.Nullable`1 + IL_0007: ldnull + IL_0008: cgt.un + IL_000a: stloc.0 + IL_000b: br.s IL_000d + + IL_000d: ldloc.0 + IL_000e: ret + } // end of method ValueTypes::IsNullable + + .method public hidebysig static valuetype [mscorlib]System.Nullable`1 + As(object obj) cil managed + { + // Code size 17 (0x11) + .maxstack 1 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: isinst valuetype [mscorlib]System.Nullable`1 + IL_0007: unbox.any valuetype [mscorlib]System.Nullable`1 + IL_000c: stloc.0 + IL_000d: br.s IL_000f + + IL_000f: ldloc.0 + IL_0010: ret + } // end of method ValueTypes::As + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + OnlyChangeTheCopy(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S p) cil managed + { + // Code size 17 (0x11) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_1) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.0 + IL_0003: ldloca.s V_0 + IL_0005: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_000a: nop + IL_000b: ldarg.0 + IL_000c: stloc.1 + IL_000d: br.s IL_000f + + IL_000f: ldloc.1 + IL_0010: ret + } // end of method ValueTypes::OnlyChangeTheCopy + + .method public hidebysig static void UseRefBoolInCondition(bool& x) cil managed + { + // Code size 24 (0x18) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldind.i1 + IL_0003: ldc.i4.0 + IL_0004: ceq + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: brtrue.s IL_0017 + + IL_000a: nop + IL_000b: ldstr "true" + IL_0010: call void [mscorlib]System.Console::WriteLine(string) + IL_0015: nop + IL_0016: nop + IL_0017: ret + } // end of method ValueTypes::UseRefBoolInCondition + + .method public hidebysig static void CompareNotEqual0IsReallyNotEqual(class [mscorlib]System.IComparable`1 a) cil managed + { + // Code size 29 (0x1d) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldc.i4.0 + IL_0003: callvirt instance int32 class [mscorlib]System.IComparable`1::CompareTo(!0) + IL_0008: ldc.i4.0 + IL_0009: ceq + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: brtrue.s IL_001c + + IL_000f: nop + IL_0010: ldstr "true" + IL_0015: call void [mscorlib]System.Console::WriteLine(string) + IL_001a: nop + IL_001b: nop + IL_001c: ret + } // end of method ValueTypes::CompareNotEqual0IsReallyNotEqual + + .method public hidebysig static void CompareEqual0IsReallyEqual(class [mscorlib]System.IComparable`1 a) cil managed + { + // Code size 32 (0x20) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldc.i4.0 + IL_0003: callvirt instance int32 class [mscorlib]System.IComparable`1::CompareTo(!0) + IL_0008: ldc.i4.0 + IL_0009: ceq + IL_000b: ldc.i4.0 + IL_000c: ceq + IL_000e: stloc.0 + IL_000f: ldloc.0 + IL_0010: brtrue.s IL_001f + + IL_0012: nop + IL_0013: ldstr "true" + IL_0018: call void [mscorlib]System.Console::WriteLine(string) + IL_001d: nop + IL_001e: nop + IL_001f: ret + } // end of method ValueTypes::CompareEqual0IsReallyEqual + + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 23 (0x17) + .maxstack 8 + IL_0000: ldsflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::ReadOnlyS + IL_0005: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_000b: ldsflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MutableS + IL_0010: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0016: ret + } // end of method ValueTypes::.cctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.opt.il new file mode 100644 index 000000000..680e1af82 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.opt.il @@ -0,0 +1,394 @@ + + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly ValueTypes.opt +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module ValueTypes.opt.dll +.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) +.imagebase 0x10000000 +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 // WINDOWS_CUI +.corflags 0x00000001 // ILONLY + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes + extends [mscorlib]System.Object +{ + .class sequential ansi sealed nested public beforefieldinit S + extends [mscorlib]System.ValueType + { + .field public int32 Field + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 'field') cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_0007: ret + } // end of method S::.ctor + + .method public hidebysig instance void + SetField() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldc.i4.5 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_0007: ret + } // end of method S::SetField + + .method public hidebysig instance void + MethodCalls() cil managed + { + // Code size 24 (0x18) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0006: ldarg.0 + IL_0007: ldobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_000c: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S) + IL_0011: ldarg.0 + IL_0012: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S&) + IL_0017: ret + } // end of method S::MethodCalls + + .method private hidebysig static void + Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S byVal) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method S::Test + + .method private hidebysig static void + Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& byRef) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method S::Test + + } // end of class S + + .field private static initonly valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ReadOnlyS + .field private static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S MutableS + .field private static int32 modreq([mscorlib]System.Runtime.CompilerServices.IsVolatile) VolatileInt + .method public hidebysig static void CallMethodViaField() cil managed + { + // Code size 37 (0x25) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_1) + IL_0000: ldsfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::ReadOnlyS + IL_0005: stloc.1 + IL_0006: ldloca.s V_1 + IL_0008: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_000d: ldsflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MutableS + IL_0012: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0017: ldsfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MutableS + IL_001c: stloc.0 + IL_001d: ldloca.s V_0 + IL_001f: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0024: ret + } // end of method ValueTypes::CallMethodViaField + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + InitObj1() cil managed + { + // Code size 16 (0x10) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0008: call int32[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MakeArray() + IL_000d: pop + IL_000e: ldloc.0 + IL_000f: ret + } // end of method ValueTypes::InitObj1 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + InitObj2() cil managed + { + // Code size 10 (0xa) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0008: ldloc.0 + IL_0009: ret + } // end of method ValueTypes::InitObj2 + + .method public hidebysig static void InitObj3([out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p) cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0007: ret + } // end of method ValueTypes::InitObj3 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + CallValueTypeCtor1() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::.ctor(int32) + IL_0007: ret + } // end of method ValueTypes::CallValueTypeCtor1 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + CallValueTypeCtor2() cil managed + { + // Code size 11 (0xb) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: ldloca.s V_0 + IL_0002: ldc.i4.s 10 + IL_0004: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::.ctor(int32) + IL_0009: ldloc.0 + IL_000a: ret + } // end of method ValueTypes::CallValueTypeCtor2 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + Copy1(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S p) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } // end of method ValueTypes::Copy1 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + Copy2(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p) cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0006: ret + } // end of method ValueTypes::Copy2 + + .method public hidebysig static void Copy3(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S p, + [out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& o) cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: stobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0007: ret + } // end of method ValueTypes::Copy3 + + .method public hidebysig static void Copy4(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p, + [out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& o) cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0007: stobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_000c: ret + } // end of method ValueTypes::Copy4 + + .method public hidebysig static void Copy4b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p, + [out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& o) cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::Copy4(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S&, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S&) + IL_0007: ret + } // end of method ValueTypes::Copy4b + + .method public hidebysig static void Issue56(int32 i, + [out] string& str) cil managed + { + // Code size 24 (0x18) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldstr "qq" + IL_0006: stind.ref + IL_0007: ldarg.1 + IL_0008: dup + IL_0009: ldind.ref + IL_000a: ldarga.s i + IL_000c: call instance string [mscorlib]System.Int32::ToString() + IL_0011: call string [mscorlib]System.String::Concat(string, + string) + IL_0016: stind.ref + IL_0017: ret + } // end of method ValueTypes::Issue56 + + .method public hidebysig static void CopyAroundAndModifyField(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S s) cil managed + { + // Code size 22 (0x16) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: dup + IL_0005: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_000a: ldc.i4.s 10 + IL_000c: add + IL_000d: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_0012: ldloc.0 + IL_0013: starg.s s + IL_0015: ret + } // end of method ValueTypes::CopyAroundAndModifyField + + .method private hidebysig static int32[] + MakeArray() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } // end of method ValueTypes::MakeArray + + .method public hidebysig static void IncrementArrayLocation() cil managed + { + // Code size 29 (0x1d) + .maxstack 8 + IL_0000: call int32[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MakeArray() + IL_0005: call int32 [mscorlib]System.Environment::get_TickCount() + IL_000a: ldelema [mscorlib]System.Int32 + IL_000f: dup + IL_0010: ldobj [mscorlib]System.Int32 + IL_0015: ldc.i4.1 + IL_0016: add + IL_0017: stobj [mscorlib]System.Int32 + IL_001c: ret + } // end of method ValueTypes::IncrementArrayLocation + + .method public hidebysig static bool Is(object obj) cil managed + { + // Code size 10 (0xa) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0006: ldnull + IL_0007: cgt.un + IL_0009: ret + } // end of method ValueTypes::Is + + .method public hidebysig static bool IsNullable(object obj) cil managed + { + // Code size 10 (0xa) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst valuetype [mscorlib]System.Nullable`1 + IL_0006: ldnull + IL_0007: cgt.un + IL_0009: ret + } // end of method ValueTypes::IsNullable + + .method public hidebysig static valuetype [mscorlib]System.Nullable`1 + As(object obj) cil managed + { + // Code size 12 (0xc) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst valuetype [mscorlib]System.Nullable`1 + IL_0006: unbox.any valuetype [mscorlib]System.Nullable`1 + IL_000b: ret + } // end of method ValueTypes::As + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + OnlyChangeTheCopy(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S p) cil managed + { + // Code size 11 (0xb) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0009: ldarg.0 + IL_000a: ret + } // end of method ValueTypes::OnlyChangeTheCopy + + .method public hidebysig static void UseRefBoolInCondition(bool& x) cil managed + { + // Code size 15 (0xf) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldind.i1 + IL_0002: brfalse.s IL_000e + + IL_0004: ldstr "true" + IL_0009: call void [mscorlib]System.Console::WriteLine(string) + IL_000e: ret + } // end of method ValueTypes::UseRefBoolInCondition + + .method public hidebysig static void CompareNotEqual0IsReallyNotEqual(class [mscorlib]System.IComparable`1 a) cil managed + { + // Code size 20 (0x14) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldc.i4.0 + IL_0002: callvirt instance int32 class [mscorlib]System.IComparable`1::CompareTo(!0) + IL_0007: brfalse.s IL_0013 + + IL_0009: ldstr "true" + IL_000e: call void [mscorlib]System.Console::WriteLine(string) + IL_0013: ret + } // end of method ValueTypes::CompareNotEqual0IsReallyNotEqual + + .method public hidebysig static void CompareEqual0IsReallyEqual(class [mscorlib]System.IComparable`1 a) cil managed + { + // Code size 20 (0x14) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldc.i4.0 + IL_0002: callvirt instance int32 class [mscorlib]System.IComparable`1::CompareTo(!0) + IL_0007: brtrue.s IL_0013 + + IL_0009: ldstr "true" + IL_000e: call void [mscorlib]System.Console::WriteLine(string) + IL_0013: ret + } // end of method ValueTypes::CompareEqual0IsReallyEqual + + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 23 (0x17) + .maxstack 8 + IL_0000: ldsflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::ReadOnlyS + IL_0005: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_000b: ldsflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MutableS + IL_0010: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0016: ret + } // end of method ValueTypes::.cctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.opt.roslyn.il new file mode 100644 index 000000000..d1b80e62c --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.opt.roslyn.il @@ -0,0 +1,392 @@ + + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly ValueTypes +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + // --- The following custom attribute is added automatically, do not uncomment ------- + // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 ) + + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module ValueTypes.dll +.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) +.imagebase 0x10000000 +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 // WINDOWS_CUI +.corflags 0x00000001 // ILONLY + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes + extends [mscorlib]System.Object +{ + .class sequential ansi sealed nested public beforefieldinit S + extends [mscorlib]System.ValueType + { + .field public int32 Field + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 'field') cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_0007: ret + } // end of method S::.ctor + + .method public hidebysig instance void + SetField() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldc.i4.5 + IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_0007: ret + } // end of method S::SetField + + .method public hidebysig instance void + MethodCalls() cil managed + { + // Code size 24 (0x18) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0006: ldarg.0 + IL_0007: ldobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_000c: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S) + IL_0011: ldarg.0 + IL_0012: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S&) + IL_0017: ret + } // end of method S::MethodCalls + + .method private hidebysig static void + Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S byVal) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method S::Test + + .method private hidebysig static void + Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& byRef) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method S::Test + + } // end of class S + + .field private static initonly valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ReadOnlyS + .field private static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S MutableS + .field private static int32 modreq([mscorlib]System.Runtime.CompilerServices.IsVolatile) VolatileInt + .method public hidebysig static void CallMethodViaField() cil managed + { + // Code size 37 (0x25) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_1) + IL_0000: ldsfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::ReadOnlyS + IL_0005: stloc.1 + IL_0006: ldloca.s V_1 + IL_0008: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_000d: ldsflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MutableS + IL_0012: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0017: ldsfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MutableS + IL_001c: stloc.0 + IL_001d: ldloca.s V_0 + IL_001f: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0024: ret + } // end of method ValueTypes::CallMethodViaField + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + InitObj1() cil managed + { + // Code size 16 (0x10) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0008: ldloc.0 + IL_0009: call int32[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MakeArray() + IL_000e: pop + IL_000f: ret + } // end of method ValueTypes::InitObj1 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + InitObj2() cil managed + { + // Code size 10 (0xa) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0008: ldloc.0 + IL_0009: ret + } // end of method ValueTypes::InitObj2 + + .method public hidebysig static void InitObj3([out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p) cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0007: ret + } // end of method ValueTypes::InitObj3 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + CallValueTypeCtor1() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::.ctor(int32) + IL_0007: ret + } // end of method ValueTypes::CallValueTypeCtor1 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + CallValueTypeCtor2() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::.ctor(int32) + IL_0007: ret + } // end of method ValueTypes::CallValueTypeCtor2 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + Copy1(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S p) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } // end of method ValueTypes::Copy1 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + Copy2(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p) cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0006: ret + } // end of method ValueTypes::Copy2 + + .method public hidebysig static void Copy3(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S p, + [out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& o) cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: stobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0007: ret + } // end of method ValueTypes::Copy3 + + .method public hidebysig static void Copy4(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p, + [out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& o) cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0007: stobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_000c: ret + } // end of method ValueTypes::Copy4 + + .method public hidebysig static void Copy4b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p, + [out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& o) cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::Copy4(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S&, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S&) + IL_0007: ret + } // end of method ValueTypes::Copy4b + + .method public hidebysig static void Issue56(int32 i, + [out] string& str) cil managed + { + // Code size 24 (0x18) + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldstr "qq" + IL_0006: stind.ref + IL_0007: ldarg.1 + IL_0008: ldarg.1 + IL_0009: ldind.ref + IL_000a: ldarga.s i + IL_000c: call instance string [mscorlib]System.Int32::ToString() + IL_0011: call string [mscorlib]System.String::Concat(string, + string) + IL_0016: stind.ref + IL_0017: ret + } // end of method ValueTypes::Issue56 + + .method public hidebysig static void CopyAroundAndModifyField(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S s) cil managed + { + // Code size 19 (0x13) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: ldflda int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_0009: dup + IL_000a: ldind.i4 + IL_000b: ldc.i4.s 10 + IL_000d: add + IL_000e: stind.i4 + IL_000f: ldloc.0 + IL_0010: starg.s s + IL_0012: ret + } // end of method ValueTypes::CopyAroundAndModifyField + + .method private hidebysig static int32[] + MakeArray() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } // end of method ValueTypes::MakeArray + + .method public hidebysig static void IncrementArrayLocation() cil managed + { + // Code size 21 (0x15) + .maxstack 8 + IL_0000: call int32[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MakeArray() + IL_0005: call int32 [mscorlib]System.Environment::get_TickCount() + IL_000a: ldelema [mscorlib]System.Int32 + IL_000f: dup + IL_0010: ldind.i4 + IL_0011: ldc.i4.1 + IL_0012: add + IL_0013: stind.i4 + IL_0014: ret + } // end of method ValueTypes::IncrementArrayLocation + + .method public hidebysig static bool Is(object obj) cil managed + { + // Code size 10 (0xa) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0006: ldnull + IL_0007: cgt.un + IL_0009: ret + } // end of method ValueTypes::Is + + .method public hidebysig static bool IsNullable(object obj) cil managed + { + // Code size 10 (0xa) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst valuetype [mscorlib]System.Nullable`1 + IL_0006: ldnull + IL_0007: cgt.un + IL_0009: ret + } // end of method ValueTypes::IsNullable + + .method public hidebysig static valuetype [mscorlib]System.Nullable`1 + As(object obj) cil managed + { + // Code size 12 (0xc) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst valuetype [mscorlib]System.Nullable`1 + IL_0006: unbox.any valuetype [mscorlib]System.Nullable`1 + IL_000b: ret + } // end of method ValueTypes::As + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + OnlyChangeTheCopy(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S p) cil managed + { + // Code size 11 (0xb) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0009: ldarg.0 + IL_000a: ret + } // end of method ValueTypes::OnlyChangeTheCopy + + .method public hidebysig static void UseRefBoolInCondition(bool& x) cil managed + { + // Code size 15 (0xf) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldind.u1 + IL_0002: brfalse.s IL_000e + + IL_0004: ldstr "true" + IL_0009: call void [mscorlib]System.Console::WriteLine(string) + IL_000e: ret + } // end of method ValueTypes::UseRefBoolInCondition + + .method public hidebysig static void CompareNotEqual0IsReallyNotEqual(class [mscorlib]System.IComparable`1 a) cil managed + { + // Code size 20 (0x14) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldc.i4.0 + IL_0002: callvirt instance int32 class [mscorlib]System.IComparable`1::CompareTo(!0) + IL_0007: brfalse.s IL_0013 + + IL_0009: ldstr "true" + IL_000e: call void [mscorlib]System.Console::WriteLine(string) + IL_0013: ret + } // end of method ValueTypes::CompareNotEqual0IsReallyNotEqual + + .method public hidebysig static void CompareEqual0IsReallyEqual(class [mscorlib]System.IComparable`1 a) cil managed + { + // Code size 20 (0x14) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldc.i4.0 + IL_0002: callvirt instance int32 class [mscorlib]System.IComparable`1::CompareTo(!0) + IL_0007: brtrue.s IL_0013 + + IL_0009: ldstr "true" + IL_000e: call void [mscorlib]System.Console::WriteLine(string) + IL_0013: ret + } // end of method ValueTypes::CompareEqual0IsReallyEqual + + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method ValueTypes::.cctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.roslyn.il new file mode 100644 index 000000000..3d3a399d9 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.roslyn.il @@ -0,0 +1,511 @@ + + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly ValueTypes +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + // --- The following custom attribute is added automatically, do not uncomment ------- + // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 ) + + .permissionset reqmin + = {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module ValueTypes.dll +.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) +.imagebase 0x10000000 +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 // WINDOWS_CUI +.corflags 0x00000001 // ILONLY + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes + extends [mscorlib]System.Object +{ + .class sequential ansi sealed nested public beforefieldinit S + extends [mscorlib]System.ValueType + { + .field public int32 Field + .method public hidebysig specialname rtspecialname + instance void .ctor(int32 'field') cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_0008: ret + } // end of method S::.ctor + + .method public hidebysig instance void + SetField() cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldc.i4.5 + IL_0003: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_0008: ret + } // end of method S::SetField + + .method public hidebysig instance void + MethodCalls() cil managed + { + // Code size 28 (0x1c) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0007: nop + IL_0008: ldarg.0 + IL_0009: ldobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_000e: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S) + IL_0013: nop + IL_0014: ldarg.0 + IL_0015: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S&) + IL_001a: nop + IL_001b: ret + } // end of method S::MethodCalls + + .method private hidebysig static void + Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S byVal) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method S::Test + + .method private hidebysig static void + Test(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& byRef) cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method S::Test + + } // end of class S + + .field private static initonly valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ReadOnlyS + .field private static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S MutableS + .field private static int32 modreq([mscorlib]System.Runtime.CompilerServices.IsVolatile) VolatileInt + .method public hidebysig static void CallMethodViaField() cil managed + { + // Code size 41 (0x29) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_1) + IL_0000: nop + IL_0001: ldsfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::ReadOnlyS + IL_0006: stloc.1 + IL_0007: ldloca.s V_1 + IL_0009: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_000e: nop + IL_000f: ldsflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MutableS + IL_0014: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0019: nop + IL_001a: ldsfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MutableS + IL_001f: stloc.0 + IL_0020: ldloca.s V_0 + IL_0022: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_0027: nop + IL_0028: ret + } // end of method ValueTypes::CallMethodViaField + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + InitObj1() cil managed + { + // Code size 21 (0x15) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_1) + IL_0000: nop + IL_0001: ldloca.s V_0 + IL_0003: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0009: call int32[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MakeArray() + IL_000e: pop + IL_000f: ldloc.0 + IL_0010: stloc.1 + IL_0011: br.s IL_0013 + + IL_0013: ldloc.1 + IL_0014: ret + } // end of method ValueTypes::InitObj1 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + InitObj2() cil managed + { + // Code size 15 (0xf) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_1) + IL_0000: nop + IL_0001: ldloca.s V_0 + IL_0003: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0009: ldloc.0 + IL_000a: stloc.1 + IL_000b: br.s IL_000d + + IL_000d: ldloc.1 + IL_000e: ret + } // end of method ValueTypes::InitObj2 + + .method public hidebysig static void InitObj3([out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p) cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0008: ret + } // end of method ValueTypes::InitObj3 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + CallValueTypeCtor1() cil managed + { + // Code size 13 (0xd) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: nop + IL_0001: ldc.i4.s 10 + IL_0003: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::.ctor(int32) + IL_0008: stloc.0 + IL_0009: br.s IL_000b + + IL_000b: ldloc.0 + IL_000c: ret + } // end of method ValueTypes::CallValueTypeCtor1 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + CallValueTypeCtor2() cil managed + { + // Code size 16 (0x10) + .maxstack 2 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_1) + IL_0000: nop + IL_0001: ldloca.s V_0 + IL_0003: ldc.i4.s 10 + IL_0005: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::.ctor(int32) + IL_000a: ldloc.0 + IL_000b: stloc.1 + IL_000c: br.s IL_000e + + IL_000e: ldloc.1 + IL_000f: ret + } // end of method ValueTypes::CallValueTypeCtor2 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + Copy1(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S p) cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method ValueTypes::Copy1 + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + Copy2(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p) cil managed + { + // Code size 12 (0xc) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0007: stloc.0 + IL_0008: br.s IL_000a + + IL_000a: ldloc.0 + IL_000b: ret + } // end of method ValueTypes::Copy2 + + .method public hidebysig static void Copy3(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S p, + [out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& o) cil managed + { + // Code size 9 (0x9) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldarg.0 + IL_0003: stobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0008: ret + } // end of method ValueTypes::Copy3 + + .method public hidebysig static void Copy4(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p, + [out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& o) cil managed + { + // Code size 14 (0xe) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldarg.0 + IL_0003: ldobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0008: stobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_000d: ret + } // end of method ValueTypes::Copy4 + + .method public hidebysig static void Copy4b(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& p, + [out] valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S& o) cil managed + { + // Code size 10 (0xa) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::Copy4(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S&, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S&) + IL_0008: nop + IL_0009: ret + } // end of method ValueTypes::Copy4b + + .method public hidebysig static void Issue56(int32 i, + [out] string& str) cil managed + { + // Code size 25 (0x19) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.1 + IL_0002: ldstr "qq" + IL_0007: stind.ref + IL_0008: ldarg.1 + IL_0009: ldarg.1 + IL_000a: ldind.ref + IL_000b: ldarga.s i + IL_000d: call instance string [mscorlib]System.Int32::ToString() + IL_0012: call string [mscorlib]System.String::Concat(string, + string) + IL_0017: stind.ref + IL_0018: ret + } // end of method ValueTypes::Issue56 + + .method public hidebysig static void CopyAroundAndModifyField(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S s) cil managed + { + // Code size 20 (0x14) + .maxstack 3 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.0 + IL_0003: ldloca.s V_0 + IL_0005: ldflda int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::Field + IL_000a: dup + IL_000b: ldind.i4 + IL_000c: ldc.i4.s 10 + IL_000e: add + IL_000f: stind.i4 + IL_0010: ldloc.0 + IL_0011: starg.s s + IL_0013: ret + } // end of method ValueTypes::CopyAroundAndModifyField + + .method private hidebysig static int32[] + MakeArray() cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (int32[] V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method ValueTypes::MakeArray + + .method public hidebysig static void IncrementArrayLocation() cil managed + { + // Code size 22 (0x16) + .maxstack 8 + IL_0000: nop + IL_0001: call int32[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MakeArray() + IL_0006: call int32 [mscorlib]System.Environment::get_TickCount() + IL_000b: ldelema [mscorlib]System.Int32 + IL_0010: dup + IL_0011: ldind.i4 + IL_0012: ldc.i4.1 + IL_0013: add + IL_0014: stind.i4 + IL_0015: ret + } // end of method ValueTypes::IncrementArrayLocation + + .method public hidebysig static bool Is(object obj) cil managed + { + // Code size 15 (0xf) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: isinst ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0007: ldnull + IL_0008: cgt.un + IL_000a: stloc.0 + IL_000b: br.s IL_000d + + IL_000d: ldloc.0 + IL_000e: ret + } // end of method ValueTypes::Is + + .method public hidebysig static bool IsNullable(object obj) cil managed + { + // Code size 15 (0xf) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: isinst valuetype [mscorlib]System.Nullable`1 + IL_0007: ldnull + IL_0008: cgt.un + IL_000a: stloc.0 + IL_000b: br.s IL_000d + + IL_000d: ldloc.0 + IL_000e: ret + } // end of method ValueTypes::IsNullable + + .method public hidebysig static valuetype [mscorlib]System.Nullable`1 + As(object obj) cil managed + { + // Code size 17 (0x11) + .maxstack 1 + .locals init (valuetype [mscorlib]System.Nullable`1 V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: isinst valuetype [mscorlib]System.Nullable`1 + IL_0007: unbox.any valuetype [mscorlib]System.Nullable`1 + IL_000c: stloc.0 + IL_000d: br.s IL_000f + + IL_000f: ldloc.0 + IL_0010: ret + } // end of method ValueTypes::As + + .method public hidebysig static valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + OnlyChangeTheCopy(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S p) cil managed + { + // Code size 17 (0x11) + .maxstack 1 + .locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_0, + valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S V_1) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.0 + IL_0003: ldloca.s V_0 + IL_0005: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S::SetField() + IL_000a: nop + IL_000b: ldarg.0 + IL_000c: stloc.1 + IL_000d: br.s IL_000f + + IL_000f: ldloc.1 + IL_0010: ret + } // end of method ValueTypes::OnlyChangeTheCopy + + .method public hidebysig static void UseRefBoolInCondition(bool& x) cil managed + { + // Code size 21 (0x15) + .maxstack 1 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldind.u1 + IL_0003: stloc.0 + IL_0004: ldloc.0 + IL_0005: brfalse.s IL_0014 + + IL_0007: nop + IL_0008: ldstr "true" + IL_000d: call void [mscorlib]System.Console::WriteLine(string) + IL_0012: nop + IL_0013: nop + IL_0014: ret + } // end of method ValueTypes::UseRefBoolInCondition + + .method public hidebysig static void CompareNotEqual0IsReallyNotEqual(class [mscorlib]System.IComparable`1 a) cil managed + { + // Code size 29 (0x1d) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldc.i4.0 + IL_0003: callvirt instance int32 class [mscorlib]System.IComparable`1::CompareTo(!0) + IL_0008: ldc.i4.0 + IL_0009: cgt.un + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: brfalse.s IL_001c + + IL_000f: nop + IL_0010: ldstr "true" + IL_0015: call void [mscorlib]System.Console::WriteLine(string) + IL_001a: nop + IL_001b: nop + IL_001c: ret + } // end of method ValueTypes::CompareNotEqual0IsReallyNotEqual + + .method public hidebysig static void CompareEqual0IsReallyEqual(class [mscorlib]System.IComparable`1 a) cil managed + { + // Code size 29 (0x1d) + .maxstack 2 + .locals init (bool V_0) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldc.i4.0 + IL_0003: callvirt instance int32 class [mscorlib]System.IComparable`1::CompareTo(!0) + IL_0008: ldc.i4.0 + IL_0009: ceq + IL_000b: stloc.0 + IL_000c: ldloc.0 + IL_000d: brfalse.s IL_001c + + IL_000f: nop + IL_0010: ldstr "true" + IL_0015: call void [mscorlib]System.Console::WriteLine(string) + IL_001a: nop + IL_001b: nop + IL_001c: ret + } // end of method ValueTypes::CompareEqual0IsReallyEqual + + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 23 (0x17) + .maxstack 8 + IL_0000: ldsflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::ReadOnlyS + IL_0005: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_000b: ldsflda valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes::MutableS + IL_0010: initobj ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes/S + IL_0016: ret + } // end of method ValueTypes::.cctor + +} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ValueTypes + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/ICSharpCode.Decompiler.Tests/ValueTypes.cs b/ICSharpCode.Decompiler.Tests/ValueTypes.cs deleted file mode 100644 index 1493cff4c..000000000 --- a/ICSharpCode.Decompiler.Tests/ValueTypes.cs +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; - -public static class ValueTypes -{ - public struct S - { - public int Field; - - public S(int field) - { - this.Field = field; - } - - public void SetField() - { - this.Field = 5; - } - - public void MethodCalls() - { - this.SetField(); - ValueTypes.S.Test(this); - ValueTypes.S.Test(ref this); - } - - private static void Test(ValueTypes.S byVal) - { - } - - private static void Test(ref ValueTypes.S byRef) - { - } - } - - private static readonly ValueTypes.S ReadOnlyS = default(ValueTypes.S); - private static ValueTypes.S MutableS = default(ValueTypes.S); - private static volatile int VolatileInt; - - public static void CallMethodViaField() - { - ValueTypes.ReadOnlyS.SetField(); - ValueTypes.MutableS.SetField(); - ValueTypes.S mutableS = ValueTypes.MutableS; - mutableS.SetField(); - } - - public static ValueTypes.S InitObj1() - { - ValueTypes.S result = default(ValueTypes.S); - ValueTypes.MakeArray(); - return result; - } - - public static ValueTypes.S InitObj2() - { - return default(ValueTypes.S); - } - - public static void InitObj3(out ValueTypes.S p) - { - p = default(ValueTypes.S); - } - - public static ValueTypes.S CallValueTypeCtor1() - { - return new ValueTypes.S(10); - } - - public static ValueTypes.S CallValueTypeCtor2() - { - ValueTypes.S result = new ValueTypes.S(10); - return result; - } - - public static ValueTypes.S Copy1(ValueTypes.S p) - { - return p; - } - - public static ValueTypes.S Copy2(ref ValueTypes.S p) - { - return p; - } - - public static void Copy3(ValueTypes.S p, out ValueTypes.S o) - { - o = p; - } - - public static void Copy4(ref ValueTypes.S p, out ValueTypes.S o) - { - o = p; - } - - public static void Copy4b(ref ValueTypes.S p, out ValueTypes.S o) - { - // test passing through by-ref arguments - ValueTypes.Copy4(ref p, out o); - } - - public static void Issue56(int i, out string str) - { - str = "qq"; - str += i.ToString(); - } - - public static void CopyAroundAndModifyField(ValueTypes.S s) - { - ValueTypes.S s2 = s; - s2.Field += 10; - s = s2; - } - - private static int[] MakeArray() - { - return null; - } - - public static void IncrementArrayLocation() - { - ValueTypes.MakeArray()[Environment.TickCount]++; - } - - public static bool Is(object obj) - { - return obj is ValueTypes.S; - } - - public static bool IsNullable(object obj) - { - return obj is ValueTypes.S?; - } - - public static ValueTypes.S? As(object obj) - { - return obj as ValueTypes.S?; - } - - public static ValueTypes.S OnlyChangeTheCopy(ValueTypes.S p) - { - ValueTypes.S s = p; - s.SetField(); - return p; - } - - public static void UseRefBoolInCondition(ref bool x) - { - if (x) - { - Console.WriteLine("true"); - } - } - - public static void CompareNotEqual0IsReallyNotEqual(IComparable a) - { - if (a.CompareTo(0) != 0) - { - Console.WriteLine("true"); - } - } - - public static void CompareEqual0IsReallyEqual(IComparable a) - { - if (a.CompareTo(0) == 0) - { - Console.WriteLine("true"); - } - } - -}