From b0ba63432af03bf233aa3752e283a727152faa19 Mon Sep 17 00:00:00 2001 From: GrahamTheCoder Date: Thu, 21 Dec 2023 00:07:45 +0000 Subject: [PATCH] Some more tests --- Tests/CSharp/MemberTests/MemberTests.cs | 113 ++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/Tests/CSharp/MemberTests/MemberTests.cs b/Tests/CSharp/MemberTests/MemberTests.cs index 750c19e62..e3a6f5db3 100644 --- a/Tests/CSharp/MemberTests/MemberTests.cs +++ b/Tests/CSharp/MemberTests/MemberTests.cs @@ -2211,6 +2211,62 @@ public partial class FooBar : IFoo, IBar }"); } + [Fact] + public async Task ExplicitInterfaceImplementationRequiredMethodParameters_749_Async() + { + await TestConversionVisualBasicToCSharpAsync( + @" +Public Interface IFoo + Function DoFooBar(ByRef str As String, i As Integer) As Integer +End Interface + +Public Interface IBar + Function DoFooBar(ByRef str As String, i As Integer) As Integer +End Interface + +Public Class FooBar + Implements IFoo, IBar + + Function Foo(ByRef str As String, i As Integer) As Integer Implements IFoo.DoFooBar + Return 4 + End Function + + Function Bar(ByRef str As String, i As Integer) As Integer Implements IBar.DoFooBar + Return 2 + End Function + +End Class", @" +public partial interface IFoo +{ + int DoFooBar(ref string str, int i); +} + +public partial interface IBar +{ + int DoFooBar(ref string str, int i); +} + +public partial class FooBar : IFoo, IBar +{ + + public int Foo(ref string str, int i) + { + return 4; + } + + int IFoo.DoFooBar(ref string str, int i) => Foo(ref str, i); + + public int Bar(ref string str, int i) + { + return 2; + } + + int IBar.DoFooBar(ref string str, int i) => Bar(ref str, i); + +} +"); + } + [Fact] public async Task ExplicitInterfaceImplementationOptionalParameters_1062_Async() { @@ -2297,6 +2353,63 @@ private void set_ExplicitProp(string str = """", int value = default) "); } + + [Fact] + public async Task ExplicitInterfaceImplementationOptionalMethodParameters_749_Async() + { + await TestConversionVisualBasicToCSharpAsync( + @" +Public Interface IFoo + Function DoFooBar(ByRef str As String, Optional i As Integer = 4) As Integer +End Interface + +Public Interface IBar + Function DoFooBar(ByRef str As String, Optional i As Integer = 8) As Integer +End Interface + +Public Class FooBar + Implements IFoo, IBar + + Function Foo(ByRef str As String, Optional i As Integer = 4) As Integer Implements IFoo.DoFooBar + Return 4 + End Function + + Function Bar(ByRef str As String, Optional i As Integer = 8) As Integer Implements IBar.DoFooBar + Return 2 + End Function + +End Class", @" +public partial interface IFoo +{ + int DoFooBar(ref string str, int i = 4); +} + +public partial interface IBar +{ + int DoFooBar(ref string str, int i = 8); +} + +public partial class FooBar : IFoo, IBar +{ + + public int Foo(ref string str, int i = 4) + { + return 4; + } + + int IFoo.DoFooBar(ref string str, int i = 4) => Foo(ref str, i); + + public int Bar(ref string str, int i = 8) + { + return 2; + } + + int IBar.DoFooBar(ref string str, int i = 8) => Bar(ref str, i); + +} +"); + } + [Fact] public async Task RenamedInterfaceMethodFullyQualifiedAsync() {