Skip to content

Commit ba270e2

Browse files
committed
Fix RDG suppressor
1 parent 787730f commit ba270e2

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/Http/Http.Extensions/gen/RequestDelegateGeneratorSuppressor.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,23 @@ public override void ReportSuppressions(SuppressionAnalysisContext context)
4646
? diagnostic.AdditionalLocations[0]
4747
: diagnostic.Location;
4848

49-
if (location.SourceTree is not { } sourceTree
50-
|| sourceTree.GetRoot().FindNode(location.SourceSpan) is not InvocationExpressionSyntax node
51-
|| !node.TryGetMapMethodName(out var method)
52-
|| !InvocationOperationExtensions.KnownMethods.Contains(method))
49+
if (location.SourceTree is not { } sourceTree)
50+
{
51+
continue;
52+
}
53+
54+
// The trim analyzer changed from warning on the InvocationExpression to the MemberAccessExpression in https://github.com/dotnet/runtime/pull/110086.
55+
// To account for this, we need to check if the location is an InvocationExpression or a child of an InvocationExpression.
56+
var node = sourceTree.GetRoot().FindNode(location.SourceSpan) switch
57+
{
58+
InvocationExpressionSyntax s => s,
59+
{ Parent: InvocationExpressionSyntax s } => s,
60+
_ => null,
61+
};
62+
63+
if (node is null ||
64+
!node.TryGetMapMethodName(out var method) ||
65+
!InvocationOperationExtensions.KnownMethods.Contains(method))
5366
{
5467
continue;
5568
}

0 commit comments

Comments
 (0)