File tree Expand file tree Collapse file tree 5 files changed +105
-0
lines changed
ICSharpCode.Decompiler.Tests
ICSharpCode.Decompiler/CSharp Expand file tree Collapse file tree 5 files changed +105
-0
lines changed Original file line number Diff line number Diff line change 100100 <None Include =" TestCases\ILPretty\GuessAccessors.il" />
101101 <None Include =" TestCases\ILPretty\Issue2260SwitchString.il" />
102102 <None Include =" TestCases\ILPretty\Issue3442.il" />
103+ <None Include =" TestCases\ILPretty\Issue3344CkFinite.il" />
103104 <None Include =" TestCases\ILPretty\Issue3466.il" />
104105 <None Include =" testcases\ilpretty\Issue3504.il" />
105106 <None Include =" testcases\ilpretty\Issue3524.il" />
142143 <Compile Include =" ProjectDecompiler\TargetFrameworkTests.cs" />
143144 <Compile Include =" ProjectDecompiler\WholeProjectDecompilerTests.cs" />
144145 <Compile Include =" TestAssemblyResolver.cs" />
146+ <Compile Include =" TestCases\ILPretty\Issue3344CkFinite.cs" />
145147 <Compile Include =" TestCases\ILPretty\Issue3421.cs" />
146148 <Compile Include =" TestCases\ILPretty\Issue3442.cs" />
147149 <Compile Include =" TestCases\ILPretty\Issue3466.cs" />
Original file line number Diff line number Diff line change @@ -207,6 +207,12 @@ public async Task Issue2443()
207207 await Run ( ) ;
208208 }
209209
210+ [ Test ]
211+ public async Task Issue3344CkFinite ( )
212+ {
213+ await Run ( ) ;
214+ }
215+
210216 [ Test ]
211217 public async Task Issue3421 ( )
212218 {
Original file line number Diff line number Diff line change 1+ using System ;
2+
3+ namespace ICSharpCode . Decompiler . Tests . TestCases . ILPretty
4+ {
5+ public class Issue3344
6+ {
7+ private static float GetFloat ( )
8+ {
9+ return 3.5f ;
10+ }
11+
12+ private static float CkFinite ( )
13+ {
14+ float num = GetFloat ( ) ;
15+ if ( ! float . IsFinite ( num ) )
16+ {
17+ throw new ArithmeticException ( ) ;
18+ }
19+ return num ;
20+ }
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ .assembly extern System.Runtime
2+ {
3+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
4+ .ver 4:0:0:0
5+ }
6+
7+ .assembly Issue3344
8+ {
9+ .hash algorithm 0x00008004 // SHA1
10+ .ver 0:0:0:0
11+ }
12+
13+ .class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue3344
14+ extends [System.Runtime]System.Object
15+ {
16+ .method private hidebysig static
17+ float32 GetFloat () cil managed
18+ {
19+ .maxstack 8
20+
21+ IL_0000: ldc.r4 3.5
22+ IL_0005: ret
23+ }
24+
25+ .method private hidebysig static
26+ float32 CkFinite () cil managed
27+ {
28+ .maxstack 1
29+ .locals init (
30+ [0] float32
31+ )
32+
33+ call float32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue3344::GetFloat()
34+ ckfinite
35+ ret
36+ }
37+
38+ .method public hidebysig specialname rtspecialname
39+ instance void .ctor () cil managed
40+ {
41+ .maxstack 8
42+
43+ IL_0000: ldarg.0
44+ IL_0001: call instance void [System.Runtime]System.Object::.ctor()
45+ IL_0006: ret
46+ }
47+
48+ }
Original file line number Diff line number Diff line change @@ -1542,5 +1542,32 @@ protected internal override TranslatedStatement VisitCpblk(Cpblk inst)
15421542 stmt . InsertChildAfter ( null , new Comment ( " IL cpblk instruction" ) , Roles . Comment ) ;
15431543 return stmt . WithILInstruction ( inst ) ;
15441544 }
1545+
1546+ protected internal override TranslatedStatement VisitCkfinite ( Ckfinite inst )
1547+ {
1548+ var isFiniteCall = new InvocationExpression {
1549+ Target = new MemberReferenceExpression {
1550+ Target = new TypeReferenceExpression ( new Syntax . PrimitiveType ( "float" ) ) ,
1551+ MemberName = "IsFinite"
1552+ } ,
1553+ Arguments = {
1554+ exprBuilder . Translate ( inst . Argument )
1555+ }
1556+ } ;
1557+ var arithmeticException = typeSystem . FindType ( typeof ( ArithmeticException ) ) ;
1558+ var arithmeticExceptionSyntax = new SimpleType ( "ArithmeticException" ) ;
1559+ arithmeticExceptionSyntax . AddAnnotation ( new TypeResolveResult ( arithmeticException ) ) ;
1560+ return new IfElseStatement {
1561+ Condition = new UnaryOperatorExpression {
1562+ Operator = UnaryOperatorType . Not ,
1563+ Expression = isFiniteCall
1564+ } ,
1565+ TrueStatement = new ThrowStatement (
1566+ new ObjectCreateExpression {
1567+ Type = arithmeticExceptionSyntax
1568+ }
1569+ ) ,
1570+ } . WithILInstruction ( inst ) ;
1571+ }
15451572 }
15461573}
You can’t perform that action at this time.
0 commit comments