Skip to content

Commit b3ad175

Browse files
author
John Moreno
committed
VB -> C#: private partial methods do not compile
- Added unit test to SpecialConversionTests (not MethodStatementTests as there is no statements) -ISymbolExtensions.cs - CanHaveMethodBody & IsPartialMethodDefinition - Added check for IsPartialDefinition #1097
1 parent 1d8143a commit b3ad175

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

CodeConverter/Util/ISymbolExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ public static bool IsPartialMethodImplementation(this ISymbol declaredSymbol)
7575

7676
public static bool CanHaveMethodBody(this ISymbol declaredSymbol)
7777
{
78-
return !(declaredSymbol is IMethodSymbol ms) || ms.PartialImplementationPart == null && !ms.IsExtern;
78+
return !(declaredSymbol is IMethodSymbol ms) || (!ms.IsPartialDefinition && (ms.PartialImplementationPart == null && !ms.IsExtern));
7979
}
8080

8181
public static bool IsPartialMethodDefinition(this ISymbol declaredSymbol)
8282
{
83-
return declaredSymbol is IMethodSymbol ms && ms.PartialImplementationPart != null;
83+
return declaredSymbol is IMethodSymbol ms && (ms.PartialImplementationPart != null || ms.IsPartialDefinition);
8484
}
8585

8686
public static bool IsPartialClassDefinition(this ISymbol declaredSymbol)

Tests/CSharp/SpecialConversionTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,11 @@ End If
402402
}
403403
}");
404404
}
405+
406+
[Fact]
407+
public async Task Issue1097_PartialMethodAsync()
408+
{
409+
await TestConversionVisualBasicToCSharpAsync(@"Partial Private Sub DummyMethod()
410+
End Sub", @"partial void DummyMethod();");
411+
}
405412
}

0 commit comments

Comments
 (0)