diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
index 96f858763..f1e073bac 100644
--- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
+++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
@@ -92,6 +92,7 @@
+
diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
index bbe37a2bf..4f46905ea 100644
--- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
+++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
@@ -139,6 +139,12 @@ namespace ICSharpCode.Decompiler.Tests
Run(cscOptions: cscOptions);
}
+ [Test]
+ public void TypeAnalysisTests([ValueSource("defaultOptions")] CompilerOptions cscOptions)
+ {
+ Run(cscOptions: cscOptions);
+ }
+
void Run([CallerMemberName] string testName = null, AssemblerOptions asmOptions = AssemblerOptions.None, CompilerOptions cscOptions = CompilerOptions.None)
{
var ilFile = Path.Combine(TestCasePath, testName);
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.cs
new file mode 100644
index 000000000..fc5341541
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.cs
@@ -0,0 +1,165 @@
+// 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 class TypeAnalysisTests
+ {
+ public byte SubtractFrom256(byte b)
+ {
+ return (byte)(256 - b);
+ }
+
+ #region Shift
+ public int LShiftInteger(int num1, int num2)
+ {
+ return num1 << num2;
+ }
+
+ public uint LShiftUnsignedInteger(uint num1, uint num2)
+ {
+ return num1 << (int)num2;
+ }
+
+ public long LShiftLong(long num1, long num2)
+ {
+ return num1 << (int)num2;
+ }
+
+ public ulong LShiftUnsignedLong(ulong num1, ulong num2)
+ {
+ return num1 << (int)num2;
+ }
+
+ public int RShiftInteger(int num1, int num2)
+ {
+ return num1 >> num2;
+ }
+
+ public uint RShiftUnsignedInteger(uint num1, int num2)
+ {
+ return num1 >> num2;
+ }
+
+ public long RShiftLong(long num1, long num2)
+ {
+ return num1 >> (int)num2;
+ }
+
+ public ulong RShiftUnsignedLong(ulong num1, ulong num2)
+ {
+ return num1 >> (int)num2;
+ }
+
+ public int ShiftByte(byte num)
+ {
+ return num << 8;
+ }
+
+ public int RShiftByte(byte num)
+ {
+ return num >> 8;
+ }
+
+ public uint RShiftByteWithZeroExtension(byte num)
+ {
+ return (uint)num >> 8;
+ }
+
+ public int RShiftByteAsSByte(byte num)
+ {
+ return (sbyte)num >> 8;
+ }
+
+ public int RShiftSByte(sbyte num)
+ {
+ return num >> 8;
+ }
+
+ public uint RShiftSByteWithZeroExtension(sbyte num)
+ {
+ return (uint)num >> 8;
+ }
+
+ public int RShiftSByteAsByte(sbyte num)
+ {
+ return (byte)num >> 8;
+ }
+ #endregion
+
+ public int GetHashCode(long num)
+ {
+ return (int)num ^ (int)(num >> 32);
+ }
+
+ public void TernaryOp(Random a, Random b, bool c)
+ {
+ if ((c ? a : b) == null) {
+ Console.WriteLine();
+ }
+ }
+
+ public void OperatorIs(object o)
+ {
+ Console.WriteLine(o is Random);
+ Console.WriteLine(!(o is Random));
+ }
+
+ public byte[] CreateArrayWithInt(int length)
+ {
+ return new byte[length];
+ }
+
+ public byte[] CreateArrayWithLong(long length)
+ {
+ return new byte[length];
+ }
+
+ public byte[] CreateArrayWithUInt(uint length)
+ {
+ return new byte[length];
+ }
+
+ public byte[] CreateArrayWithULong(ulong length)
+ {
+ return new byte[length];
+ }
+
+ public byte[] CreateArrayWithShort(short length)
+ {
+ return new byte[length];
+ }
+
+ public byte[] CreateArrayWithUShort(ushort length)
+ {
+ return new byte[length];
+ }
+
+ public StringComparison EnumDiffNumber(StringComparison data)
+ {
+ return data - 1;
+ }
+
+ public int EnumDiff(StringComparison a, StringComparison b)
+ {
+ return Math.Abs(a - b);
+ }
+ }
+}
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.il
new file mode 100644
index 000000000..d960141bc
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.il
@@ -0,0 +1,569 @@
+
+// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.18020
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+
+
+// Metadata version: v4.0.30319
+.assembly extern mscorlib
+{
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+ .ver 4:0:0:0
+}
+.assembly atizfkop
+{
+ .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 atizfkop.dll
+// MVID: {6E63D5B6-44D4-4BB0-A1F2-26CF3701BD7D}
+.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
+.imagebase 0x10000000
+.file alignment 0x00000200
+.stackreserve 0x00100000
+.subsystem 0x0003 // WINDOWS_CUI
+.corflags 0x00000001 // ILONLY
+// Image base: 0x02B60000
+
+
+// =============== CLASS MEMBERS DECLARATION ===================
+
+.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.TypeAnalysisTests
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig instance uint8
+ SubtractFrom256(uint8 b) cil managed
+ {
+ // Code size 14 (0xe)
+ .maxstack 2
+ .locals init (uint8 V_0)
+ IL_0000: nop
+ IL_0001: ldc.i4 0x100
+ IL_0006: ldarg.1
+ IL_0007: sub
+ IL_0008: conv.u1
+ IL_0009: stloc.0
+ IL_000a: br.s IL_000c
+
+ IL_000c: ldloc.0
+ IL_000d: ret
+ } // end of method TypeAnalysisTests::SubtractFrom256
+
+ .method public hidebysig instance int32
+ LShiftInteger(int32 num1,
+ int32 num2) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 3
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: ldc.i4.s 31
+ IL_0005: and
+ IL_0006: shl
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::LShiftInteger
+
+ .method public hidebysig instance uint32
+ LShiftUnsignedInteger(uint32 num1,
+ uint32 num2) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 3
+ .locals init (uint32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: ldc.i4.s 31
+ IL_0005: and
+ IL_0006: shl
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::LShiftUnsignedInteger
+
+ .method public hidebysig instance int64
+ LShiftLong(int64 num1,
+ int64 num2) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 3
+ .locals init (int64 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: conv.i4
+ IL_0004: ldc.i4.s 63
+ IL_0006: and
+ IL_0007: shl
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::LShiftLong
+
+ .method public hidebysig instance uint64
+ LShiftUnsignedLong(uint64 num1,
+ uint64 num2) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 3
+ .locals init (uint64 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: conv.i4
+ IL_0004: ldc.i4.s 63
+ IL_0006: and
+ IL_0007: shl
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::LShiftUnsignedLong
+
+ .method public hidebysig instance int32
+ RShiftInteger(int32 num1,
+ int32 num2) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 3
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: ldc.i4.s 31
+ IL_0005: and
+ IL_0006: shr
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::RShiftInteger
+
+ .method public hidebysig instance uint32
+ RShiftUnsignedInteger(uint32 num1,
+ int32 num2) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 3
+ .locals init (uint32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: ldc.i4.s 31
+ IL_0005: and
+ IL_0006: shr.un
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::RShiftUnsignedInteger
+
+ .method public hidebysig instance int64
+ RShiftLong(int64 num1,
+ int64 num2) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 3
+ .locals init (int64 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: conv.i4
+ IL_0004: ldc.i4.s 63
+ IL_0006: and
+ IL_0007: shr
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::RShiftLong
+
+ .method public hidebysig instance uint64
+ RShiftUnsignedLong(uint64 num1,
+ uint64 num2) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 3
+ .locals init (uint64 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: conv.i4
+ IL_0004: ldc.i4.s 63
+ IL_0006: and
+ IL_0007: shr.un
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::RShiftUnsignedLong
+
+ .method public hidebysig instance int32
+ ShiftByte(uint8 num) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 2
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldc.i4.8
+ IL_0003: shl
+ IL_0004: stloc.0
+ IL_0005: br.s IL_0007
+
+ IL_0007: ldloc.0
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::ShiftByte
+
+ .method public hidebysig instance int32
+ RShiftByte(uint8 num) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 2
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldc.i4.8
+ IL_0003: shr
+ IL_0004: stloc.0
+ IL_0005: br.s IL_0007
+
+ IL_0007: ldloc.0
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::RShiftByte
+
+ .method public hidebysig instance uint32
+ RShiftByteWithZeroExtension(uint8 num) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 2
+ .locals init (uint32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldc.i4.8
+ IL_0003: shr.un
+ IL_0004: stloc.0
+ IL_0005: br.s IL_0007
+
+ IL_0007: ldloc.0
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::RShiftByteWithZeroExtension
+
+ .method public hidebysig instance int32
+ RShiftByteAsSByte(uint8 num) cil managed
+ {
+ // Code size 10 (0xa)
+ .maxstack 2
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: conv.i1
+ IL_0003: ldc.i4.8
+ IL_0004: shr
+ IL_0005: stloc.0
+ IL_0006: br.s IL_0008
+
+ IL_0008: ldloc.0
+ IL_0009: ret
+ } // end of method TypeAnalysisTests::RShiftByteAsSByte
+
+ .method public hidebysig instance int32
+ RShiftSByte(int8 num) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 2
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldc.i4.8
+ IL_0003: shr
+ IL_0004: stloc.0
+ IL_0005: br.s IL_0007
+
+ IL_0007: ldloc.0
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::RShiftSByte
+
+ .method public hidebysig instance uint32
+ RShiftSByteWithZeroExtension(int8 num) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 2
+ .locals init (uint32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldc.i4.8
+ IL_0003: shr.un
+ IL_0004: stloc.0
+ IL_0005: br.s IL_0007
+
+ IL_0007: ldloc.0
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::RShiftSByteWithZeroExtension
+
+ .method public hidebysig instance int32
+ RShiftSByteAsByte(int8 num) cil managed
+ {
+ // Code size 10 (0xa)
+ .maxstack 2
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: conv.u1
+ IL_0003: ldc.i4.8
+ IL_0004: shr
+ IL_0005: stloc.0
+ IL_0006: br.s IL_0008
+
+ IL_0008: ldloc.0
+ IL_0009: ret
+ } // end of method TypeAnalysisTests::RShiftSByteAsByte
+
+ .method public hidebysig instance int32
+ GetHashCode(int64 num) cil managed
+ {
+ // Code size 14 (0xe)
+ .maxstack 3
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: conv.i4
+ IL_0003: ldarg.1
+ IL_0004: ldc.i4.s 32
+ IL_0006: shr
+ IL_0007: conv.i4
+ IL_0008: xor
+ IL_0009: stloc.0
+ IL_000a: br.s IL_000c
+
+ IL_000c: ldloc.0
+ IL_000d: ret
+ } // end of method TypeAnalysisTests::GetHashCode
+
+ .method public hidebysig instance void
+ TernaryOp(class [mscorlib]System.Random a,
+ class [mscorlib]System.Random b,
+ bool c) cil managed
+ {
+ // Code size 28 (0x1c)
+ .maxstack 2
+ .locals init (bool V_0)
+ IL_0000: nop
+ IL_0001: ldarg.3
+ IL_0002: brtrue.s IL_0007
+
+ IL_0004: ldarg.2
+ IL_0005: br.s IL_0008
+
+ IL_0007: ldarg.1
+ IL_0008: nop
+ IL_0009: ldnull
+ IL_000a: ceq
+ IL_000c: ldc.i4.0
+ IL_000d: ceq
+ IL_000f: stloc.0
+ IL_0010: ldloc.0
+ IL_0011: brtrue.s IL_001b
+
+ IL_0013: nop
+ IL_0014: call void [mscorlib]System.Console::WriteLine()
+ IL_0019: nop
+ IL_001a: nop
+ IL_001b: ret
+ } // end of method TypeAnalysisTests::TernaryOp
+
+ .method public hidebysig instance void
+ OperatorIs(object o) cil managed
+ {
+ // Code size 35 (0x23)
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: isinst [mscorlib]System.Random
+ IL_0007: ldnull
+ IL_0008: cgt.un
+ IL_000a: call void [mscorlib]System.Console::WriteLine(bool)
+ IL_000f: nop
+ IL_0010: ldarg.1
+ IL_0011: isinst [mscorlib]System.Random
+ IL_0016: ldnull
+ IL_0017: cgt.un
+ IL_0019: ldc.i4.0
+ IL_001a: ceq
+ IL_001c: call void [mscorlib]System.Console::WriteLine(bool)
+ IL_0021: nop
+ IL_0022: ret
+ } // end of method TypeAnalysisTests::OperatorIs
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithInt(int32 length) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 1
+ .locals init (uint8[] V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: newarr [mscorlib]System.Byte
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithInt
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithLong(int64 length) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 1
+ .locals init (uint8[] V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: conv.ovf.i
+ IL_0003: newarr [mscorlib]System.Byte
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithLong
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithUInt(uint32 length) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 1
+ .locals init (uint8[] V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: conv.u
+ IL_0003: newarr [mscorlib]System.Byte
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithUInt
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithULong(uint64 length) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 1
+ .locals init (uint8[] V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: conv.ovf.i.un
+ IL_0003: newarr [mscorlib]System.Byte
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithULong
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithShort(int16 length) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 1
+ .locals init (uint8[] V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: newarr [mscorlib]System.Byte
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithShort
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithUShort(uint16 length) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 1
+ .locals init (uint8[] V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: newarr [mscorlib]System.Byte
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithUShort
+
+ .method public hidebysig instance valuetype [mscorlib]System.StringComparison
+ EnumDiffNumber(valuetype [mscorlib]System.StringComparison data) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 2
+ .locals init (valuetype [mscorlib]System.StringComparison V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldc.i4.1
+ IL_0003: sub
+ IL_0004: stloc.0
+ IL_0005: br.s IL_0007
+
+ IL_0007: ldloc.0
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::EnumDiffNumber
+
+ .method public hidebysig instance int32
+ EnumDiff(valuetype [mscorlib]System.StringComparison a,
+ valuetype [mscorlib]System.StringComparison b) cil managed
+ {
+ // Code size 14 (0xe)
+ .maxstack 2
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: sub
+ IL_0004: call int32 [mscorlib]System.Math::Abs(int32)
+ IL_0009: stloc.0
+ IL_000a: br.s IL_000c
+
+ IL_000c: ldloc.0
+ IL_000d: ret
+ } // end of method TypeAnalysisTests::EnumDiff
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::.ctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.TypeAnalysisTests
+
+
+// =============================================================
+
+// *********** DISASSEMBLY COMPLETE ***********************
+// WARNING: Created Win32 resource file ../../../TestCases/Pretty\TypeAnalysisTests.res
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.il
new file mode 100644
index 000000000..22a1a101f
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.il
@@ -0,0 +1,404 @@
+
+// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.18020
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+
+
+// Metadata version: v4.0.30319
+.assembly extern mscorlib
+{
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+ .ver 4:0:0:0
+}
+.assembly '23m0rxdj'
+{
+ .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 '23m0rxdj.dll'
+// MVID: {9DFA58C5-09E0-491E-AD57-5C642A58E0B0}
+.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
+.imagebase 0x10000000
+.file alignment 0x00000200
+.stackreserve 0x00100000
+.subsystem 0x0003 // WINDOWS_CUI
+.corflags 0x00000001 // ILONLY
+// Image base: 0x01190000
+
+
+// =============== CLASS MEMBERS DECLARATION ===================
+
+.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.TypeAnalysisTests
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig instance uint8
+ SubtractFrom256(uint8 b) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 8
+ IL_0000: ldc.i4 0x100
+ IL_0005: ldarg.1
+ IL_0006: sub
+ IL_0007: conv.u1
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::SubtractFrom256
+
+ .method public hidebysig instance int32
+ LShiftInteger(int32 num1,
+ int32 num2) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: ldc.i4.s 31
+ IL_0004: and
+ IL_0005: shl
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::LShiftInteger
+
+ .method public hidebysig instance uint32
+ LShiftUnsignedInteger(uint32 num1,
+ uint32 num2) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: ldc.i4.s 31
+ IL_0004: and
+ IL_0005: shl
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::LShiftUnsignedInteger
+
+ .method public hidebysig instance int64
+ LShiftLong(int64 num1,
+ int64 num2) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: conv.i4
+ IL_0003: ldc.i4.s 63
+ IL_0005: and
+ IL_0006: shl
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::LShiftLong
+
+ .method public hidebysig instance uint64
+ LShiftUnsignedLong(uint64 num1,
+ uint64 num2) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: conv.i4
+ IL_0003: ldc.i4.s 63
+ IL_0005: and
+ IL_0006: shl
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::LShiftUnsignedLong
+
+ .method public hidebysig instance int32
+ RShiftInteger(int32 num1,
+ int32 num2) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: ldc.i4.s 31
+ IL_0004: and
+ IL_0005: shr
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::RShiftInteger
+
+ .method public hidebysig instance uint32
+ RShiftUnsignedInteger(uint32 num1,
+ int32 num2) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: ldc.i4.s 31
+ IL_0004: and
+ IL_0005: shr.un
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::RShiftUnsignedInteger
+
+ .method public hidebysig instance int64
+ RShiftLong(int64 num1,
+ int64 num2) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: conv.i4
+ IL_0003: ldc.i4.s 63
+ IL_0005: and
+ IL_0006: shr
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::RShiftLong
+
+ .method public hidebysig instance uint64
+ RShiftUnsignedLong(uint64 num1,
+ uint64 num2) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: conv.i4
+ IL_0003: ldc.i4.s 63
+ IL_0005: and
+ IL_0006: shr.un
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::RShiftUnsignedLong
+
+ .method public hidebysig instance int32
+ ShiftByte(uint8 num) cil managed
+ {
+ // Code size 4 (0x4)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.8
+ IL_0002: shl
+ IL_0003: ret
+ } // end of method TypeAnalysisTests::ShiftByte
+
+ .method public hidebysig instance int32
+ RShiftByte(uint8 num) cil managed
+ {
+ // Code size 4 (0x4)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.8
+ IL_0002: shr
+ IL_0003: ret
+ } // end of method TypeAnalysisTests::RShiftByte
+
+ .method public hidebysig instance uint32
+ RShiftByteWithZeroExtension(uint8 num) cil managed
+ {
+ // Code size 4 (0x4)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.8
+ IL_0002: shr.un
+ IL_0003: ret
+ } // end of method TypeAnalysisTests::RShiftByteWithZeroExtension
+
+ .method public hidebysig instance int32
+ RShiftByteAsSByte(uint8 num) cil managed
+ {
+ // Code size 5 (0x5)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: conv.i1
+ IL_0002: ldc.i4.8
+ IL_0003: shr
+ IL_0004: ret
+ } // end of method TypeAnalysisTests::RShiftByteAsSByte
+
+ .method public hidebysig instance int32
+ RShiftSByte(int8 num) cil managed
+ {
+ // Code size 4 (0x4)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.8
+ IL_0002: shr
+ IL_0003: ret
+ } // end of method TypeAnalysisTests::RShiftSByte
+
+ .method public hidebysig instance uint32
+ RShiftSByteWithZeroExtension(int8 num) cil managed
+ {
+ // Code size 4 (0x4)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.8
+ IL_0002: shr.un
+ IL_0003: ret
+ } // end of method TypeAnalysisTests::RShiftSByteWithZeroExtension
+
+ .method public hidebysig instance int32
+ RShiftSByteAsByte(int8 num) cil managed
+ {
+ // Code size 5 (0x5)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: conv.u1
+ IL_0002: ldc.i4.8
+ IL_0003: shr
+ IL_0004: ret
+ } // end of method TypeAnalysisTests::RShiftSByteAsByte
+
+ .method public hidebysig instance int32
+ GetHashCode(int64 num) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: conv.i4
+ IL_0002: ldarg.1
+ IL_0003: ldc.i4.s 32
+ IL_0005: shr
+ IL_0006: conv.i4
+ IL_0007: xor
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::GetHashCode
+
+ .method public hidebysig instance void
+ TernaryOp(class [mscorlib]System.Random a,
+ class [mscorlib]System.Random b,
+ bool c) cil managed
+ {
+ // Code size 15 (0xf)
+ .maxstack 8
+ IL_0000: ldarg.3
+ IL_0001: brtrue.s IL_0006
+
+ IL_0003: ldarg.2
+ IL_0004: br.s IL_0007
+
+ IL_0006: ldarg.1
+ IL_0007: brtrue.s IL_000e
+
+ IL_0009: call void [mscorlib]System.Console::WriteLine()
+ IL_000e: ret
+ } // end of method TypeAnalysisTests::TernaryOp
+
+ .method public hidebysig instance void
+ OperatorIs(object o) cil managed
+ {
+ // Code size 32 (0x20)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: isinst [mscorlib]System.Random
+ IL_0006: ldnull
+ IL_0007: cgt.un
+ IL_0009: call void [mscorlib]System.Console::WriteLine(bool)
+ IL_000e: ldarg.1
+ IL_000f: isinst [mscorlib]System.Random
+ IL_0014: ldnull
+ IL_0015: cgt.un
+ IL_0017: ldc.i4.0
+ IL_0018: ceq
+ IL_001a: call void [mscorlib]System.Console::WriteLine(bool)
+ IL_001f: ret
+ } // end of method TypeAnalysisTests::OperatorIs
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithInt(int32 length) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: newarr [mscorlib]System.Byte
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithInt
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithLong(int64 length) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: conv.ovf.i
+ IL_0002: newarr [mscorlib]System.Byte
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithLong
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithUInt(uint32 length) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: conv.u
+ IL_0002: newarr [mscorlib]System.Byte
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithUInt
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithULong(uint64 length) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: conv.ovf.i.un
+ IL_0002: newarr [mscorlib]System.Byte
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithULong
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithShort(int16 length) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: newarr [mscorlib]System.Byte
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithShort
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithUShort(uint16 length) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: newarr [mscorlib]System.Byte
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithUShort
+
+ .method public hidebysig instance valuetype [mscorlib]System.StringComparison
+ EnumDiffNumber(valuetype [mscorlib]System.StringComparison data) cil managed
+ {
+ // Code size 4 (0x4)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.1
+ IL_0002: sub
+ IL_0003: ret
+ } // end of method TypeAnalysisTests::EnumDiffNumber
+
+ .method public hidebysig instance int32
+ EnumDiff(valuetype [mscorlib]System.StringComparison a,
+ valuetype [mscorlib]System.StringComparison b) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: sub
+ IL_0003: call int32 [mscorlib]System.Math::Abs(int32)
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::EnumDiff
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::.ctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.TypeAnalysisTests
+
+
+// =============================================================
+
+// *********** DISASSEMBLY COMPLETE ***********************
+// WARNING: Created Win32 resource file ../../../TestCases/Pretty\TypeAnalysisTests.opt.res
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.roslyn.il
new file mode 100644
index 000000000..00255f8e8
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.opt.roslyn.il
@@ -0,0 +1,406 @@
+
+// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.18020
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+
+
+// Metadata version: v4.0.30319
+.assembly extern mscorlib
+{
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+ .ver 4:0:0:0
+}
+.assembly TypeAnalysisTests
+{
+ .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 TypeAnalysisTests.dll
+// MVID: {BAEDEF38-6FE3-4BCD-B0E6-F860EA0EEDDB}
+.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
+.imagebase 0x10000000
+.file alignment 0x00000200
+.stackreserve 0x00100000
+.subsystem 0x0003 // WINDOWS_CUI
+.corflags 0x00000001 // ILONLY
+// Image base: 0x01840000
+
+
+// =============== CLASS MEMBERS DECLARATION ===================
+
+.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.TypeAnalysisTests
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig instance uint8
+ SubtractFrom256(uint8 b) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 8
+ IL_0000: ldc.i4 0x100
+ IL_0005: ldarg.1
+ IL_0006: sub
+ IL_0007: conv.u1
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::SubtractFrom256
+
+ .method public hidebysig instance int32
+ LShiftInteger(int32 num1,
+ int32 num2) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: ldc.i4.s 31
+ IL_0004: and
+ IL_0005: shl
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::LShiftInteger
+
+ .method public hidebysig instance uint32
+ LShiftUnsignedInteger(uint32 num1,
+ uint32 num2) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: ldc.i4.s 31
+ IL_0004: and
+ IL_0005: shl
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::LShiftUnsignedInteger
+
+ .method public hidebysig instance int64
+ LShiftLong(int64 num1,
+ int64 num2) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: conv.i4
+ IL_0003: ldc.i4.s 63
+ IL_0005: and
+ IL_0006: shl
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::LShiftLong
+
+ .method public hidebysig instance uint64
+ LShiftUnsignedLong(uint64 num1,
+ uint64 num2) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: conv.i4
+ IL_0003: ldc.i4.s 63
+ IL_0005: and
+ IL_0006: shl
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::LShiftUnsignedLong
+
+ .method public hidebysig instance int32
+ RShiftInteger(int32 num1,
+ int32 num2) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: ldc.i4.s 31
+ IL_0004: and
+ IL_0005: shr
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::RShiftInteger
+
+ .method public hidebysig instance uint32
+ RShiftUnsignedInteger(uint32 num1,
+ int32 num2) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: ldc.i4.s 31
+ IL_0004: and
+ IL_0005: shr.un
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::RShiftUnsignedInteger
+
+ .method public hidebysig instance int64
+ RShiftLong(int64 num1,
+ int64 num2) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: conv.i4
+ IL_0003: ldc.i4.s 63
+ IL_0005: and
+ IL_0006: shr
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::RShiftLong
+
+ .method public hidebysig instance uint64
+ RShiftUnsignedLong(uint64 num1,
+ uint64 num2) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: conv.i4
+ IL_0003: ldc.i4.s 63
+ IL_0005: and
+ IL_0006: shr.un
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::RShiftUnsignedLong
+
+ .method public hidebysig instance int32
+ ShiftByte(uint8 num) cil managed
+ {
+ // Code size 4 (0x4)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.8
+ IL_0002: shl
+ IL_0003: ret
+ } // end of method TypeAnalysisTests::ShiftByte
+
+ .method public hidebysig instance int32
+ RShiftByte(uint8 num) cil managed
+ {
+ // Code size 4 (0x4)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.8
+ IL_0002: shr
+ IL_0003: ret
+ } // end of method TypeAnalysisTests::RShiftByte
+
+ .method public hidebysig instance uint32
+ RShiftByteWithZeroExtension(uint8 num) cil managed
+ {
+ // Code size 4 (0x4)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.8
+ IL_0002: shr.un
+ IL_0003: ret
+ } // end of method TypeAnalysisTests::RShiftByteWithZeroExtension
+
+ .method public hidebysig instance int32
+ RShiftByteAsSByte(uint8 num) cil managed
+ {
+ // Code size 5 (0x5)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: conv.i1
+ IL_0002: ldc.i4.8
+ IL_0003: shr
+ IL_0004: ret
+ } // end of method TypeAnalysisTests::RShiftByteAsSByte
+
+ .method public hidebysig instance int32
+ RShiftSByte(int8 num) cil managed
+ {
+ // Code size 4 (0x4)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.8
+ IL_0002: shr
+ IL_0003: ret
+ } // end of method TypeAnalysisTests::RShiftSByte
+
+ .method public hidebysig instance uint32
+ RShiftSByteWithZeroExtension(int8 num) cil managed
+ {
+ // Code size 4 (0x4)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.8
+ IL_0002: shr.un
+ IL_0003: ret
+ } // end of method TypeAnalysisTests::RShiftSByteWithZeroExtension
+
+ .method public hidebysig instance int32
+ RShiftSByteAsByte(int8 num) cil managed
+ {
+ // Code size 5 (0x5)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: conv.u1
+ IL_0002: ldc.i4.8
+ IL_0003: shr
+ IL_0004: ret
+ } // end of method TypeAnalysisTests::RShiftSByteAsByte
+
+ .method public hidebysig instance int32
+ GetHashCode(int64 num) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: conv.i4
+ IL_0002: ldarg.1
+ IL_0003: ldc.i4.s 32
+ IL_0005: shr
+ IL_0006: conv.i4
+ IL_0007: xor
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::GetHashCode
+
+ .method public hidebysig instance void
+ TernaryOp(class [mscorlib]System.Random a,
+ class [mscorlib]System.Random b,
+ bool c) cil managed
+ {
+ // Code size 15 (0xf)
+ .maxstack 8
+ IL_0000: ldarg.3
+ IL_0001: brtrue.s IL_0006
+
+ IL_0003: ldarg.2
+ IL_0004: br.s IL_0007
+
+ IL_0006: ldarg.1
+ IL_0007: brtrue.s IL_000e
+
+ IL_0009: call void [mscorlib]System.Console::WriteLine()
+ IL_000e: ret
+ } // end of method TypeAnalysisTests::TernaryOp
+
+ .method public hidebysig instance void
+ OperatorIs(object o) cil managed
+ {
+ // Code size 32 (0x20)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: isinst [mscorlib]System.Random
+ IL_0006: ldnull
+ IL_0007: cgt.un
+ IL_0009: call void [mscorlib]System.Console::WriteLine(bool)
+ IL_000e: ldarg.1
+ IL_000f: isinst [mscorlib]System.Random
+ IL_0014: ldnull
+ IL_0015: cgt.un
+ IL_0017: ldc.i4.0
+ IL_0018: ceq
+ IL_001a: call void [mscorlib]System.Console::WriteLine(bool)
+ IL_001f: ret
+ } // end of method TypeAnalysisTests::OperatorIs
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithInt(int32 length) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: newarr [mscorlib]System.Byte
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithInt
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithLong(int64 length) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: conv.ovf.i
+ IL_0002: newarr [mscorlib]System.Byte
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithLong
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithUInt(uint32 length) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: newarr [mscorlib]System.Byte
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithUInt
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithULong(uint64 length) cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: conv.ovf.i.un
+ IL_0002: newarr [mscorlib]System.Byte
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithULong
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithShort(int16 length) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: newarr [mscorlib]System.Byte
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithShort
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithUShort(uint16 length) cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: newarr [mscorlib]System.Byte
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithUShort
+
+ .method public hidebysig instance valuetype [mscorlib]System.StringComparison
+ EnumDiffNumber(valuetype [mscorlib]System.StringComparison data) cil managed
+ {
+ // Code size 4 (0x4)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.1
+ IL_0002: sub
+ IL_0003: ret
+ } // end of method TypeAnalysisTests::EnumDiffNumber
+
+ .method public hidebysig instance int32
+ EnumDiff(valuetype [mscorlib]System.StringComparison a,
+ valuetype [mscorlib]System.StringComparison b) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldarg.2
+ IL_0002: sub
+ IL_0003: call int32 [mscorlib]System.Math::Abs(int32)
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::EnumDiff
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ } // end of method TypeAnalysisTests::.ctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.TypeAnalysisTests
+
+
+// =============================================================
+
+// *********** DISASSEMBLY COMPLETE ***********************
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.roslyn.il
new file mode 100644
index 000000000..8e4fb7b64
--- /dev/null
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.roslyn.il
@@ -0,0 +1,569 @@
+
+// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.18020
+// Copyright (c) Microsoft Corporation. All rights reserved.
+
+
+
+// Metadata version: v4.0.30319
+.assembly extern mscorlib
+{
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+ .ver 4:0:0:0
+}
+.assembly TypeAnalysisTests
+{
+ .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 TypeAnalysisTests.dll
+// MVID: {FB8CCB77-958F-4BAB-8E8E-E95AD68FFF21}
+.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
+.imagebase 0x10000000
+.file alignment 0x00000200
+.stackreserve 0x00100000
+.subsystem 0x0003 // WINDOWS_CUI
+.corflags 0x00000001 // ILONLY
+// Image base: 0x024D0000
+
+
+// =============== CLASS MEMBERS DECLARATION ===================
+
+.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.TypeAnalysisTests
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig instance uint8
+ SubtractFrom256(uint8 b) cil managed
+ {
+ // Code size 14 (0xe)
+ .maxstack 2
+ .locals init (uint8 V_0)
+ IL_0000: nop
+ IL_0001: ldc.i4 0x100
+ IL_0006: ldarg.1
+ IL_0007: sub
+ IL_0008: conv.u1
+ IL_0009: stloc.0
+ IL_000a: br.s IL_000c
+
+ IL_000c: ldloc.0
+ IL_000d: ret
+ } // end of method TypeAnalysisTests::SubtractFrom256
+
+ .method public hidebysig instance int32
+ LShiftInteger(int32 num1,
+ int32 num2) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 3
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: ldc.i4.s 31
+ IL_0005: and
+ IL_0006: shl
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::LShiftInteger
+
+ .method public hidebysig instance uint32
+ LShiftUnsignedInteger(uint32 num1,
+ uint32 num2) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 3
+ .locals init (uint32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: ldc.i4.s 31
+ IL_0005: and
+ IL_0006: shl
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::LShiftUnsignedInteger
+
+ .method public hidebysig instance int64
+ LShiftLong(int64 num1,
+ int64 num2) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 3
+ .locals init (int64 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: conv.i4
+ IL_0004: ldc.i4.s 63
+ IL_0006: and
+ IL_0007: shl
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::LShiftLong
+
+ .method public hidebysig instance uint64
+ LShiftUnsignedLong(uint64 num1,
+ uint64 num2) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 3
+ .locals init (uint64 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: conv.i4
+ IL_0004: ldc.i4.s 63
+ IL_0006: and
+ IL_0007: shl
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::LShiftUnsignedLong
+
+ .method public hidebysig instance int32
+ RShiftInteger(int32 num1,
+ int32 num2) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 3
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: ldc.i4.s 31
+ IL_0005: and
+ IL_0006: shr
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::RShiftInteger
+
+ .method public hidebysig instance uint32
+ RShiftUnsignedInteger(uint32 num1,
+ int32 num2) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 3
+ .locals init (uint32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: ldc.i4.s 31
+ IL_0005: and
+ IL_0006: shr.un
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::RShiftUnsignedInteger
+
+ .method public hidebysig instance int64
+ RShiftLong(int64 num1,
+ int64 num2) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 3
+ .locals init (int64 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: conv.i4
+ IL_0004: ldc.i4.s 63
+ IL_0006: and
+ IL_0007: shr
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::RShiftLong
+
+ .method public hidebysig instance uint64
+ RShiftUnsignedLong(uint64 num1,
+ uint64 num2) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 3
+ .locals init (uint64 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: conv.i4
+ IL_0004: ldc.i4.s 63
+ IL_0006: and
+ IL_0007: shr.un
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::RShiftUnsignedLong
+
+ .method public hidebysig instance int32
+ ShiftByte(uint8 num) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 2
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldc.i4.8
+ IL_0003: shl
+ IL_0004: stloc.0
+ IL_0005: br.s IL_0007
+
+ IL_0007: ldloc.0
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::ShiftByte
+
+ .method public hidebysig instance int32
+ RShiftByte(uint8 num) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 2
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldc.i4.8
+ IL_0003: shr
+ IL_0004: stloc.0
+ IL_0005: br.s IL_0007
+
+ IL_0007: ldloc.0
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::RShiftByte
+
+ .method public hidebysig instance uint32
+ RShiftByteWithZeroExtension(uint8 num) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 2
+ .locals init (uint32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldc.i4.8
+ IL_0003: shr.un
+ IL_0004: stloc.0
+ IL_0005: br.s IL_0007
+
+ IL_0007: ldloc.0
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::RShiftByteWithZeroExtension
+
+ .method public hidebysig instance int32
+ RShiftByteAsSByte(uint8 num) cil managed
+ {
+ // Code size 10 (0xa)
+ .maxstack 2
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: conv.i1
+ IL_0003: ldc.i4.8
+ IL_0004: shr
+ IL_0005: stloc.0
+ IL_0006: br.s IL_0008
+
+ IL_0008: ldloc.0
+ IL_0009: ret
+ } // end of method TypeAnalysisTests::RShiftByteAsSByte
+
+ .method public hidebysig instance int32
+ RShiftSByte(int8 num) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 2
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldc.i4.8
+ IL_0003: shr
+ IL_0004: stloc.0
+ IL_0005: br.s IL_0007
+
+ IL_0007: ldloc.0
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::RShiftSByte
+
+ .method public hidebysig instance uint32
+ RShiftSByteWithZeroExtension(int8 num) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 2
+ .locals init (uint32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldc.i4.8
+ IL_0003: shr.un
+ IL_0004: stloc.0
+ IL_0005: br.s IL_0007
+
+ IL_0007: ldloc.0
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::RShiftSByteWithZeroExtension
+
+ .method public hidebysig instance int32
+ RShiftSByteAsByte(int8 num) cil managed
+ {
+ // Code size 10 (0xa)
+ .maxstack 2
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: conv.u1
+ IL_0003: ldc.i4.8
+ IL_0004: shr
+ IL_0005: stloc.0
+ IL_0006: br.s IL_0008
+
+ IL_0008: ldloc.0
+ IL_0009: ret
+ } // end of method TypeAnalysisTests::RShiftSByteAsByte
+
+ .method public hidebysig instance int32
+ GetHashCode(int64 num) cil managed
+ {
+ // Code size 14 (0xe)
+ .maxstack 3
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: conv.i4
+ IL_0003: ldarg.1
+ IL_0004: ldc.i4.s 32
+ IL_0006: shr
+ IL_0007: conv.i4
+ IL_0008: xor
+ IL_0009: stloc.0
+ IL_000a: br.s IL_000c
+
+ IL_000c: ldloc.0
+ IL_000d: ret
+ } // end of method TypeAnalysisTests::GetHashCode
+
+ .method public hidebysig instance void
+ TernaryOp(class [mscorlib]System.Random a,
+ class [mscorlib]System.Random b,
+ bool c) cil managed
+ {
+ // Code size 24 (0x18)
+ .maxstack 2
+ .locals init (bool V_0)
+ IL_0000: nop
+ IL_0001: ldarg.3
+ IL_0002: brtrue.s IL_0007
+
+ IL_0004: ldarg.2
+ IL_0005: br.s IL_0008
+
+ IL_0007: ldarg.1
+ IL_0008: ldnull
+ IL_0009: ceq
+ IL_000b: stloc.0
+ IL_000c: ldloc.0
+ IL_000d: brfalse.s IL_0017
+
+ IL_000f: nop
+ IL_0010: call void [mscorlib]System.Console::WriteLine()
+ IL_0015: nop
+ IL_0016: nop
+ IL_0017: ret
+ } // end of method TypeAnalysisTests::TernaryOp
+
+ .method public hidebysig instance void
+ OperatorIs(object o) cil managed
+ {
+ // Code size 35 (0x23)
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: isinst [mscorlib]System.Random
+ IL_0007: ldnull
+ IL_0008: cgt.un
+ IL_000a: call void [mscorlib]System.Console::WriteLine(bool)
+ IL_000f: nop
+ IL_0010: ldarg.1
+ IL_0011: isinst [mscorlib]System.Random
+ IL_0016: ldnull
+ IL_0017: cgt.un
+ IL_0019: ldc.i4.0
+ IL_001a: ceq
+ IL_001c: call void [mscorlib]System.Console::WriteLine(bool)
+ IL_0021: nop
+ IL_0022: ret
+ } // end of method TypeAnalysisTests::OperatorIs
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithInt(int32 length) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 1
+ .locals init (uint8[] V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: newarr [mscorlib]System.Byte
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithInt
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithLong(int64 length) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 1
+ .locals init (uint8[] V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: conv.ovf.i
+ IL_0003: newarr [mscorlib]System.Byte
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithLong
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithUInt(uint32 length) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 1
+ .locals init (uint8[] V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: newarr [mscorlib]System.Byte
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithUInt
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithULong(uint64 length) cil managed
+ {
+ // Code size 13 (0xd)
+ .maxstack 1
+ .locals init (uint8[] V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: conv.ovf.i.un
+ IL_0003: newarr [mscorlib]System.Byte
+ IL_0008: stloc.0
+ IL_0009: br.s IL_000b
+
+ IL_000b: ldloc.0
+ IL_000c: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithULong
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithShort(int16 length) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 1
+ .locals init (uint8[] V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: newarr [mscorlib]System.Byte
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithShort
+
+ .method public hidebysig instance uint8[]
+ CreateArrayWithUShort(uint16 length) cil managed
+ {
+ // Code size 12 (0xc)
+ .maxstack 1
+ .locals init (uint8[] V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: newarr [mscorlib]System.Byte
+ IL_0007: stloc.0
+ IL_0008: br.s IL_000a
+
+ IL_000a: ldloc.0
+ IL_000b: ret
+ } // end of method TypeAnalysisTests::CreateArrayWithUShort
+
+ .method public hidebysig instance valuetype [mscorlib]System.StringComparison
+ EnumDiffNumber(valuetype [mscorlib]System.StringComparison data) cil managed
+ {
+ // Code size 9 (0x9)
+ .maxstack 2
+ .locals init (valuetype [mscorlib]System.StringComparison V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldc.i4.1
+ IL_0003: sub
+ IL_0004: stloc.0
+ IL_0005: br.s IL_0007
+
+ IL_0007: ldloc.0
+ IL_0008: ret
+ } // end of method TypeAnalysisTests::EnumDiffNumber
+
+ .method public hidebysig instance int32
+ EnumDiff(valuetype [mscorlib]System.StringComparison a,
+ valuetype [mscorlib]System.StringComparison b) cil managed
+ {
+ // Code size 14 (0xe)
+ .maxstack 2
+ .locals init (int32 V_0)
+ IL_0000: nop
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: sub
+ IL_0004: call int32 [mscorlib]System.Math::Abs(int32)
+ IL_0009: stloc.0
+ IL_000a: br.s IL_000c
+
+ IL_000c: ldloc.0
+ IL_000d: ret
+ } // end of method TypeAnalysisTests::EnumDiff
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ // Code size 8 (0x8)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method TypeAnalysisTests::.ctor
+
+} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.TypeAnalysisTests
+
+
+// =============================================================
+
+// *********** DISASSEMBLY COMPLETE ***********************
diff --git a/ICSharpCode.Decompiler.Tests/TypeAnalysisTests.cs b/ICSharpCode.Decompiler.Tests/TypeAnalysisTests.cs
deleted file mode 100644
index 760bb862d..000000000
--- a/ICSharpCode.Decompiler.Tests/TypeAnalysisTests.cs
+++ /dev/null
@@ -1,153 +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 class TypeAnalysisTests
-{
- public byte SubtractFrom256(byte b)
- {
- return (byte)(256 - (int)b);
- }
-
- #region Shift
- public int LShiftInteger(int num1, int num2)
- {
- return num1 << num2;
- }
-
- public uint LShiftUnsignedInteger(uint num1, uint num2)
- {
- return num1 << (int)num2;
- }
-
- public long LShiftLong(long num1, long num2)
- {
- return num1 << (int)num2;
- }
-
- public ulong LShiftUnsignedLong(ulong num1, ulong num2)
- {
- return num1 << (int)num2;
- }
-
- public int RShiftInteger(int num1, int num2)
- {
- return num1 >> num2;
- }
-
- public uint RShiftUnsignedInteger(uint num1, int num2)
- {
- return num1 >> num2;
- }
-
- public long RShiftLong(long num1, long num2)
- {
- return num1 >> (int)num2;
- }
-
- public ulong RShiftUnsignedLong(ulong num1, ulong num2)
- {
- return num1 >> (int)num2;
- }
-
- public int ShiftByte(byte num)
- {
- return (int)num << 8;
- }
-
- public int RShiftByte(byte num)
- {
- return num >> 8;
- }
-
- public uint RShiftByteWithZeroExtension(byte num)
- {
- return (uint)num >> 8;
- }
-
- public int RShiftByteAsSByte(byte num)
- {
- return (sbyte)num >> 8;
- }
-
- public int RShiftSByte(sbyte num)
- {
- return num >> 8;
- }
-
- public uint RShiftSByteWithZeroExtension(sbyte num)
- {
- return (uint)num >> 8;
- }
-
- public int RShiftSByteAsByte(sbyte num)
- {
- return (byte)num >> 8;
- }
- #endregion
-
- public int GetHashCode(long num)
- {
- return (int)num ^ (int)(num >> 32);
- }
-
- public void TernaryOp(Random a, Random b, bool c)
- {
- if ((c ? a : b) == null)
- {
- Console.WriteLine();
- }
- }
-
- public void OperatorIs(object o)
- {
- Console.WriteLine(o is Random);
- Console.WriteLine(!(o is Random));
- }
-
- public byte[] CreateArrayWithInt(int length)
- {
- return new byte[length];
- }
-
- public byte[] CreateArrayWithLong(long length)
- {
- return new byte[length];
- }
-
- public byte[] CreateArrayWithUInt(uint length)
- {
- return new byte[length];
- }
-
- public byte[] CreateArrayWithULong(ulong length)
- {
- return new byte[length];
- }
-
- public StringComparison EnumDiffNumber(StringComparison data)
- {
- return data - 1;
- }
-
- public int EnumDiff(StringComparison a, StringComparison b)
- {
- return Math.Abs(a - b);
- }
-}
diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
index 0d12c85a7..aab1d322e 100644
--- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
+++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
@@ -1376,8 +1376,17 @@ namespace ICSharpCode.Decompiler.CSharp
TranslatedExpression TranslateArrayIndex(ILInstruction i)
{
- var stackType = i.ResultType == StackType.I4 ? KnownTypeCode.Int32 : KnownTypeCode.Int64;
- return Translate(i).ConvertTo(compilation.FindType(stackType), this);
+ var input = Translate(i);
+ KnownTypeCode targetType;
+ if (i.ResultType == StackType.I4) {
+ if (input.Type.IsSmallIntegerType() && input.Type.Kind != TypeKind.Enum) {
+ return input; // we don't need a cast, just let small integers be promoted to int
+ }
+ targetType = input.Type.GetSign() == Sign.Unsigned ? KnownTypeCode.UInt32 : KnownTypeCode.Int32;
+ } else {
+ targetType = input.Type.GetSign() == Sign.Unsigned ? KnownTypeCode.UInt64 : KnownTypeCode.Int64;
+ }
+ return input.ConvertTo(compilation.FindType(targetType), this);
}
protected internal override TranslatedExpression VisitUnboxAny(UnboxAny inst, TranslationContext context)
diff --git a/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs b/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs
index 7ce9047e4..562ac2bf8 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs
@@ -107,7 +107,21 @@ namespace ICSharpCode.Decompiler.IL.Transforms
inst.ReplaceWith(new LdLen(inst.TargetType.GetStackType(), array) { ILRange = inst.ILRange });
}
}
-
+
+ protected internal override void VisitNewArr(NewArr inst)
+ {
+ base.VisitNewArr(inst);
+ foreach (ILInstruction index in inst.Indices) {
+ if (index is Conv conv && conv.ResultType == StackType.I
+ && (conv.Kind == ConversionKind.Truncate && conv.CheckForOverflow
+ || conv.Kind == ConversionKind.ZeroExtend || conv.Kind == ConversionKind.SignExtend)
+ ) {
+ context.Step("newarr(conv(X)) => newarr(X)", inst);
+ index.ReplaceWith(conv.Argument);
+ }
+ }
+ }
+
protected internal override void VisitLogicNot(LogicNot inst)
{
ILInstruction arg, lhs, rhs;