Skip to content

Commit 58406ea

Browse files
committed
Make sure we don't attempt to analyze methods without a symbol
Since we need a resolved invocation syntax to an actual symbol in order to determine if it's the service collection method we are looking for.
1 parent 71a87c3 commit 58406ea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/DependencyInjection/AddServicesAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static bool IsDDICode(SyntaxNode node, SemanticModel semantic)
5959
.OfType<InvocationExpressionSyntax>()
6060
.Select(invocation => new { Invocation = invocation, semantic.GetSymbolInfo(invocation, semanticContext.CancellationToken).Symbol })
6161
// It has to be user-provided code, not our own extensions/overloads.
62-
.Where(x => !IsDDICode(x.Invocation, semantic))
62+
.Where(x => !IsDDICode(x.Invocation, semantic) && x.Symbol != null)
6363
.Select(x => new { x.Invocation, Method = (IMethodSymbol)x.Symbol! });
6464

6565
bool IsServiceCollectionExtension(IMethodSymbol method) => method.IsExtensionMethod &&

0 commit comments

Comments
 (0)