@@ -47,20 +47,34 @@ protected sealed override Task DetermineDocumentsToSearchAsync<TData>(
4747 FindReferencesSearchOptions options ,
4848 CancellationToken cancellationToken )
4949 {
50- // Type parameters are only found in documents that have both their name, and the name
51- // of its owning method. NOTE(cyrusn): We have to check in multiple files because of
52- // partial types. A type parameter can be referenced across all the parts. NOTE(cyrusn):
53- // We look for type parameters by name. This means if the same type parameter has a
54- // different name in different parts that we won't find it. However, this only happens
55- // in error situations. It is not legal in C# to use a different name for a type
56- // parameter in different parts.
50+ // Type parameters are only found in documents that have both their name, and the name of its owning method.
51+ // NOTE(cyrusn): We have to check in multiple files because of partial types. A type parameter can be
52+ // referenced across all the parts. NOTE(cyrusn): We look for type parameters by name. This means if the same
53+ // type parameter has a different name in different parts that we won't find it. However, this only happens in
54+ // error situations. It is not legal in C# to use a different name for a type parameter in different parts.
5755 //
58- // Also, we only look for files that have the name of the owning type. This helps filter
59- // down the set considerably.
56+ // Also, we only look for files that have the name of the owning type. This helps filter down the set
57+ // considerably. Note: we don't do this for top level local functions as they obviously appear only in one
58+ // document, and their containing type name ("Program") doesn't have to appear there at all.
59+
6060 Contract . ThrowIfNull ( symbol . DeclaringMethod ) ;
61- return FindDocumentsAsync ( project , documents , processResult , processResultData , cancellationToken , symbol . Name ,
62- GetMemberNameWithoutInterfaceName ( symbol . DeclaringMethod . Name ) ,
63- symbol . DeclaringMethod . ContainingType . Name ) ;
61+ if ( symbol is
62+ {
63+ ContainingSymbol : IMethodSymbol { MethodKind : MethodKind . LocalFunction } ,
64+ ContainingType : INamedTypeSymbol { Name : "Program" , ContainingNamespace . IsGlobalNamespace : true }
65+ } )
66+ {
67+ return FindDocumentsAsync ( project , documents , processResult , processResultData , cancellationToken ,
68+ symbol . Name ,
69+ GetMemberNameWithoutInterfaceName ( symbol . DeclaringMethod . Name ) ) ;
70+ }
71+ else
72+ {
73+ return FindDocumentsAsync ( project , documents , processResult , processResultData , cancellationToken ,
74+ symbol . Name ,
75+ GetMemberNameWithoutInterfaceName ( symbol . DeclaringMethod . Name ) ,
76+ symbol . DeclaringMethod . ContainingType . Name ) ;
77+ }
6478 }
6579
6680 private static string GetMemberNameWithoutInterfaceName ( string fullName )
0 commit comments