Improve doc for MSTEST0049 and TestContext#52468
Open
Evangelink wants to merge 2 commits intomainfrom
Open
Conversation
Give example on how to use the cancellation token
Contributor
There was a problem hiding this comment.
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
TestContextdocumentation, 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.
docs/core/testing/snippets/testcontext/csharp-cancellation/project.csproj
Outdated
Show resolved
Hide resolved
docs/core/testing/snippets/testcontext/csharp-cancellation/CancellationToken.cs
Show resolved
Hide resolved
YuliiaKovalova
approved these changes
Mar 19, 2026
Youssef1313
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Give example on how to use the cancellation token
Fixes #52340 and relates to #52341
Internal previews