roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

Analyzers and fix for casting numeric literal values to enums

Open IanKemp opened this issue 6 years ago • 0 comments
trafficstars

Introduces two new analyzers:

  • RCS1235 that detects and notifies when an enum is being cast from a numeric value, instead of referencing the corresponding enum field
  • RCS1236 that detects and warns when an enum is being cast from a numeric value that doesn't exist in the enum

and a codefix and refactoring for RCS1235.

This is not my first time playing with Roslyn and syntax trees, but it is my first time doing it "seriously" in the hopes that the result will be useful to others, so please be gentle. In particular, I'm not sure what the best/correct diagnostic category to use is, and of course I'm sure there are more efficient/more correct ways to achieve what I want to do.

IanKemp avatar Feb 19 '19 09:02 IanKemp