Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allow not finding attribute data for more cases that we don't care about
This will fix the upstream repo intake of dotnet/runtime by allowing us to fall back to null for cases where Roslyn does things that we aren't expecting with the "ContainingSymbol" value.
  • Loading branch information
jkoritzinsky authored Jul 21, 2022
commit 5b7e2ed24112ca47b817015aeabbd1b448102cd0
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public static Location FindTypeExpressionOrNullLocation(this AttributeArgumentSy
return null;
}
}
return targetSymbol.GetAttributes().First(attributeSyntaxLocationMatches);
// Sometimes an attribute is put on a symbol that is nested within the containing symbol.
// For example, the ContainingSymbol for an AttributeSyntax on a parameter have a ContainingSymbol of the method.
// Since this method is internal and the callers don't care about attributes on parameters, we just allow
// this method to return null in those cases.
return targetSymbol.GetAttributes().FirstOrDefault(attributeSyntaxLocationMatches);

bool attributeSyntaxLocationMatches(AttributeData attrData)
{
Expand Down