Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore tests lost in merge conflicts #1123

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions Tests/CSharp/MemberTests/MemberTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4092,4 +4092,86 @@ public void M([Optional, DefaultParameterValue(""a"")] string a, [Optional, Defa
}
}");
}

[Fact]
public async Task TestRefConstArgumentAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class RefConstArgument
Const a As String = ""a""
Sub S()
Const b As String = ""b""
MO(a)
MS(b)
End Sub
Sub MO(ByRef s As Object) : End Sub
Sub MS(ByRef s As String) : End Sub
End Class", @"
internal partial class RefConstArgument
{
private const string a = ""a"";
public void S()
{
const string b = ""b"";
object args = a;
MO(ref args);
string args1 = b;
MS(ref args1);
}
public void MO(ref object s)
{
}
public void MS(ref string s)
{
}
}");
}

[Fact]
public async Task TestMissingByRefArgumentWithNoExplicitDefaultValueAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Imports System.Runtime.InteropServices

Class MissingByRefArgumentWithNoExplicitDefaultValue
Sub S()
ByRefNoDefault()
OptionalByRefNoDefault()
OptionalByRefWithDefault()
End Sub

Private Sub ByRefNoDefault(ByRef str1 As String) : End Sub
Private Sub OptionalByRefNoDefault(<[Optional]> ByRef str2 As String) : End Sub
Private Sub OptionalByRefWithDefault(<[Optional], DefaultParameterValue(""a"")> ByRef str3 As String) : End Sub
End Class", @"using System.Runtime.InteropServices;

internal partial class MissingByRefArgumentWithNoExplicitDefaultValue
{
public void S()
{
ByRefNoDefault();
string argstr2 = default;
OptionalByRefNoDefault(str2: ref argstr2);
string argstr3 = ""a"";
OptionalByRefWithDefault(str3: ref argstr3);
}

private void ByRefNoDefault(ref string str1)
{
}
private void OptionalByRefNoDefault([Optional] ref string str2)
{
}
private void OptionalByRefWithDefault([Optional][DefaultParameterValue(""a"")] ref string str3)
{
}
}
3 source compilation errors:
BC30455: Argument not specified for parameter 'str1' of 'Private Sub ByRefNoDefault(ByRef str1 As String)'.
BC30455: Argument not specified for parameter 'str2' of 'Private Sub OptionalByRefNoDefault(ByRef str2 As String)'.
BC30455: Argument not specified for parameter 'str3' of 'Private Sub OptionalByRefWithDefault(ByRef str3 As String)'.
1 target compilation errors:
CS7036: There is no argument given that corresponds to the required formal parameter 'str1' of 'MissingByRefArgumentWithNoExplicitDefaultValue.ByRefNoDefault(ref string)'
");
}
}
Loading