Add DiagnosticId to warning-level [Obsolete] attributes#8194
Add DiagnosticId to warning-level [Obsolete] attributes#8194Evangelink wants to merge 2 commits into
Conversation
Add specific diagnostic identifiers to all warning-level [Obsolete] attributes that previously relied on the default CS0618 warning. This enables downstream users to selectively suppress specific deprecation warnings using #pragma warning disable or project-level <NoWarn>. Diagnostic ID scheme: - MSTEST0100-0105: Assert/StringAssert/CollectionAssert Equals/ReferenceEquals - MSTEST0106: MSTestExecutor.RunTests (use RunTestsAsync) - MTP0001: CancelledTestNodeStateProperty - MTP0002: TestApplication.CreateServerModeBuilderAsync The DiagnosticId and UrlFormat properties are guarded with #if NET8_0_OR_GREATER since they are not available on netstandard2.0/net462.
There was a problem hiding this comment.
Pull request overview
This PR adds custom diagnostic IDs and help URLs to obsolete MSTest and Microsoft.Testing.Platform APIs where supported by newer target frameworks, enabling more targeted downstream suppression and diagnostics.
Changes:
- Adds
DiagnosticId/UrlFormatto warning-level obsolete MSTest assertion APIs and adapterRunTestsoverloads underNET8_0_OR_GREATER. - Adds MTP-specific obsolete diagnostic IDs for deprecated platform APIs.
- Preserves existing obsolete attributes for older target frameworks.
Show a summary per file
| File | Description |
|---|---|
src/TestFramework/TestFramework/Assertions/StringAssert.cs |
Adds MSTEST obsolete diagnostic IDs for Equals and ReferenceEquals. |
src/TestFramework/TestFramework/Assertions/CollectionAssert.cs |
Adds MSTEST obsolete diagnostic IDs for collection assertion blocked APIs. |
src/TestFramework/TestFramework/Assertions/Assert.cs |
Adds MSTEST obsolete diagnostic IDs for base assertion blocked APIs. |
src/Platform/Microsoft.Testing.Platform/Messages/TestNodeStateProperties.cs |
Adds MTP obsolete diagnostic metadata for cancelled test node state property. |
src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs |
Adds MTP obsolete diagnostic metadata for server mode builder creation API. |
src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestExecutor.cs |
Adds MSTEST obsolete diagnostic metadata for sync RunTests adapter overloads. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 0
Review: Add DiagnosticId to warning-level [Obsolete] attributes🟡 MAJOR — Source-compatibility break for
|
Evangelink
left a comment
There was a problem hiding this comment.
Code review complete. One MAJOR source-compatibility concern (CS0619 suppressions breaking on NET8_0_OR_GREATER builds) and one NIT (UrlFormat convention inconsistency). No blocking issues. All other dimensions LGTM.
Generated by Expert Code Review (on open) for issue #8194 · ● 12.4M
Update all #pragma warning disable/restore CS0618 at CancelledTestNodeStateProperty
call sites to also suppress MTP0001 (the new diagnostic ID on NET8_0_OR_GREATER).
Also unify UrlFormat to use {0} placeholder across all MSTEST Obsolete attributes,
matching the MTP convention and the SYSLIB pattern.
Summary
Add specific
DiagnosticId(andUrlFormat) to all warning-level[Obsolete]attributes that previously relied on the defaultCS0618warning. This enables downstream users to selectively suppress specific deprecation warnings using#pragma warning disable MSTEST0XXXor project-level<NoWarn>, following the pattern established bySYSLIB0051.Diagnostic ID scheme
MSTEST0100Assert.EqualsMSTEST0101Assert.ReferenceEqualsMSTEST0102StringAssert.EqualsMSTEST0103StringAssert.ReferenceEqualsMSTEST0104CollectionAssert.EqualsMSTEST0105CollectionAssert.ReferenceEqualsMSTEST0106MSTestExecutor.RunTestsRunTestsAsyncinsteadMTP0001CancelledTestNodeStatePropertyOperationCanceledExceptioninsteadMTP0002TestApplication.CreateServerModeBuilderAsyncCreateBuilderAsyncinsteadNotes
DiagnosticIdandUrlFormatproperties onObsoleteAttributerequire .NET 5+, so they are guarded with#if NET8_0_OR_GREATER(the minimum .NET Core TFM in this repo). Onnetstandard2.0andnet462, the attributes remain unchanged.MSTEST0100+range is deliberately separated from the analyzer rule IDs (MSTEST0001–MSTEST0063) to avoid confusion.MSTestExecutor.RunTestsoverloads shareMSTEST0106since they are deprecated for the same reason.MTP0001/MTP0002prefix distinguishes Microsoft.Testing.Platform deprecations from MSTest deprecations.