File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1504,7 +1504,13 @@ public override async Task<CSharpSyntaxNode> VisitDeclareStatement(VBSyntax.Decl
15041504
15051505 var attributeLists = ( await CommonConversions . ConvertAttributesAsync ( node . AttributeLists ) ) . Add ( dllImportAttributeList ) ;
15061506
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+
15081514 var returnType = await ( node . AsClause ? . Type ) . AcceptAsync < TypeSyntax > ( _triviaConvertingExpressionVisitor ) ?? SyntaxFactory . PredefinedType ( SyntaxFactory . Token ( CSSyntaxKind . VoidKeyword ) ) ;
15091515 var parameterListSyntax = await ( node . ParameterList ) . AcceptAsync < ParameterListSyntax > ( _triviaConvertingExpressionVisitor ) ??
15101516 SyntaxFactory . ParameterList ( ) ;
Original file line number Diff line number Diff line change @@ -84,6 +84,34 @@ static Module1()
8484}" ) ;
8585 }
8686
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+
87115 [ Fact ]
88116 public async Task TestTypeInferredConstAsync ( )
89117 {
You can’t perform that action at this time.
0 commit comments