C#: Also check the namespace of the InlineArrayAttribute.

This commit is contained in:
Michael Nebel
2024-01-17 16:20:47 +01:00
parent 674838e698
commit 70e7c92774

View File

@@ -527,7 +527,11 @@ namespace Semmle.Extraction.CSharp
public static bool IsInlineArray(this ITypeSymbol type)
{
var attributes = type.GetAttributes();
var isInline = attributes.Any(attribute => attribute.AttributeClass?.Name == "InlineArrayAttribute");
var isInline = attributes.Any(attribute =>
attribute.AttributeClass is INamedTypeSymbol nt &&
nt.Name == "InlineArrayAttribute" &&
nt.ContainingNamespace.ToString() == "System.Runtime.CompilerServices"
);
return isInline;
}