diff --git a/Tests/CSharp/MemberTests/MemberTests.cs b/Tests/CSharp/MemberTests/MemberTests.cs index 2427ed6b..1aae7ee1 100644 --- a/Tests/CSharp/MemberTests/MemberTests.cs +++ b/Tests/CSharp/MemberTests/MemberTests.cs @@ -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)' +"); + } } \ No newline at end of file