Skip to content

Commit 6986791

Browse files
Add new test and move existing tests together
The existing test may need an update to work for #749 and #1062
1 parent b8c5a10 commit 6986791

2 files changed

Lines changed: 87 additions & 57 deletions

File tree

CodeConverter/CSharp/OperationExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static bool IsAssignableExpression(this IOperation operation)
5656
case OperationKind.DynamicMemberReference:
5757
return true;
5858

59-
//Just documenting since it's the only one mentioning reference that can't be assigned to AFAIK
59+
//Just documenting since it's the only one mentioning reference that can't necessarily be assigned to AFAIK
6060
case OperationKind.PropertyReference:
6161
return false;
6262
}

Tests/CSharp/MemberTests/MemberTests.cs

Lines changed: 86 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,6 +2211,92 @@ public partial class FooBar : IFoo, IBar
22112211
}");
22122212
}
22132213

2214+
[Fact]
2215+
public async Task ExplicitInterfaceImplementationOptionalParameters_1062_Async()
2216+
{
2217+
await TestConversionVisualBasicToCSharpAsync(
2218+
@"
2219+
Public Interface InterfaceWithOptionalParameters
2220+
Sub S(Optional i As Integer = 0)
2221+
End Interface
2222+
2223+
Public Class ImplInterfaceWithOptionalParameters : Implements InterfaceWithOptionalParameters
2224+
Public Sub InterfaceWithOptionalParameters_S(Optional i As Integer = 0) Implements InterfaceWithOptionalParameters.S
2225+
End Sub
2226+
End Class", @"
2227+
public partial interface InterfaceWithOptionalParameters
2228+
{
2229+
void S(int i = 0);
2230+
}
2231+
2232+
public partial class ImplInterfaceWithOptionalParameters : InterfaceWithOptionalParameters
2233+
{
2234+
public void InterfaceWithOptionalParameters_S(int i = 0)
2235+
{
2236+
}
2237+
2238+
void InterfaceWithOptionalParameters.S(int i = 0) => InterfaceWithOptionalParameters_S(i);
2239+
}
2240+
");
2241+
}
2242+
2243+
2244+
[Fact]
2245+
public async Task ExplicitInterfaceImplementationOptionalParametersAsync()
2246+
{
2247+
await TestConversionVisualBasicToCSharpAsync(
2248+
@"Public Interface IFoo
2249+
Property ExplicitProp(Optional str As String = """") As Integer
2250+
Function ExplicitFunc(Optional str2 As String = """", Optional i2 As Integer = 1) As Integer
2251+
End Interface
2252+
2253+
Public Class Foo
2254+
Implements IFoo
2255+
2256+
Private Function ExplicitFunc(Optional str As String = """", Optional i2 As Integer = 1) As Integer Implements IFoo.ExplicitFunc
2257+
Return 5
2258+
End Function
2259+
2260+
Private Property ExplicitProp(Optional str As String = """") As Integer Implements IFoo.ExplicitProp
2261+
Get
2262+
Return 5
2263+
End Get
2264+
Set(value As Integer)
2265+
End Set
2266+
End Property
2267+
End Class", @"
2268+
public partial interface IFoo
2269+
{
2270+
int get_ExplicitProp(string str = """");
2271+
void set_ExplicitProp(string str = """", int value = default);
2272+
int ExplicitFunc(string str2 = """", int i2 = 1);
2273+
}
2274+
2275+
public partial class Foo : IFoo
2276+
{
2277+
2278+
private int ExplicitFunc(string str = """", int i2 = 1)
2279+
{
2280+
return 5;
2281+
}
2282+
2283+
int IFoo.ExplicitFunc(string str, int i2) => ExplicitFunc(str, i2);
2284+
2285+
private int get_ExplicitProp(string str = """")
2286+
{
2287+
return 5;
2288+
}
2289+
2290+
private void set_ExplicitProp(string str = """", int value = default)
2291+
{
2292+
}
2293+
2294+
int IFoo.get_ExplicitProp(string str) => get_ExplicitProp(str);
2295+
void IFoo.set_ExplicitProp(string str, int value) => set_ExplicitProp(str, value);
2296+
}
2297+
");
2298+
}
2299+
22142300
[Fact]
22152301
public async Task RenamedInterfaceMethodFullyQualifiedAsync()
22162302
{
@@ -3506,62 +3592,6 @@ private void set_ExplicitProp(string str, int value)
35063592
}");
35073593
}
35083594

3509-
[Fact]
3510-
public async Task ExplicitInterfaceImplementationOptionalParametersAsync()
3511-
{
3512-
await TestConversionVisualBasicToCSharpAsync(
3513-
@"Public Interface IFoo
3514-
Property ExplicitProp(Optional str As String = """") As Integer
3515-
Function ExplicitFunc(Optional str2 As String = """", Optional i2 As Integer = 1) As Integer
3516-
End Interface
3517-
3518-
Public Class Foo
3519-
Implements IFoo
3520-
3521-
Private Function ExplicitFunc(Optional str As String = """", Optional i2 As Integer = 1) As Integer Implements IFoo.ExplicitFunc
3522-
Return 5
3523-
End Function
3524-
3525-
Private Property ExplicitProp(Optional str As String = """") As Integer Implements IFoo.ExplicitProp
3526-
Get
3527-
Return 5
3528-
End Get
3529-
Set(value As Integer)
3530-
End Set
3531-
End Property
3532-
End Class", @"
3533-
public partial interface IFoo
3534-
{
3535-
int get_ExplicitProp(string str = """");
3536-
void set_ExplicitProp(string str = """", int value = default);
3537-
int ExplicitFunc(string str2 = """", int i2 = 1);
3538-
}
3539-
3540-
public partial class Foo : IFoo
3541-
{
3542-
3543-
private int ExplicitFunc(string str = """", int i2 = 1)
3544-
{
3545-
return 5;
3546-
}
3547-
3548-
int IFoo.ExplicitFunc(string str, int i2) => ExplicitFunc(str, i2);
3549-
3550-
private int get_ExplicitProp(string str = """")
3551-
{
3552-
return 5;
3553-
}
3554-
3555-
private void set_ExplicitProp(string str = """", int value = default)
3556-
{
3557-
}
3558-
3559-
int IFoo.get_ExplicitProp(string str) => get_ExplicitProp(str);
3560-
void IFoo.set_ExplicitProp(string str, int value) => set_ExplicitProp(str, value);
3561-
}
3562-
");
3563-
}
3564-
35653595
/// <summary>
35663596
///
35673597
/// </summary>

0 commit comments

Comments
 (0)