Skip to content

Commit a69fa83

Browse files
Timur KelmanTimur Kelman
authored andcommitted
add a test
1 parent fc0a1e6 commit a69fa83

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

Tests/CSharp/MemberTests/MemberTests.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4049,4 +4049,52 @@ public static int StaticTestProperty
40494049
}
40504050
}");
40514051
}
4052+
4053+
[Fact]
4054+
public async Task TestMissingByRefArgumentWithNoExplicitDefaultValueAsync()
4055+
{
4056+
await TestConversionVisualBasicToCSharpAsync(
4057+
@"Imports System.Runtime.InteropServices
4058+
4059+
Class MissingByRefArgumentWithNoExplicitDefaultValue
4060+
Sub S()
4061+
ByRefNoDefault()
4062+
OptionalByRefNoDefault()
4063+
OptionalByRefWithDefault()
4064+
End Sub
4065+
4066+
Private Sub ByRefNoDefault(ByRef str1 As String) : End Sub
4067+
Private Sub OptionalByRefNoDefault(<[Optional]> ByRef str2 As String) : End Sub
4068+
Private Sub OptionalByRefWithDefault(<[Optional], DefaultParameterValue(""a"")> ByRef str3 As String) : End Sub
4069+
End Class", @"using System.Runtime.InteropServices;
4070+
4071+
internal partial class MissingByRefArgumentWithNoExplicitDefaultValue
4072+
{
4073+
public void S()
4074+
{
4075+
ByRefNoDefault();
4076+
string argstr2 = default;
4077+
OptionalByRefNoDefault(str2: ref argstr2);
4078+
string argstr3 = ""a"";
4079+
OptionalByRefWithDefault(str3: ref argstr3);
4080+
}
4081+
4082+
private void ByRefNoDefault(ref string str1)
4083+
{
4084+
}
4085+
private void OptionalByRefNoDefault([Optional] ref string str2)
4086+
{
4087+
}
4088+
private void OptionalByRefWithDefault([Optional][DefaultParameterValue(""a"")] ref string str3)
4089+
{
4090+
}
4091+
}
4092+
3 source compilation errors:
4093+
BC30455: Argument not specified for parameter 'str1' of 'Private Sub ByRefNoDefault(ByRef str1 As String)'.
4094+
BC30455: Argument not specified for parameter 'str2' of 'Private Sub OptionalByRefNoDefault(ByRef str2 As String)'.
4095+
BC30455: Argument not specified for parameter 'str3' of 'Private Sub OptionalByRefWithDefault(ByRef str3 As String)'.
4096+
1 target compilation errors:
4097+
CS7036: There is no argument given that corresponds to the required formal parameter 'str1' of 'MissingByRefArgumentWithNoExplicitDefaultValue.ByRefNoDefault(ref string)'
4098+
");
4099+
}
40524100
}

0 commit comments

Comments
 (0)