Skip to content

Commit 3e0aacd

Browse files
committed
C#: Generalize modifier extraction from symbols.
1 parent ad8d9c5 commit 3e0aacd

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

csharp/extractor/Semmle.Extraction.CSharp/SymbolExtensions.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,8 @@ private static IEnumerable<SyntaxToken> GetModifiers<T>(this ISymbol symbol, Fun
7777
/// <summary>
7878
/// Gets the source-level modifiers belonging to this symbol, if any.
7979
/// </summary>
80-
public static IEnumerable<string> GetSourceLevelModifiers(this ISymbol symbol)
81-
{
82-
var methodModifiers = symbol.GetModifiers<Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax>(md => md.Modifiers);
83-
var typeModifiers = symbol.GetModifiers<Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax>(cd => cd.Modifiers);
84-
return methodModifiers.Concat(typeModifiers).Select(m => m.Text);
85-
}
80+
public static IEnumerable<string> GetSourceLevelModifiers(this ISymbol symbol) =>
81+
symbol.GetModifiers<Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax>(md => md.Modifiers).Select(m => m.Text);
8682

8783
/// <summary>
8884
/// Holds if the ID generated for `dependant` will contain a reference to

0 commit comments

Comments
 (0)