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

Implement analyzer and codefix to switch to Assert.ThrowsExactly[Async] #4459

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

Conversation

Youssef1313
Copy link
Member

Fixes #4257

}

[TestMethod]
public async Task WhenAssertThrowsExceptionFuncOverloadComplexBody_Diagnostic()
Copy link
Member Author

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 😄

@Youssef1313 Youssef1313 requested a review from Copilot December 30, 2024 05:13

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
Evangelink
Evangelink previously approved these changes Dec 31, 2024
@@ -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>
Copy link
Member

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?

Copy link
Member Author

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)

Comment on lines +114 to +116
// 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.
Copy link
Member

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.

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.

Add relaxed versions of Assert.ThrowsException and Assert.ThrowsExceptionAsync
2 participants