Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
New rule S2198: Silly mathematical comparisons should not be made #6695
New rule S2198: Silly mathematical comparisons should not be made #6695
Changes from 11 commits
e76d32a
93391b2
ececfa2
46f3d70
5bdd084
fee626d
36214a2
2983cc7
3374a35
3564d52
86696dc
99f3b27
ee45a5c
ba6589f
d463864
4f0720a
0070a96
e3b6f24
a84d441
4856e96
51d7b9c
f79b42a
083ae47
0980aa4
16c517c
a0fd1ce
339ac49
a8f25d7
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roslyn provides an API for naming things in the shortest possible way:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it, but for some reason it gives me the name of the entire node, for example
ulong variableName
.I ended up using this, which is also slightly more succinct:
It also works if you declare the type as
System.UInt64
, giving back the simplest form of the type (the primitiveulong
).Note: Included the
ulong
andlong
types, since they are not checked by theCS0652
compiler warning.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably called it on an
ILocalSymbol
which represents a local variable. You need it for the ITypeSymbol of the type of the expression. UsesemanticModel.GetTypeInfo(second)
and call ToDisplayString on it.