Replace the Issue3659 IL test with a VBPretty test

This commit is contained in:
dualfroz committed 2026-09-13 18:32:51 +02:00
1 parent 5088708223
commit 14f32689d4
6 files changed
+114 -180

No files matched your search

@@ -267,12 +267,6 @@ namespace ICSharpCode.Decompiler.Tests
await Run(); await Run();
} }
[Test]
public async Task Issue3659()
{
await Run();
}
[Test] [Test]
public async Task Issue3466() public async Task Issue3466()
{ {
@@ -1,65 +0,0 @@
using System;
using Microsoft.VisualBasic.CompilerServices;
namespace ICSharpCode.Decompiler.Tests.TestCases.ILPretty
{
public class Issue3659
{
public static void Func(ref Issue3659 obj, object value)
{
}
public static int ShowMessage(string a, int b, string c, object d, int e)
{
return 0;
}
internal void VBFunction(object value)
{
int try0000_dispatch = -1;
int num2 = default;
int num = default;
while (true)
{
try
{
/*Note: ILSpy has introduced the following switch to emulate a goto from catch-block to try-block*/;
switch (try0000_dispatch)
{
default:
{
ProjectData.ClearProjectError();
num2 = 2;
Issue3659 obj = this;
Func(ref obj, value);
goto end_IL_0000;
}
case 40:
num = -1;
switch (num2)
{
case 2:
ShowMessage("VBFunction", 0, "Exception", null, 0);
goto end_IL_0000;
}
break;
}
}
catch (Exception ex) when ((num2 != 0) & (num == 0))
{
ProjectData.SetProjectError(ex);
try0000_dispatch = 40;
continue;
}
throw ProjectData.CreateProjectError(-214628237);
continue;
end_IL_0000:
break;
}
if (num != 0)
{
ProjectData.ClearProjectError();
}
}
}
}
@@ -1,109 +0,0 @@
.assembly extern System.Runtime
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 4:0:0:0
}
.assembly extern Microsoft.VisualBasic.Core
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
.ver 10:0:0:0
}
.assembly Issue3659 { .ver 0:0:0:0 }
.module Issue3659.dll
.class private auto ansi '<Module>'
{
}
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue3659
extends [System.Runtime]System.Object
{
.method public hidebysig static void Func(class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue3659& obj, object 'value') cil managed
{
ret
}
.method public hidebysig static int32 ShowMessage(string a, int32 b, string c, object d, int32 e) cil managed
{
ldc.i4.0
ret
}
.method assembly hidebysig instance void VBFunction(object 'value') cil managed
{
.maxstack 5
.locals init (
[0] int32,
[1] int32,
[2] class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue3659
)
.try
{
IL_0000: call void [Microsoft.VisualBasic.Core]Microsoft.VisualBasic.CompilerServices.ProjectData::ClearProjectError()
IL_0005: ldc.i4.2
IL_0006: stloc.0
IL_0007: ldarg.0
IL_0008: stloc.2
IL_0009: ldloca.s 2
IL_000b: ldarg.1
IL_000c: call void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue3659::Func(class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue3659&, object)
IL_0011: br.s IL_0026
IL_0013: ldstr "VBFunction"
IL_0018: ldc.i4.0
IL_0019: ldstr "Exception"
IL_001e: ldnull
IL_001f: ldc.i4.0
IL_0020: call int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue3659::ShowMessage(string, int32, string, object, int32)
IL_0025: pop
IL_0026: leave.s IL_0069
IL_0028: ldc.i4.m1
IL_0029: stloc.1
IL_002a: ldloc.0
IL_002b: switch (IL_003c, IL_003c, IL_0013)
IL_003c: leave.s IL_005e
}
filter
{
IL_003e: isinst [System.Runtime]System.Exception
IL_0043: ldnull
IL_0044: cgt.un
IL_0046: ldloc.0
IL_0047: ldc.i4.0
IL_0048: cgt.un
IL_004a: and
IL_004b: ldloc.1
IL_004c: ldc.i4.0
IL_004d: ceq
IL_004f: and
IL_0050: endfilter
}
{
IL_0052: castclass [System.Runtime]System.Exception
IL_0057: call void [Microsoft.VisualBasic.Core]Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError(class [System.Runtime]System.Exception)
IL_005c: leave.s IL_0028
}
IL_005e: ldc.i4 -214628237
IL_0063: call class [System.Runtime]System.Exception [Microsoft.VisualBasic.Core]Microsoft.VisualBasic.CompilerServices.ProjectData::CreateProjectError(int32)
IL_0068: throw
IL_0069: ldloc.1
IL_006a: brfalse.s IL_0071
IL_006c: call void [Microsoft.VisualBasic.Core]Microsoft.VisualBasic.CompilerServices.ProjectData::ClearProjectError()
IL_0071: ret
}
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed
{
ldarg.0
call instance void [System.Runtime]System.Object::.ctor()
ret
}
}
@@ -0,0 +1,91 @@
using System;
using System.Runtime.CompilerServices;
using Microsoft.VisualBasic.CompilerServices;
public class Issue3659
{
public static void Func(ref Issue3659 obj, object value)
{
}
public static int ShowMessage(string a, int b, string c, object d, int e)
{
return 0;
}
internal void VBFunction(object value)
{
#if OPT
int try0000_dispatch = -1;
#else
int try0001_dispatch = -1;
#endif
int num2 = default;
int num = default;
while (true)
{
try
{
/*Note: ILSpy has introduced the following switch to emulate a goto from catch-block to try-block*/;
#if OPT
switch (try0000_dispatch)
#else
switch (try0001_dispatch)
#endif
{
default:
{
ProjectData.ClearProjectError();
num2 = 2;
Issue3659 obj = this;
Func(ref obj, RuntimeHelpers.GetObjectValue(value));
#if OPT
goto end_IL_0000;
#else
goto end_IL_0001;
#endif
}
#if OPT
case 45:
#else
case 50:
#endif
num = -1;
switch (num2)
{
case 2:
ShowMessage("VBFunction", 0, "Exception", null, 0);
#if OPT
goto end_IL_0000;
#else
goto end_IL_0001;
#endif
}
break;
}
}
catch (Exception ex) when ((num2 != 0) & (num == 0))
{
ProjectData.SetProjectError(ex);
#if OPT
try0000_dispatch = 45;
#else
try0001_dispatch = 50;
#endif
continue;
}
throw ProjectData.CreateProjectError(-2146828237);
continue;
#if OPT
end_IL_0000:
#else
end_IL_0001:
#endif
break;
}
if (num != 0)
{
ProjectData.ClearProjectError();
}
}
}
@@ -0,0 +1,17 @@
Imports System
Public Class Issue3659
Public Shared Sub Func(ByRef obj As Issue3659, value As Object)
End Sub
Public Shared Function ShowMessage(a As String, b As Integer, c As String, d As Object, e As Integer) As Integer
Return 0
End Function
Friend Sub VBFunction(value As Object)
On Error GoTo Handler
Func(Me, value)
Exit Sub
Handler:
ShowMessage("VBFunction", 0, "Exception", Nothing, 0)
End Sub
End Class
@@ -132,6 +132,12 @@ namespace ICSharpCode.Decompiler.Tests
await Run(options: options | CompilerOptions.Library); await Run(options: options | CompilerOptions.Library);
} }
[Test]
public async Task Issue3659([ValueSource(nameof(defaultOptions))] CompilerOptions options)
{
await Run(options: options | CompilerOptions.Library);
}
[Test] [Test]
public async Task Issue1906([ValueSource(nameof(defaultOptions))] CompilerOptions options) public async Task Issue1906([ValueSource(nameof(defaultOptions))] CompilerOptions options)
{ {