Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyzers and fix for casting numeric literal values to enums #505

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

IanKemp
Copy link

@IanKemp IanKemp commented Feb 19, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants