Skip to content

Commit f0eb3f7

Browse files
Timur KelmanTimur Kelman
authored andcommitted
add a test
1 parent e65b3fd commit f0eb3f7

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Tests/CSharp/MemberTests/MemberTests.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,60 @@ public VisualBasicClass()
385385
}
386386
}");
387387
}
388+
389+
[Fact]
390+
public async Task TestHoistedOutParameterLambdaUsingByRefParameterAsync()
391+
{
392+
await TestConversionVisualBasicToCSharpAsync(
393+
@"Public Class SomeClass
394+
Sub S(Optional ByRef x As Integer = -1)
395+
Dim i As Integer = 0
396+
If F1(x, i) Then
397+
ElseIf F2(x, i) Then
398+
ElseIf F3(x, i) Then
399+
End If
400+
End Sub
401+
402+
Function F1(x As Integer, ByRef o As Object) As Boolean : End Function
403+
Function F2(ByRef x As Integer, ByRef o As Object) As Boolean : End Function
404+
Function F3(ByRef x As Object, ByRef o As Object) As Boolean : End Function
405+
End Class", @"using System.Runtime.InteropServices;
406+
using Microsoft.VisualBasic.CompilerServices; // Install-Package Microsoft.VisualBasic
407+
408+
public partial class SomeClass
409+
{
410+
public void S([Optional, DefaultParameterValue(-1)] ref int x)
411+
{
412+
int i = 0;
413+
bool localF1(ref int x) { object argo = i; var ret = F1(x, ref argo); i = Conversions.ToInteger(argo); return ret; }
414+
bool localF2(ref int x) { object argo1 = i; var ret = F2(ref x, ref argo1); i = Conversions.ToInteger(argo1); return ret; }
415+
bool localF3(ref int x) { object argx = x; object argo2 = i; var ret = F3(ref argx, ref argo2); x = Conversions.ToInteger(argx); i = Conversions.ToInteger(argo2); return ret; }
416+
417+
if (localF1(ref x))
418+
{
419+
}
420+
else if (localF2(ref x))
421+
{
422+
}
423+
else if (localF3(ref x))
424+
{
425+
}
426+
}
427+
428+
public bool F1(int x, ref object o)
429+
{
430+
return default;
431+
}
432+
public bool F2(ref int x, ref object o)
433+
{
434+
return default;
435+
}
436+
public bool F3(ref object x, ref object o)
437+
{
438+
return default;
439+
}
440+
}");
441+
}
388442

389443
[Fact]
390444
public async Task TestMethodWithReturnTypeAsync()

0 commit comments

Comments
 (0)