VB.Net/Visual Studio - Find all uses of string equality operator

Viewed 47

Language: VB.Net

Visual Studio Version: 15.9.35

.Net Framework Version: 4.8.04084

I recently came across an error in an application I'm maintaining: one line of code uses the equality operator = to compare two strings and the code failed when one string was in titlecase and one in lowercase (as should have been expected; Option Compare Binary is on by default). I am now concerned that there may be other cases in the code (something like 15,000 lines) where this may be an issue and I would like to find all uses of = to compare two string values. Searching for all occurrences of = is less than ideal (I know I'll miss some if I try to inspect every single use of = visually), and I don't want to switch the Option Compare to Text if I can avoid it, in case there are instances where case-sensitivity is desired, so what I'm looking for is a way of locating all uses of = to compare (not assign) strings and only strings.

Is there a way of doing this in Visual Studio? To be frank I wouldn't expect there to be as I can't see it making the must-do list of features. If not, is there some other way I can search for these instances? I could write an application to search for all strings and then look for if statements that use the = sign for equality but I'm pressed for time so I would prefer to use a tried and tested alternative.

Any help or suggestions (even a frame challenge if I've missed something fundamental) would be very much appreciated.

Thank you.

0 Answers
Related