Skip to content

Commit 775b3eb

Browse files
Merge pull request #339 from krishnprakash/alert-autofix-4
Potential fix for code scanning alert no. 4: Missed opportunity to use Where
2 parents 209c3eb + 39693eb commit 775b3eb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Populators/TypeContainerVisitor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public TypeContainerVisitor(Context cx, TextWriter trapFile, IEntity parent)
2525
attributeLookup = new Lazy<Func<SyntaxNode, AttributeData?>>(() =>
2626
{
2727
var dict = new Dictionary<SyntaxNode, AttributeData?>();
28-
foreach (var attributeData in cx.Compilation.Assembly.GetAttributes().Concat(cx.Compilation.Assembly.Modules.SelectMany(m => m.GetAttributes())))
28+
foreach (var attributeData in cx.Compilation.Assembly.GetAttributes().Concat(cx.Compilation.Assembly.Modules.SelectMany(m => m.GetAttributes())).Where(attributeData => attributeData.ApplicationSyntaxReference?.GetSyntax() is SyntaxNode syntax))
2929
{
30-
if (attributeData.ApplicationSyntaxReference?.GetSyntax() is SyntaxNode syntax)
31-
dict.Add(syntax, attributeData);
30+
var syntax = attributeData.ApplicationSyntaxReference?.GetSyntax() as SyntaxNode;
31+
dict.Add(syntax, attributeData);
3232
}
3333
return dict.GetValueOrDefault;
3434
});

0 commit comments

Comments
 (0)