@@ -405,24 +405,20 @@ public void ConvertBaseList(CSS.BaseTypeDeclarationSyntax type, List<InheritsSta
405405 }
406406
407407
408- private static IEnumerable < SyntaxToken > ConvertModifiersCore ( IReadOnlyCollection < SyntaxToken > modifiers ,
409- TokenContext context , bool isConstructor )
410- {
411- if ( context != TokenContext . Local && context != TokenContext . MemberInInterface && context != TokenContext . MemberInProperty ) {
412- bool visibility = false ;
413- foreach ( var token in modifiers ) {
414- if ( token . IsCsVisibility ( true , isConstructor ) ) { //TODO Don't always treat as variable or const, pass in more context to detect this
415- visibility = true ;
416- break ;
417- }
418- }
419- if ( ! visibility )
420- yield return CSharpDefaultVisibility ( context ) ;
421- }
422- foreach ( var token in modifiers . Where ( m => ! IgnoreInContext ( m , context ) ) ) {
423- var m = ConvertModifier ( token , context ) ;
424- if ( m . HasValue ) yield return m . Value ;
425- }
408+ private static IEnumerable < SyntaxToken > ConvertModifiersCore ( IReadOnlyCollection < SyntaxToken > modifiers , TokenContext context , bool isConstructor ) {
409+ var needsExplicitVisibility = context != TokenContext . Local
410+ && context != TokenContext . MemberInInterface
411+ && context != TokenContext . MemberInProperty
412+ && ! modifiers . Any ( x => x . IsCsVisibility ( true , isConstructor ) ) ; //TODO Don't always treat as variable or const, pass in more context to detect this
413+ var vbModifiers = modifiers
414+ . Where ( m => ! IgnoreInContext ( m , context ) )
415+ . Select ( x => ConvertModifier ( x , context ) )
416+ . Where ( x => x . HasValue )
417+ . Select ( x => x . Value )
418+ . ToList ( ) ;
419+ if ( needsExplicitVisibility )
420+ vbModifiers . Insert ( vbModifiers . FirstOrDefault ( ) . IsKind ( SyntaxKind . PartialKeyword ) ? 1 : 0 , CSharpDefaultVisibility ( context ) ) ;
421+ return vbModifiers ;
426422 }
427423
428424 private static bool IgnoreInContext ( SyntaxToken m , TokenContext context )
0 commit comments