-
Notifications
You must be signed in to change notification settings - Fork 266
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
MSTEST0039
CodeFix adds redundant (& unexpected) Discard-Operators
#5112
Comments
Reasons for why this was added are in comment here: https://github.com/microsoft/testfx/blame/7d906dd55222ce529b7ca7dfc8ec8368608b846b/src/Analyzers/MSTest.Analyzers/UseNewerAssertThrowsAnalyzer.cs#L66-L72 @Youssef1313 maybe it would be valid to add the Func<object?> overload back to the new assertions so we avoid the need for the discard? Or was this analyzed and there was a reason why it should not be done? |
oh, ok. I guess just having a single From my little Testing, it seems only stuff like Field/Property-Access needs Discard. A method with return value works Just fine, ie: But I don't mind having discards per-se. |
The double discard is definitely something that can/should be fixed. For adding |
@nohwnd I opened an issue on Roslyn side to consider improving the codefix. Meanwhile, we may still consider adding the |
Gotcha saw it. I think it would not hurt to add the overload, it is in place on the old assertions, and it would lower the friction for users when moving from the older assertions. |
Sorry if that sounded like RTFM. That was not my intention, I was just documenting the reason why it is in place 🙂 |
Describe the bug
The CodeFix for
MSTEST0039
adds some additional Discards, even if one is already present.It also adds a Discard to an AssignmentOperation. Yes assignments do emit their value, but this (at least by us) is used rather rarely.
Steps To Reproduce
after fix all:
Expected behavior
Only add Discards where appropriate/excepted (?)
Actual behavior
Adds Discard to every Operation/Expression that emits some value. It ignores Discards already present
Additional context
Packages:
MsTest v3.8.2
The text was updated successfully, but these errors were encountered: