I am seeing inexplicable behaviour in Visual Studio’s search functionality, whereby a particular string is found when searching for some of its substrings but not others.
There are other similar questions on StackOverflow, but most resolutions seem to involve incorrect search settings (which I think is not the case here), historical bugs (allegedly fixed) or certain files not being searched at all (also not the case here as the ‘problem’ file does appear in some search results).
In each of four files, I have two #pragma directives for rule CA1711:
#pragma warning disable CA1711
// code line
#pragma warning restore CA1711
The details of the code are not important.
If I search for "17", "71" or "11", all eight instances are found:
If I search for "171", "711", "1711" or "CA1711", only six of the instances are found; one file (ReadOnlyDictionary.cs) is omitted completely from the results:
I have checked all the settings and can see nothing amiss:
It might be relevant that the number of files reported as searched is different (97 vs 101), possibly suggesting that some caching is at play. However, editing the ‘missing’ file, saving it and then repeating the search does not resolve the problem.
Additionally, if I search for a new substring (e.g. "e CA1711"), the results are still incorrect, despite the ‘problem’ file appearing normally in Solution Explorer and no relevant warnings being present.
Next things to try might include, say, restarting Visual Studio or deleting the solution’s .vs files. But then the logical conclusion would be that any time I want to perform a search (which is often), and I want to be able to rely on the results (which is always), I need to e.g. restart, which is obviously not tolerable.
This is very concerning as I rely upon Visual Studio’s search functionality on a regular basis. This problem could easily affect the integrity of my code bases, potentially with serious consequences.
Is this a known bug? Or has anyone seen similar behaviour?
Is there any way of clearing specific caches in Visual Studio to guarantee the validity of the search results?
I am using Visual Studio Professional 2022 (64-bit), v17.13.6.


