Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1277 from Viridovics/issue-1256
Fix #1256: Add cast to object for reference types in ExpressionBuilder.VisitUnboxAny
- Loading branch information
Showing
5 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1256.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
|
||
namespace ICSharpCode.Decompiler.Tests.TestCases.ILPretty | ||
{ | ||
internal class Issue1256 | ||
{ | ||
public void Method(Enum e, object o, string s) | ||
{ | ||
int num = (int)(object)e; | ||
object obj = new object(); | ||
int num2 = (int)obj; | ||
long num3 = (long)o; | ||
int num4 = (int)(object)s; | ||
int num5 = (int)num3; | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1256.il
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue1256 | ||
extends [mscorlib]System.Object | ||
{ | ||
// Methods | ||
.method public hidebysig | ||
instance void Method ( | ||
class [mscorlib]System.Enum e, | ||
object o, | ||
string s | ||
) cil managed | ||
{ | ||
// Method begins at RVA 0x2050 | ||
// Code size 41 (0x29) | ||
.maxstack 1 | ||
.locals init ( | ||
[0] int32, | ||
[1] object, | ||
[2] int32, | ||
[3] int64, | ||
[4] int32, | ||
[5] int32 | ||
) | ||
|
||
IL_0000: nop | ||
IL_0001: ldarg.1 | ||
IL_0002: unbox.any [mscorlib]System.Int32 | ||
IL_0007: stloc.0 | ||
IL_0008: newobj instance void [mscorlib]System.Object::.ctor() | ||
IL_000d: stloc.1 | ||
IL_000e: ldloc.1 | ||
IL_000f: unbox.any [mscorlib]System.Int32 | ||
IL_0014: stloc.2 | ||
IL_0015: ldarg.2 | ||
IL_0016: unbox.any [mscorlib]System.Int64 | ||
IL_001b: stloc.3 | ||
IL_001c: ldarg.3 | ||
IL_001d: unbox.any [mscorlib]System.Int32 | ||
IL_0022: stloc.s 4 | ||
IL_0024: ldloc.3 | ||
IL_0025: conv.i4 | ||
IL_0026: stloc.s 5 | ||
IL_0028: ret | ||
} // end of method Issue1256::Method | ||
|
||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor () cil managed | ||
{ | ||
// Method begins at RVA 0x2085 | ||
// 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 Issue1256::.ctor | ||
|
||
} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue1256 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters