@@ -68,19 +68,19 @@ public static string GetName(this ISymbol symbol, bool useMetadataName = false)
68
68
return symbol . CanBeReferencedByName ? name : name . Substring ( symbol . Name . LastIndexOf ( '.' ) + 1 ) ;
69
69
}
70
70
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
+
71
77
/// <summary>
72
78
/// Gets the source-level modifiers belonging to this symbol, if any.
73
79
/// </summary>
74
80
public static IEnumerable < string > GetSourceLevelModifiers ( this ISymbol symbol )
75
81
{
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 ) ;
84
84
return methodModifiers . Concat ( typeModifers ) . Select ( m => m . Text ) ;
85
85
}
86
86
@@ -277,10 +277,8 @@ private static void BuildAssembly(IAssemblySymbol asm, EscapingTextWriter trapFi
277
277
trapFile . Write ( "::" ) ;
278
278
}
279
279
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 ) =>
282
281
BuildFunctionPointerSignature ( funptr , trapFile , s => s . BuildOrWriteId ( cx , trapFile , symbolBeingDefined ) ) ;
283
- }
284
282
285
283
private static void BuildNamedTypeId ( this INamedTypeSymbol named , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool constructUnderlyingTupleType )
286
284
{
@@ -456,10 +454,8 @@ public static void BuildFunctionPointerSignature(IFunctionPointerTypeSymbol funp
456
454
trapFile . Write ( '>' ) ;
457
455
}
458
456
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 ) =>
461
458
BuildFunctionPointerSignature ( funptr , trapFile , s => s . BuildDisplayName ( cx , trapFile ) ) ;
462
- }
463
459
464
460
private static void BuildNamedTypeDisplayName ( this INamedTypeSymbol namedType , Context cx , TextWriter trapFile , bool constructUnderlyingTupleType )
465
461
{
0 commit comments