File tree 2 files changed +35
-1
lines changed
2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -1504,7 +1504,13 @@ public override async Task<CSharpSyntaxNode> VisitDeclareStatement(VBSyntax.Decl
1504
1504
1505
1505
var attributeLists = ( await CommonConversions . ConvertAttributesAsync ( node . AttributeLists ) ) . Add ( dllImportAttributeList ) ;
1506
1506
1507
- var modifiers = CommonConversions . ConvertModifiers ( node , node . Modifiers ) . Add ( SyntaxFactory . Token ( CSSyntaxKind . StaticKeyword ) ) . Add ( SyntaxFactory . Token ( CSSyntaxKind . ExternKeyword ) ) ;
1507
+ var tokenContext = GetMemberContext ( node ) ;
1508
+ var modifiers = CommonConversions . ConvertModifiers ( node , node . Modifiers , tokenContext ) ;
1509
+ if ( ! modifiers . Any ( m => m . IsKind ( CSSyntaxKind . StaticKeyword ) ) ) {
1510
+ modifiers = modifiers . Add ( SyntaxFactory . Token ( CSSyntaxKind . StaticKeyword ) ) ;
1511
+ }
1512
+ modifiers = modifiers . Add ( SyntaxFactory . Token ( CSSyntaxKind . ExternKeyword ) ) ;
1513
+
1508
1514
var returnType = await ( node . AsClause ? . Type ) . AcceptAsync < TypeSyntax > ( _triviaConvertingExpressionVisitor ) ?? SyntaxFactory . PredefinedType ( SyntaxFactory . Token ( CSSyntaxKind . VoidKeyword ) ) ;
1509
1515
var parameterListSyntax = await ( node . ParameterList ) . AcceptAsync < ParameterListSyntax > ( _triviaConvertingExpressionVisitor ) ??
1510
1516
SyntaxFactory . ParameterList ( ) ;
Original file line number Diff line number Diff line change @@ -84,6 +84,34 @@ static Module1()
84
84
}" ) ;
85
85
}
86
86
87
+ [ Fact ]
88
+ public async Task TestDeclareMethodVisibilityInModuleAsync ( )
89
+ {
90
+ await TestConversionVisualBasicToCSharpAsync ( @"Module Module1
91
+ Declare Sub External Lib ""lib.dll"" ()
92
+ End Module" , @"using System.Runtime.InteropServices;
93
+
94
+ internal static partial class Module1
95
+ {
96
+ [DllImport(""lib.dll"")]
97
+ public static extern void External();
98
+ }" ) ;
99
+ }
100
+
101
+ [ Fact ]
102
+ public async Task TestDeclareMethodVisibilityInClassAsync ( )
103
+ {
104
+ await TestConversionVisualBasicToCSharpAsync ( @"Class Class1
105
+ Declare Sub External Lib ""lib.dll"" ()
106
+ End Class" , @"using System.Runtime.InteropServices;
107
+
108
+ internal partial class Class1
109
+ {
110
+ [DllImport(""lib.dll"")]
111
+ public static extern void External();
112
+ }" ) ;
113
+ }
114
+
87
115
[ Fact ]
88
116
public async Task TestTypeInferredConstAsync ( )
89
117
{
You can’t perform that action at this time.
0 commit comments