@@ -109,6 +109,13 @@ private void AnalyzeMethodDependencies(Solution solution, CodeElement methodElem
109
109
AddTypeDependency ( methodElement , methodSymbol . ReturnType , DependencyType . Uses ) ;
110
110
}
111
111
112
+ //if (methodSymbol.IsExtensionMethod)
113
+ //{
114
+ // // The first parameter of an extension method is the extended type
115
+ // var extendedType = methodSymbol.Parameters[0].Type;
116
+ // AddTypeDependency(methodElement, extendedType, DependencyType.Uses);
117
+ //}
118
+
112
119
// If this method is an interface method or an abstract method, find its implementations
113
120
if ( methodSymbol . IsAbstract || methodSymbol . ContainingType . TypeKind == TypeKind . Interface )
114
121
{
@@ -300,11 +307,16 @@ private void AddEventUsageDependency(CodeElement sourceElement, IEventSymbol eve
300
307
}
301
308
}
302
309
303
-
304
310
private void AddCallsDependency ( CodeElement sourceElement , IMethodSymbol methodSymbol , SourceLocation location )
305
311
{
306
312
//Trace.WriteLine($"Adding call dependency: {sourceElement.Name} -> {methodSymbol.Name}");
307
313
314
+ if ( methodSymbol . IsExtensionMethod )
315
+ {
316
+ // Handle calls to extension methods
317
+ methodSymbol = methodSymbol . ReducedFrom ?? methodSymbol ;
318
+ }
319
+
308
320
if ( _symbolKeyToElementMap . TryGetValue ( GetSymbolKey ( methodSymbol ) , out var targetElement ) )
309
321
{
310
322
AddDependency ( sourceElement , DependencyType . Calls , targetElement , [ location ] ) ;
@@ -414,6 +426,8 @@ private void AddExternalDependency(CodeElement sourceElement, ITypeSymbol typeSy
414
426
private void AnalyzeExpressionBody ( CodeElement sourceElement , ArrowExpressionClauseSyntax expressionBody ,
415
427
SemanticModel semanticModel )
416
428
{
429
+ // TODO atr. Can we just call AnalyzeMethodBody?
430
+ // The InvocationExpressionSyntax handles more cases here. But all other methods are also handled in AnalyzeMethodBody
417
431
AnalyzeExpression ( sourceElement , expressionBody . Expression , semanticModel ) ;
418
432
}
419
433
0 commit comments