FindBackgroundReferencesInFile
on Active Pattern Case finds all other Cases too
#14206
Labels
Area-LangService-FindAllReferences
Find all references across projects and solutions
Bug
Impact-Medium
(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
"Find All References" in Visual Studio (and Ionide) on an Active Pattern Case sometimes not just finds current case, but all other cases too:
-> "Find All References" on
Even
-- but findsOdd
tooBut this isn't always the case:
Here VS correctly finds just
Even
occurrences.Difference: First one is a fs file inside a Project, second one is a Script file (even one not saved on disk)
Also an issue for Renaming:
Instead of just renaming
Even
,Odd
gets renamed at same time (to same name)Side Note:
Images above show a presentation error too:
let |Even|Odd|(|Even|Odd|) v =
instead oflet (|Even|Odd|) v =
Link location (click on result) works fine
The difference in behaviour can be explained by looking at FindUsagesService:
fsharp/vsintegration/src/FSharp.Editor/Navigation/FindUsagesService.fs
Lines 103 to 126 in d13df68
-> different lookup methods depending on local to current doc or public:
checkFileResults.GetUsesOfSymbolInFile
SymbolHelpers.getSymbolUsesInProjects
which boils down tochecker.FindBackgroundReferencesInFile
(actual call)(Ionide uses same functions for same scopes -> explains same behavior as in VS)
So it seems
FSharpCheckFileResults.GetUsesOfSymbolInFile
andFSharpChecker.FindBackgroundReferencesInFile
return different results for Active Pattern Cases -- withFSharpChecker.FindBackgroundReferencesInFile
being wrongRepro steps
(Test Script)
Tests find usages on last
Even
in:Output:
uses
:GetUsesOfSymbolInFile
refs
:FindBackgroundReferencesInFile
Ok
when 3 occurrences found, otherwiseError
-> tests prove: Different results for
GetUsesOfSymbolInFile
andFindBackgroundReferencesInFile
and wrong results forFindBackgroundReferencesInFile
Expected behavior
FindBackgroundReferencesInFile
should only return locations of search Active Pattern Case.Actual behavior
FindBackgroundReferencesInFile
returns locations of other Cases tooKnown workarounds
Use
GetUsesOfSymbolInFile
instead ofFindBackgroundReferencesInFile
Related information
dotnet --version
:6.0.402
,7.0.100-rc.2.22477.23
41.0.5
,41.0.6
,42.7.100-preview.22473.1
The text was updated successfully, but these errors were encountered: