Document MSTest analyzers MSTEST0051-MSTEST0055 #48813
Merged
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.
Summary
This PR adds comprehensive documentation for five new MSTest analyzer rules (MSTEST0051 through MSTEST0055) that were introduced in MSTest 3.10.0.
Changes
New Documentation Files
Created documentation for the following analyzers:
MSTEST0051: Assert.Throws should contain a single statement
Assert.Throws
,Assert.ThrowsAsync
,Assert.ThrowsExactly
, andAssert.ThrowsExactlyAsync
methods contain exactly one statement in the action delegate to avoid ambiguous test resultsMSTEST0052: Prefer DynamicDataSourceType.AutoDetect
DynamicDataSourceType.AutoDetect
(introduced in MSTest 3.8) instead of explicitly specifyingProperty
orMethod
for better maintainabilityMSTEST0053: Avoid Assert method format parameters
MSTEST0054: Use cancellation token from TestContext.CancellationToken
TestContext.CancellationToken
property instead of creating separate cancellation tokens to ensure proper integration with test timeouts and cooperative cancellationMSTEST0055: String method return value should not be ignored
ToUpper()
,ToLower()
,Trim()
,Replace()
, orSubstring()
are called without using their return values, which is always a bug due to string immutabilityUpdated Files
ms.date
to reflect the latest changesDocumentation Standards
All documentation files follow the established patterns:
ai-usage: ai-generated
disclosureReferences
The implementations for these analyzers were added in the following PRs:
TestContext.CancellationTokenSource.Token
toTestContext.CancellationToken
microsoft/testfx#6429Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Internal previews