Skip to content

Commit ca94e02

Browse files
authored
Merge pull request github#12258 from michaelnebel/csharp/enumanddelegatemodfiers
C#: Generalise modifier extraction from symbols.
2 parents 8ed99bc + b4a6d1e commit ca94e02

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-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
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The extraction of member modifiers has been generalised, which could lead to the extraction of more modifiers.

0 commit comments

Comments
 (0)