-
Notifications
You must be signed in to change notification settings - Fork 33
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
Support classic StringAssert in ConstActualValueUsage analyzer and code fix #453
Support classic StringAssert in ConstActualValueUsage analyzer and code fix #453
Conversation
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.
Thanks @eatdrinksleepcode for your contribution.
Your additions are neat and clean.
I added one remark about the use of the 'includeClassic' field.
70f38bc
to
89bec5f
Compare
89bec5f
to
f32db4d
Compare
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.
Thanks, looks good to me.
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.
Look good to me. Thanks for the contribution @eatdrinksleepcode and thanks for the review @manfred-brands 👍 . I'll just add one minor correction and then merge the PR
This adds support for
StringAssert
toConstActualValueUsageAnalyzer
andConstActualValueUsageCodeFix
.The analyzers already support "classic" assertions in many places, but only ones that are defined on
Assert
. I have an existing codebase that frequently usesStringAssert
and the other classic Assert classes, and I recently found a case where aStringAssert.Contains
call started failing incorrectly after a refactoring because the arguments were reversed. I have tested that this change correctly flags that case.This change is narrowly focused on
StringAssert
andConstActualValueUsage
; but if the general approach is acceptable, I can add more classic Asserts to more analyzers. I am probably going to do it anyway to use on my own code.Also, I noticed that the existing code fix only supports the classic assertions specifically related to equality; but I saw no reason not to support all of the asserts on
StringAssert
, as they all follow the same format.