@@ -68,19 +68,19 @@ public static string GetName(this ISymbol symbol, bool useMetadataName = false)
6868 return symbol . CanBeReferencedByName ? name : name . Substring ( symbol . Name . LastIndexOf ( '.' ) + 1 ) ;
6969 }
7070
71+ private static IEnumerable < SyntaxToken > GetModifiers < T > ( this ISymbol symbol , Func < T , IEnumerable < SyntaxToken > > getModifierTokens ) =>
72+ symbol . DeclaringSyntaxReferences
73+ . Select ( r => r . GetSyntax ( ) )
74+ . OfType < T > ( )
75+ . SelectMany ( getModifierTokens ) ;
76+
7177 /// <summary>
7278 /// Gets the source-level modifiers belonging to this symbol, if any.
7379 /// </summary>
7480 public static IEnumerable < string > GetSourceLevelModifiers ( this ISymbol symbol )
7581 {
76- var methodModifiers = symbol . DeclaringSyntaxReferences
77- . Select ( r => r . GetSyntax ( ) )
78- . OfType < Microsoft . CodeAnalysis . CSharp . Syntax . BaseMethodDeclarationSyntax > ( )
79- . SelectMany ( md => md . Modifiers ) ;
80- var typeModifers = symbol . DeclaringSyntaxReferences
81- . Select ( r => r . GetSyntax ( ) )
82- . OfType < Microsoft . CodeAnalysis . CSharp . Syntax . TypeDeclarationSyntax > ( )
83- . SelectMany ( cd => cd . Modifiers ) ;
82+ var methodModifiers = symbol . GetModifiers < Microsoft . CodeAnalysis . CSharp . Syntax . BaseMethodDeclarationSyntax > ( md => md . Modifiers ) ;
83+ var typeModifers = symbol . GetModifiers < Microsoft . CodeAnalysis . CSharp . Syntax . TypeDeclarationSyntax > ( cd => cd . Modifiers ) ;
8484 return methodModifiers . Concat ( typeModifers ) . Select ( m => m . Text ) ;
8585 }
8686
@@ -277,10 +277,8 @@ private static void BuildAssembly(IAssemblySymbol asm, EscapingTextWriter trapFi
277277 trapFile . Write ( "::" ) ;
278278 }
279279
280- private static void BuildFunctionPointerTypeId ( this IFunctionPointerTypeSymbol funptr , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined )
281- {
280+ private static void BuildFunctionPointerTypeId ( this IFunctionPointerTypeSymbol funptr , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined ) =>
282281 BuildFunctionPointerSignature ( funptr , trapFile , s => s . BuildOrWriteId ( cx , trapFile , symbolBeingDefined ) ) ;
283- }
284282
285283 private static void BuildNamedTypeId ( this INamedTypeSymbol named , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool constructUnderlyingTupleType )
286284 {
@@ -456,10 +454,8 @@ public static void BuildFunctionPointerSignature(IFunctionPointerTypeSymbol funp
456454 trapFile . Write ( '>' ) ;
457455 }
458456
459- private static void BuildFunctionPointerTypeDisplayName ( this IFunctionPointerTypeSymbol funptr , Context cx , TextWriter trapFile )
460- {
457+ private static void BuildFunctionPointerTypeDisplayName ( this IFunctionPointerTypeSymbol funptr , Context cx , TextWriter trapFile ) =>
461458 BuildFunctionPointerSignature ( funptr , trapFile , s => s . BuildDisplayName ( cx , trapFile ) ) ;
462- }
463459
464460 private static void BuildNamedTypeDisplayName ( this INamedTypeSymbol namedType , Context cx , TextWriter trapFile , bool constructUnderlyingTupleType )
465461 {
0 commit comments