@@ -27,7 +27,7 @@ public static Doc Print(CSharpSyntaxNode node, PrintingContext context)
2727 TypeSyntax ? returnType = null ;
2828 ExplicitInterfaceSpecifierSyntax ? explicitInterfaceSpecifier = null ;
2929 TypeParameterListSyntax ? typeParameterList = null ;
30- Func < Doc > ? identifier = null ;
30+ Func < CSharpSyntaxNode , PrintingContext , Doc > ? identifier = null ;
3131 SyntaxList < TypeParameterConstraintClauseSyntax > ? constraintClauses = null ;
3232 ParameterListSyntax ? parameterList = null ;
3333 ConstructorInitializerSyntax ? constructorInitializer = null ;
@@ -46,21 +46,32 @@ public static Doc Print(CSharpSyntaxNode node, PrintingContext context)
4646 {
4747 returnType = methodDeclarationSyntax . ReturnType ;
4848 explicitInterfaceSpecifier = methodDeclarationSyntax . ExplicitInterfaceSpecifier ;
49- identifier = ( ) => Token . Print ( methodDeclarationSyntax . Identifier , context ) ;
49+ identifier = static ( node , context ) =>
50+ {
51+ var methodDeclarationSyntax = node as MethodDeclarationSyntax ;
52+ return Token . Print ( methodDeclarationSyntax . Identifier , context ) ;
53+ } ;
5054 typeParameterList = methodDeclarationSyntax . TypeParameterList ;
5155 constraintClauses = methodDeclarationSyntax . ConstraintClauses ;
5256 }
53- else if ( node is DestructorDeclarationSyntax destructorDeclarationSyntax )
57+ else if ( node is DestructorDeclarationSyntax )
5458 {
55- identifier = ( ) =>
56- Doc . Concat (
59+ identifier = static ( node , context ) =>
60+ {
61+ var destructorDeclarationSyntax = ( DestructorDeclarationSyntax ) node ;
62+ return Doc . Concat (
5763 Token . Print ( destructorDeclarationSyntax . TildeToken , context ) ,
5864 Token . Print ( destructorDeclarationSyntax . Identifier , context )
5965 ) ;
66+ } ;
6067 }
6168 else if ( node is ConstructorDeclarationSyntax constructorDeclarationSyntax )
6269 {
63- identifier = ( ) => Token . Print ( constructorDeclarationSyntax . Identifier , context ) ;
70+ identifier = static ( node , context ) =>
71+ {
72+ var constructorDeclarationSyntax = ( ConstructorDeclarationSyntax ) node ;
73+ return Token . Print ( constructorDeclarationSyntax . Identifier , context ) ;
74+ } ;
6475 constructorInitializer = constructorDeclarationSyntax . Initializer ;
6576 }
6677
@@ -71,7 +82,11 @@ public static Doc Print(CSharpSyntaxNode node, PrintingContext context)
7182 attributeLists = localFunctionStatementSyntax . AttributeLists ;
7283 modifiers = localFunctionStatementSyntax . Modifiers ;
7384 returnType = localFunctionStatementSyntax . ReturnType ;
74- identifier = ( ) => Token . Print ( localFunctionStatementSyntax . Identifier , context ) ;
85+ identifier = static ( node , context ) =>
86+ {
87+ var localFunctionStatementSyntax = ( LocalFunctionStatementSyntax ) node ;
88+ return Token . Print ( localFunctionStatementSyntax . Identifier , context ) ;
89+ } ;
7590 typeParameterList = localFunctionStatementSyntax . TypeParameterList ;
7691 parameterList = localFunctionStatementSyntax . ParameterList ;
7792 constraintClauses = localFunctionStatementSyntax . ConstraintClauses ;
@@ -163,7 +178,7 @@ void PrintMethodUnformattedWithoutAttributes(SyntaxTriviaList syntaxTriviaList)
163178
164179 if ( identifier != null )
165180 {
166- declarationGroup . Add ( identifier ( ) ) ;
181+ declarationGroup . Add ( identifier ( node , context ) ) ;
167182 }
168183
169184 if ( node is ConversionOperatorDeclarationSyntax conversionOperatorDeclarationSyntax )
0 commit comments