-
Notifications
You must be signed in to change notification settings - Fork 262
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
Implement analyzer and codefix to switch to Assert.ThrowsExactly[Async] #4459
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
[TestMethod] | ||
public async Task WhenAssertThrowsExceptionFuncOverloadComplexBody_Diagnostic() |
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 hope no one is calling Assert.ThrowsException this 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.
Copilot reviewed 20 out of 36 changed files in this pull request and generated no comments.
Files not reviewed (16)
- src/Analyzers/MSTest.Analyzers.CodeFixes/CodeFixResources.Designer.cs: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/CodeFixResources.resx: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.cs.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.de.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.es.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.fr.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.it.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.ja.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.ko.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.pl.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.pt-BR.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.ru.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.tr.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.zh-Hans.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers.CodeFixes/xlf/CodeFixResources.zh-Hant.xlf: Language not supported
- src/Analyzers/MSTest.Analyzers/Resources.Designer.cs: Language not supported
src/Analyzers/MSTest.Analyzers.CodeFixes/UseNewerAssertThrowsFixer.cs
Outdated
Show resolved
Hide resolved
@@ -543,4 +543,10 @@ The type declaring these methods should also respect the following rules: | |||
<data name="DynamicDataShouldBeValidMessageFormat_SourceTypeNotPropertyOrMethod" xml:space="preserve"> | |||
<value>'[DynamicData]' member '{0}.{1}' is not a property nor a method. Only properties and methods are supported.</value> | |||
</data> | |||
</root> | |||
<data name="UseNewerAssertThrowsTitle" xml:space="preserve"> | |||
<value>Use newer methods to assert exceptions</value> |
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 don't recall, do we see title on the menu or message?
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 think the message. Not sure of all places that show the title, but Solution Explorer is one that shows the title (when you expand Dependencies -> Analyzers)
// NOTE: The discard is needed to avoid CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement | ||
// This is because ThrowsException has a Func<object> overload that is being used in the original code. | ||
// But ThrowsExactly only has an Action overload. |
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.
Interesting, I'll try to have a look at this specific API and see if there is any need to have it on the newer APIs.
Fixes #4257