Analyzer to prefer equality operator over object.equals calls for enums #41567
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-System.Runtime
code-analyzer
Marks an issue that suggests a Roslyn analyzer
Milestone
Enums shoud always be compared by using == when testing for equality. In Xamarin.Essentials I saw the use of .Equals calls to compare enums for equality, which does the same but incurs a box for enums. A roslyn analyzer can easily detect calls to object.Equals calls where the argument is an enum. I already have a working implementation of this analyzer if this is a desirable feature.
The text was updated successfully, but these errors were encountered: