@@ -29,21 +29,21 @@ internal VisibilityRewriter(Document document, CancellationToken cancellationTok
2929 _cancellationToken = cancellationToken ;
3030 }
3131
32- public override SyntaxNode VisitClassDeclaration ( ClassDeclarationSyntax node )
32+ public override SyntaxNode VisitClassDeclaration ( ClassDeclarationSyntax originalNode )
3333 {
34- node = ( ClassDeclarationSyntax ) base . VisitClassDeclaration ( node ) ;
35- return EnsureVisibility ( node , node . Modifiers , ( x , l ) => x . WithModifiers ( l ) , ( ) => GetTypeDefaultVisibility ( node ) ) ;
34+ var node = ( ClassDeclarationSyntax ) base . VisitClassDeclaration ( originalNode ) ;
35+ return EnsureVisibility ( node , node . Modifiers , ( x , l ) => x . WithModifiers ( l ) , ( ) => GetTypeDefaultVisibility ( originalNode ) ) ;
3636 }
3737
3838 public override SyntaxNode VisitInterfaceDeclaration ( InterfaceDeclarationSyntax node )
3939 {
4040 return EnsureVisibility ( node , node . Modifiers , ( x , l ) => x . WithModifiers ( l ) , ( ) => GetTypeDefaultVisibility ( node ) ) ;
4141 }
4242
43- public override SyntaxNode VisitStructDeclaration ( StructDeclarationSyntax node )
43+ public override SyntaxNode VisitStructDeclaration ( StructDeclarationSyntax originalNode )
4444 {
45- node = ( StructDeclarationSyntax ) base . VisitStructDeclaration ( node ) ;
46- return EnsureVisibility ( node , node . Modifiers , ( x , l ) => x . WithModifiers ( l ) , ( ) => GetTypeDefaultVisibility ( node ) ) ;
45+ var node = ( StructDeclarationSyntax ) base . VisitStructDeclaration ( originalNode ) ;
46+ return EnsureVisibility ( node , node . Modifiers , ( x , l ) => x . WithModifiers ( l ) , ( ) => GetTypeDefaultVisibility ( originalNode ) ) ;
4747 }
4848
4949 public override SyntaxNode VisitDelegateDeclaration ( DelegateDeclarationSyntax node )
@@ -106,27 +106,27 @@ public override SyntaxNode VisitFieldDeclaration(FieldDeclarationSyntax node)
106106 return EnsureVisibility ( node , node . Modifiers , ( x , l ) => x . WithModifiers ( l ) , ( ) => SyntaxKind . PrivateKeyword ) ;
107107 }
108108
109- private SyntaxKind GetTypeDefaultVisibility ( BaseTypeDeclarationSyntax node )
109+ private SyntaxKind GetTypeDefaultVisibility ( BaseTypeDeclarationSyntax originalDeclarationSyntax )
110110 {
111111 // In the case of partial types we need to use the existing visibility if it exists
112- if ( node . Modifiers . Any ( x => x . CSharpContextualKind ( ) == SyntaxKind . PartialKeyword ) )
112+ if ( originalDeclarationSyntax . Modifiers . Any ( x => x . CSharpContextualKind ( ) == SyntaxKind . PartialKeyword ) )
113113 {
114- SyntaxKind ? kind = GetExistingPartialVisibility ( node ) ;
114+ SyntaxKind ? kind = GetExistingPartialVisibility ( originalDeclarationSyntax ) ;
115115 if ( kind . HasValue )
116116 {
117117 return kind . Value ;
118118 }
119119 }
120120
121- return GetDelegateTypeDefaultVisibility ( node ) ;
121+ return GetDelegateTypeDefaultVisibility ( originalDeclarationSyntax ) ;
122122 }
123123
124124 private SyntaxKind GetDelegateTypeDefaultVisibility ( SyntaxNode node )
125125 {
126126 return IsNestedDeclaration ( node ) ? SyntaxKind . PrivateKeyword : SyntaxKind . InternalKeyword ;
127127 }
128128
129- private SyntaxKind ? GetExistingPartialVisibility ( BaseTypeDeclarationSyntax declarationSyntax )
129+ private SyntaxKind ? GetExistingPartialVisibility ( BaseTypeDeclarationSyntax originalDeclarationSyntax )
130130 {
131131 // Getting the SemanticModel is a relatively expensive operation. Can take a few seconds in
132132 // projects of significant size. It is delay created to avoid this in files which already
@@ -136,7 +136,7 @@ private SyntaxKind GetDelegateTypeDefaultVisibility(SyntaxNode node)
136136 _semanticModel = _document . GetSemanticModelAsync ( _cancellationToken ) . Result ;
137137 }
138138
139- var symbol = _semanticModel . GetDeclaredSymbol ( declarationSyntax , _cancellationToken ) ;
139+ var symbol = _semanticModel . GetDeclaredSymbol ( originalDeclarationSyntax , _cancellationToken ) ;
140140 if ( symbol == null )
141141 {
142142 return null ;
0 commit comments