Skip to content

Improve doc for MSTEST0049 and TestContext#52468

Open
Evangelink wants to merge 2 commits intomainfrom
dev/amauryleve/mstest0049
Open

Improve doc for MSTEST0049 and TestContext#52468
Evangelink wants to merge 2 commits intomainfrom
dev/amauryleve/mstest0049

Conversation

@Evangelink
Copy link
Member

@Evangelink Evangelink commented Mar 19, 2026

Give example on how to use the cancellation token
Copilot AI review requested due to automatic review settings March 19, 2026 08:11
@dotnetrepoman dotnetrepoman bot added this to the March 2026 milestone Mar 19, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the MSTest documentation to include concrete examples of flowing TestContext.CancellationToken in async tests, addressing MSTEST0049 guidance and improving discoverability from the TestContext article.

Changes:

  • Add a Cancellation token section to the TestContext documentation, including snippet references for property-based access and constructor injection.
  • Expand the MSTEST0049 analyzer page with before/after examples and suppression guidance.
  • Add new C# snippet files and a snippet project to support the new documentation examples.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
docs/core/testing/unit-testing-mstest-writing-tests-testcontext.md Adds a new section describing TestContext.CancellationToken and links to new snippets.
docs/core/testing/mstest-analyzers/mstest0049.md Adds new examples demonstrating MSTEST0049 triggers and fixes, plus suppression instructions.
docs/core/testing/snippets/testcontext/csharp-cancellation/project.csproj Introduces a new snippet project for the cancellation-token examples.
docs/core/testing/snippets/testcontext/csharp-cancellation/CancellationToken.cs Adds a property-based TestContext.CancellationToken example.
docs/core/testing/snippets/testcontext/csharp-cancellation/CancellationTokenCtor.cs Adds a constructor-injection example for accessing TestContext.CancellationToken.

You can also share your feedback on Copilot code review. Take the survey.

@Evangelink Evangelink enabled auto-merge (squash) March 19, 2026 08:24
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.

Missing example for async tests with TestContext.CancellationToken

4 participants