/net10-upgrade:migrate-mstest-v3-to-v4from net10-upgrade
Use this skill before answering, planning, or editing any MSTest 3.x-to-4.x upgrade or post-upgrade failure. Triggers include "MSTest v4 breaking changes"; CS0507/CS0103/CS1061/CS1615; ExecuteAsync, CallerInfo, DisplayName, or custom TestMethodAttribute; ClassCleanupBehavior; ContainsKey; ThrowsExactly or ExpectedException; IsInstanceOfType out parameters; TestTimeout.Infinite; removed TestContext properties; ITestMethod changes; StringAssert overloads; MSTEST0056/MSTEST0057; renamed assemblies or executor URI; net6/net7 compatibility; TestCase.Id history; TestName in ClassInitialize; TreatDiscoveryWarningsAsErrors; ReflectionTypeLoadException during discovery; inherited test attributes; custom data-source display names; and MSTest.Sdk/MTP or vstest.console discovery changes. Do not use for v1/v2-to-v3 leftovers, framework conversion, runner-only migration, or a general .NET upgrade.
Ships in net10-upgrade. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Migrate a test project from MSTest v3 to MSTest v4. The outcome is a project using MSTest v4 that builds cleanly, passes tests, and accounts for every source-incompatible and behavioral change. MSTest v4 is not binary compatible with MSTest v3 -- any library compiled against v3 must be recompiled against v4.
Inspect the supplied project and source before searching the web or answering
from memory. Classify the request as a focused source fix, runtime behavior
change, CI discovery issue, compatibility question, or full migration, then
follow the matching row below. A clean compile does not exclude this skill:
discovery failures, TestContext lifecycle exceptions, and test-history
changes are runtime migration failures.
MSTest.TestFramework, MSTest.TestAdapter, or MSTest metapackage from 3.x to 4.xMSTest.Sdk from 3.x to 4.xTestMethodAttribute or ConditionBaseAttribute implementations for v4migrate-mstest-v1v2-to-v3 first, then return here| Input | Required | Description |
|---|---|---|
| Project or solution path | No | The .csproj, .sln, or .slnx entry point containing MSTest test projects. Discover it yourself by globbing the working directory; ask only when nothing is found or the choice is genuinely ambiguous |
| Build command | No | How to build (e.g., dotnet build, a repo build script). Auto-detect if not provided |
| Test command | No | How to run tests (e.g., dotnet test). Auto-detect if not provided |
| Detected request or state | Required action |
|---|---|
| Files are supplied in the current workspace | Search there and open the literal returned paths. The skill directory is not the project directory. If one tool rejects a valid path, retry with another available reader/editor; do not ask the user for a path you can discover. |
| User asks to apply changes to supplied files: "fix my project/files", "please update this source", "make the changes", or "then build and run" | Edit every affected occurrence. Run the narrowest meaningful build/test command against the actual package version; skill activation is not a reason to stop at advice. |
| User asks "what should I expect?", "how do I fix these changes?", for compatibility advice, or for a plan | Answer directly from the actual project state even when source is visible. Keep a single-symptom answer focused; include only adjacent risks that change the decision. |
| Unsupported TFM in a full migration | Update the TFM first, then update MSTest packages, then fix source breaks. Do not bury this order in a release-note inventory. |
Custom TestMethodAttribute subclass | Treat ExecuteAsync, CallerInfo propagation, display-name handling, and the subclass's retry/result semantics as one coupled migration. Fix the actual class, not a placeholder example. |
MSTest.Sdk v4 source/API errors (ManagedType, TestTimeout, Contains) | Give the exact source replacements, then add the adjacent runner warning: MTP mode no longer supplies Microsoft.NET.Test.Sdk; add it only if VSTest discovery is still required. |
MSTest.Sdk v4 plus vstest.console | MTP mode no longer includes Microsoft.NET.Test.Sdk in v4. Add it to retain transitional VSTest discovery while keeping MTP, opt into UseVSTest, or migrate CI to dotnet test. Native MTP requires every project/TFM governed by global.json to support it (4.5). |
MSTest.Sdk, explain whether losing the Microsoft.NET.Test.Sdk reference affects the visible runner. Skip the full migration workflow.TestMethodAttribute constructor issues, include MSTEST0056 for display-name arguments and MSTEST0057 for custom attributes that fail to propagate caller info.MSTest.Sdk v4 plus failing vstest.console discovery, explain the missing Microsoft.NET.Test.Sdk reference (4.5) and all three paths: add it while preserving MTP, set UseVSTest, or switch CI to MTP-native dotnet test. Skip the full migration workflow.Commit strategy: Do not create commits unless the user asks. Keep package, source, and behavioral changes logically separable in the diff, but finish and verify the requested migration.
MSTest, MSTest.TestFramework, MSTest.TestAdapter, or MSTest.Sdk in .csproj, Directory.Build.props, or Directory.Packages.props.migrate-mstest-v1v2-to-v3 first.TestMethodAttribute subclasses and uses of DataTestMethodAttribute, STATestMethodAttribute, and UITestMethodAttribute constructors -- these require changes in v4.ExpectedExceptionAttribute -- removed in v4 (deprecated since v3 with analyzer MSTEST0006).Assert.ThrowsException (deprecated) -- removed in v4.TestContext properties, changed ITestMethod members, removed cleanup settings, and custom data-source interfaces or overrides listed in Step 3.netstandard2.0 asset.First resolve the latest stable v4 version from the configured package source. Pin that exact
version consistently in the metapackage, individual packages, MSTest.Sdk, and central package
management.
MSTest metapackage, update its PackageReference to the resolved exact version.MSTest.TestFramework and MSTest.TestAdapter to that same version.MSTest.Sdk, update the SDK version in the project or global.json pin to that same version.Run dotnet restore, then dotnet build. Collect all errors for Step 3.
Work through compilation errors systematically. Use this quick-lookup table to identify all applicable changes, then apply each fix:
| Error / Pattern in code | Breaking change | Fix |
|---|---|---|
Custom TestMethodAttribute overrides Execute | Execute removed | Change to ExecuteAsync returning Task<TestResult[]> (3.1) |
[TestMethod("name")] or custom attribute constructor | CallerInfo params added | Use DisplayName = "name" named param; propagate CallerInfo in subclasses (3.2) |
ClassCleanupBehavior.EndOfClass | Enum removed | Remove argument: just [ClassCleanup] (3.3) |
TestContext.Properties.Contains("key") | Properties is IDictionary<string, object> | Change to ContainsKey("key") (3.4) |
[Timeout(TestTimeout.Infinite)] | TestTimeout enum removed | Replace with [Timeout(int.MaxValue)] (3.5) |
TestContext.ManagedType | Property removed | Use FullyQualifiedTestClassName (3.6) |
Assert.AreEqual(a, b, "msg {0}", arg) | Message+params overloads removed | Use string interpolation: $"msg {arg}" (3.7) |
Assert.ThrowsException<T>(...) | Renamed | Replace with Assert.ThrowsExactly<T>(...) or Assert.Throws<T>(...) (3.7) |
Assert.IsInstanceOfType<T>(obj, out var t) | Out parameter removed | Use var t = Assert.IsInstanceOfType<T>(obj) (3.7) |
[ExpectedException(typeof(T))] | Attribute removed | Move assertion into test body: Assert.ThrowsExactly<T>(() => ...) (3.8) |
| Project targets net5.0, net6.0, or net7.0 | TFM dropped | Change to net8.0 or net9.0 (3.9) |
UnfoldingStrategy on DataRow or DynamicData | Property moved | Set it on TestMethodAttribute instead (3.10) |
ConditionBaseAttribute.ShouldRun | Property renamed | Use IsConditionMet (3.11) |
| Public adapter or PlatformServices types | Types internalized or removed | Remove dependencies on those implementation APIs; distinguish the two ITestMethod interfaces (3.12) |
DataTestMethod, STATestMethod, or UITestMethod display-name constructor | displayName constructor removed | Set the DisplayName property instead (3.13) |
ITestMethod.Invoke or GetAllAttributes(..., inherit) | TestFramework interface changed | Use InvokeAsync; remove the inherit argument because inherited attributes are always included (3.14) |
Removed TestContext.TestDir, TestDeploymentDir, TestLogsDir, or ManagedMethod | Deprecated properties removed | Use the appropriate replacement in 3.15 |
ClassCleanupExecutionAttribute, runsettings ClassCleanupLifecycle, or JSON classCleanupLifecycle | Assembly attribute and settings removed | Remove the attribute/settings; v4 always uses end-of-class cleanup (3.16) |
StringAssert message and comparison arguments, or renamed named arguments | Assertion signatures changed | Reorder StringComparison before message; update renamed parameters (3.17) |
Assert.ReplaceNullChars, ExpectedExceptionBaseAttribute, TestIdGenerationStrategy, CSS attributes, or InternalTestFailureException | API/type removed | Remove or replace the usage as described in 3.17 |
| Assembly-name or executor-URI lookup fails | MSTest assemblies and executor URI renamed | Update references to the v4 names and executor://MSTestAdapter/v4 (3.18) |
ITestDataSourceUnfoldingCapability or custom IgnoreMessage override | Interface removed / property no longer virtual | Set UnfoldingStrategy on TestMethodAttribute; set IgnoreMessage without overriding (3.19) |
Important: Scan the entire project for ALL patterns above before starting fixes. Multiple breaking changes often coexist in the same project.
Before applying a matching fix, read the relevant numbered section in the
breaking-change reference.
Resolve this path relative to this SKILL.md, not the user's project. If it is
missing, list the known references directory at most once and report the
missing guidance rather than silently proceeding with reduced coverage.
For custom test-method attributes, update both ExecuteAsync and caller-info
propagation (3.1-3.2), preserving the existing retry and result semantics.
Do not replace a retry implementation with a pass-through call to the base method.
For display names, replace positional strings with the named property:
[TestMethod(DisplayName = "custom name")]
These changes won't cause build errors but may affect test runtime behavior.
| Symptom | Cause | Fix |
|---|---|---|
| Tests show as new in Azure DevOps / test history lost | TestCase.Id generation changed (4.3) | No code fix; history will re-baseline |
TestContext.TestName throws in [ClassInitialize] | v4 enforces lifecycle scope (4.2) | Move access to [TestInitialize] or test methods |
| Tests not discovered / discovery failures | TreatDiscoveryWarningsAsErrors now true (4.4) | Fix warnings, or set to false in .runsettings |
| .NET Framework tests hang under MTP | AppDomain unloading no longer aborts foreground threads by default (4.1) | Stop lingering threads, or enable required isolation with DisableAppDomain = false under .runsettings RunConfiguration |
| vstest.console can't find tests with MSTest.Sdk after the v4 upgrade | MSTest.Sdk defaults to MTP; v4 stopped adding Microsoft.NET.Test.Sdk in MTP mode (4.5) | Add an explicit package while preserving MTP, set UseVSTest, or switch CI to dotnet test |
| New warnings from analyzers | Analyzer severities upgraded (4.6) | Fix warnings or suppress in .editorconfig |
Discovery fails with ReflectionTypeLoadException | v4 fails discovery when any types in the test assembly cannot load | Fix the underlying loader error, often a missing or mismatched dependency (4.7) |
| A custom inherited data-source attribute now applies to overrides | v4 always includes inherited attributes | Set Inherited = false in the custom attribute's AttributeUsage if that is not intended (4.8) |
| Custom data rows have a different display name | A null ITestDataSource.GetDisplayName result now falls back to a name containing row arguments | Return an explicit display name if the old method-name fallback is required (4.9) |
Read the breaking-change reference for the relevant runtime configuration, discovery, attribute-inheritance, and custom data-source details.
dotnet build -- confirm zero errors and review any new warningsdotnet test -- confirm all tests passTestCase.Id changes may affect history continuitydotnet testTestMethodAttribute subclasses updated for ExecuteAsync and CallerInfoExpectedExceptionAttribute replaced with Assert.ThrowsExactlyAssert.ThrowsException replaced with Assert.ThrowsExactly (or Assert.Throws)ClassCleanupBehavior enum usages removedTestContext.Properties.Contains updated to ContainsKeyTestContext properties replaced with the correct directory/name propertyITestMethod callers use InvokeAsync and updated attribute lookup signatureswriting-mstest-tests -- for modern MSTest v4 assertion APIs and test authoring best practicesrun-tests -- for running tests after migration| Pitfall | Solution |
|---|---|
Custom TestMethodAttribute still overrides Execute | Change to ExecuteAsync returning Task<TestResult[]> |
TestMethodAttribute("display name") is silently ignored | Use TestMethodAttribute(DisplayName = "display name") |
ClassCleanupBehavior enum not found | Remove the enum argument; [ClassCleanup] now always runs at end of class. For end-of-assembly cleanup, use [AssemblyCleanup] |
TestContext.Properties.Contains missing | Use ContainsKey -- Properties is now IDictionary<string, object> |
ExpectedException attribute not found | Replace with Assert.ThrowsExactly<T>(() => ...) inside the test body |
Assert.ThrowsException not found | Replace with Assert.ThrowsExactly (or Assert.Throws for derived types) |
Assert.AreEqual with format string args fails | Use string interpolation: $"message {value}" |
TestContext.TestDeploymentDir or TestContext.ManagedMethod is missing | Use DeploymentDirectory or TestName; verify that the replacement preserves the required semantics |
ITestMethod.Invoke is missing | Use InvokeAsync; update attribute lookup calls to omit the inherit parameter |
vstest.console or assembly lookup stops matching after upgrade | Update renamed assembly references and the executor URI to v4 |
Custom ITestDataSource now applies to an override | Set Inherited = false in the attribute's AttributeUsage if inheritance is not intended |
| Discovery fails after a loader warning in v3 | Resolve the ReflectionTypeLoadException, commonly by fixing a missing or mismatched dependency |
| A custom data-source test gets a different display name | Return a non-null name from GetDisplayName when row arguments should not appear |
| .NET Framework tests hang under MTP | Stop lingering foreground threads or enable required AppDomain isolation; this default change is specific to MTP |
| Azure DevOps test history breaks | Expected -- TestCase.Id generation changed; no code fix, results will re-baseline |
| Discovery warnings now fail the run | TreatDiscoveryWarningsAsErrors is true by default; fix the discovery warnings |
| Net6.0/net7.0 targets don't compile | Update to net8.0 -- MSTest v4 supports net8.0, net9.0, net462, uap10.0.16299, modern UWP, and WinUI |
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub codehepta/net10-skills --plugin net10-upgrade8 skills in this plugin
/dotnet-aot-compatMake .NET projects compatible with Native AOT and trimming by systematically resolving IL trim/AOT analyzer warnings. USE FOR: making projects AOT-compatible, fixing trimming warnings, resolving IL warnings (IL2026, IL2070, IL2067, IL2072, IL3050), adding DynamicallyAccessedMembers annotations, enabling IsAotCompatible. DO NOT USE FOR: publishing native AOT binaries, optimizing binary size, replacing reflection-heavy libraries with alternatives. INVOKES: no tools — pure knowledge skill.
/migrate-dotnet10-to-dotnet11Migrate a .NET 10 project or solution to .NET 11 and resolve all breaking changes. This is a MIGRATION skill — use it when upgrading from .NET 10 to .NET 11, NOT for writing new programs. USE FOR: upgrading TargetFramework from net10.0 to net11.0, fixing build errors after updating the .NET 11 SDK, resolving source-breaking and behavioral changes in .NET 11 runtime, C# 15 compiler, and EF Core 11, adapting to updated minimum hardware requirements (x86-64-v2, Arm64 LSE), and updating CI/CD pipelines and Dockerfiles for .NET 11. DO NOT USE FOR: .NET Framework migrations, upgrading from .NET 9 or earlier, greenfield .NET 11 projects, or cosmetic modernization unrelated to the upgrade. NOTE: .NET 11 is in preview. Covers breaking changes through Preview 3.