Skip to content

Commit

Permalink
Merge pull request #14792 from tamasvajk/standalone/assembly-attribute
Browse files Browse the repository at this point in the history
C#: Fix assembly attribute extraction in standalone mode
  • Loading branch information
tamasvajk authored Nov 16, 2023
2 parents 408ba51 + 7a001f4 commit 14268f3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ public override void VisitAttributeList(AttributeListSyntax node)
SyntaxKind.ModuleKeyword => Entities.AttributeKind.Module,
_ => throw new InternalError(node, "Unhandled global target")
};
foreach (var attribute in node.Attributes)
var attributes = node.Attributes;
for (var i = 0; i < attributes.Count; i++)
{
var attribute = attributes[i];
if (attributeLookup.Value(attribute) is AttributeData attributeData)
{
var ae = Entities.Attribute.Create(Cx, attributeData, outputAssembly, kind);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
| standalone.cs:3:12:3:29 | [assembly: Attribute1(...)] |
| standalone.cs:9:2:9:11 | [Attribute1(...)] |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import csharp

from Attribute a
where a.getType().getName() = "Attribute1Attribute"
select a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
semmle-extractor-options: --standalone
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

[assembly: global::Attribute1]

class Attribute1Attribute : Attribute
{
}

[Attribute1]
class A
{
}

0 comments on commit 14268f3

Please sign in to comment.