[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D23PP9MNR8MMF5AV6R76PY":3,"skill-same:01M7D23PP9MNR8MMF5AV6R76PY":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7D23PP9MNR8MMF5AV6R76PY","migrate-mstest-v3-to-v4",null,"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\u002FCS0103\u002FCS1061\u002FCS1615; ExecuteAsync, CallerInfo, DisplayName, or custom TestMethodAttribute; ClassCleanupBehavior; ContainsKey; ThrowsExactly or ExpectedException; IsInstanceOfType out parameters; TestTimeout.Infinite; ManagedType; net6\u002Fnet7 compatibility; TestCase.Id history; TestName in ClassInitialize; TreatDiscoveryWarningsAsErrors; discovery errors after a clean build; and MSTest.Sdk\u002FMTP or vstest.console discovery changes. Do not use for v1\u002Fv2-to-v3 leftovers, framework conversion, runner-only migration, or a general .NET upgrade.","itsmejay18\u002FAI-Skills-for-My-Development-Stack","itsmejay18","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F167779943?v=4","01M7CZRFC6DDZA5V2CX8WDSZED","Jay Jemino Ababon ","01M7CZRFCVRNW1SFHSQXEJ3CQN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F13-Testing-QA\u002Fmigrate-mstest-v3-to-v4\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: migrate-mstest-v3-to-v4\ndescription: >\n  Use this skill before answering, planning, or editing any MSTest 3.x-to-4.x\n  upgrade or post-upgrade failure. Triggers include \"MSTest v4 breaking\n  changes\"; CS0507\u002FCS0103\u002FCS1061\u002FCS1615; ExecuteAsync, CallerInfo, DisplayName,\n  or custom TestMethodAttribute; ClassCleanupBehavior; ContainsKey;\n  ThrowsExactly or ExpectedException; IsInstanceOfType out parameters;\n  TestTimeout.Infinite; ManagedType; net6\u002Fnet7 compatibility; TestCase.Id\n  history; TestName in ClassInitialize; TreatDiscoveryWarningsAsErrors;\n  discovery errors after a clean build; and MSTest.Sdk\u002FMTP or vstest.console\n  discovery changes. Do not use for v1\u002Fv2-to-v3 leftovers, framework\n  conversion, runner-only migration, or a general .NET upgrade.\nlicense: MIT\n---\n\n# MSTest v3 -> v4 Migration\n\nMigrate 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.\n\n## First Action\n\nInspect the supplied project and source before searching the web or answering\nfrom memory. Classify the request as a focused source fix, runtime behavior\nchange, CI discovery issue, compatibility question, or full migration, then\nfollow the matching row below. A clean compile does not exclude this skill:\ndiscovery failures, `TestContext` lifecycle exceptions, and test-history\nchanges are runtime migration failures.\n\n## When to Use\n\n- Upgrading `MSTest.TestFramework`, `MSTest.TestAdapter`, or `MSTest` metapackage from 3.x to 4.x\n- Upgrading `MSTest.Sdk` from 3.x to 4.x\n- Fixing build errors after updating to MSTest v4 packages\n- Resolving behavioral changes in test execution after upgrading to MSTest v4\n- Updating custom `TestMethodAttribute` or `ConditionBaseAttribute` implementations for v4\n\n## When Not to Use\n\n- The project already uses MSTest v4 and builds cleanly -- migration is done\n- Upgrading from MSTest v1 or v2 -- use `migrate-mstest-v1v2-to-v3` first, then return here\n- The project does not use MSTest\n- Migrating between test frameworks (e.g., MSTest to xUnit or NUnit)\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| 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 |\n| Build command | No | How to build (e.g., `dotnet build`, a repo build script). Auto-detect if not provided |\n| Test command | No | How to run tests (e.g., `dotnet test`). Auto-detect if not provided |\n\n## Decisions That Change the Result\n\n| Detected request or state | Required action |\n|---|---|\n| 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\u002Feditor; do not ask the user for a path you can discover. |\n| User asks to apply changes to supplied files: \"fix my project\u002Ffiles\", \"please update this source\", \"make the changes\", or \"then build and run\" | Edit every affected occurrence. Run the narrowest meaningful build\u002Ftest command against the actual package version; skill activation is not a reason to stop at advice. |\n| 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. |\n| 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. |\n| Custom `TestMethodAttribute` subclass | Treat `ExecuteAsync`, CallerInfo propagation, display-name handling, and the subclass's retry\u002Fresult semantics as one coupled migration. Fix the actual class, not a placeholder example. |\n| `MSTest.Sdk` v4 source\u002FAPI 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. |\n| `MSTest.Sdk` v4 plus `vstest.console` | This is a v4 change: MTP mode no longer brings `Microsoft.NET.Test.Sdk`. Keep MTP and add that package for transitional VSTest discovery, opt into `UseVSTest`, or migrate CI to `dotnet test`; state which runner the choice preserves. |\n\n## Response Guidelines\n\n- **Always identify the current version first**: Before recommending any migration steps, explicitly state the current MSTest version detected in the project (e.g., \"Your project uses MSTest v3 (3.8.0)\"). This confirms you've read the project files and grounds the migration advice.\n- **Resolve, do not assume, the target version**: When the user asks for \"latest\", query the project's configured package source and select the latest stable MSTest v4 version available at execution time. Never copy the example version from this skill into the result without checking it. Keep all MSTest packages on the same resolved version.\n- **Focused fix requests** (user has specific compilation errors after upgrading): Address only the relevant breaking changes from Step 3. Make edits only when the requested deliverable is a source change; \"how do I fix these?\" remains an answer request. **Always provide concrete fixed code** using the user's actual types and method names. If the fixture still references v3, do not claim that a green v3 build verifies v4 compatibility; either update packages when requested or state the verification boundary. For custom `TestMethodAttribute` subclasses, show the full fixed class including CallerInfo propagation to the base constructor. Mention any related analyzer that could have caught this earlier (e.g., MSTEST0006 for ExpectedException). When the project uses `MSTest.Sdk`, also state that v4 MTP mode no longer supplies `Microsoft.NET.Test.Sdk` and whether that affects the visible runner. Do not walk through the entire migration workflow.\n- **\"What to expect\" questions** (user asks about breaking changes before upgrading): Present ALL major breaking changes from the Step 3 quick-lookup table -- not just the ones visible in the current code. For each, provide a one-line fix summary. Also mention key behavioral changes from Step 4 (especially TestCase.Id history impact and TreatDiscoveryWarningsAsErrors default). If project code is available, highlight which changes apply directly.\n- **Full migration requests** (user wants complete migration): Follow the complete workflow below.\n- **Behavioral\u002Fruntime symptom reports** (user describes test execution differences without build errors): Match described symptoms to the behavioral changes table in Step 4. Provide targeted, symptom-specific advice. Mention other behavioral changes the user should watch for. Do not walk through source breaking changes unless the user also has build errors.\n- **CI\u002Ftest-discovery issues** (tests not discovered, vstest.console stopped working, CI pipeline failures after upgrading): Focus on 4.5 (MSTest.Sdk v4 no longer includes Microsoft.NET.Test.Sdk in its default MTP mode -- it is still needed for vstest.console) and 4.4 (TreatDiscoveryWarningsAsErrors). Explain the root cause clearly and give all three paths: add Microsoft.NET.Test.Sdk while preserving MTP, set `UseVSTest` to switch the project runner, or switch CI to MTP-native `dotnet test`. Do not walk through the full migration workflow.\n- **Explanatory questions** (user asks \"is this a known change?\", \"what else should I watch out for?\"): Explain the relevant changes and advise. Mention related changes the user might encounter next. Do not prescribe a full migration procedure.\n- **Result proof**: End implementation work with the detected v3 version, resolved v4 version, runner choice, files changed, and actual build\u002Ftest counts. Never report a build, VSTest compatibility, discovery, or passing tests from inference.\n\n## Workflow\n\n> **Commit strategy:** Do not create commits unless the user asks. Keep package,\n> source, and behavioral changes logically separable in the diff, but finish and\n> verify the requested migration.\n\n### Step 1: Assess the project\n\n1. Identify the current MSTest version by checking package references for `MSTest`, `MSTest.TestFramework`, `MSTest.TestAdapter`, or `MSTest.Sdk` in `.csproj`, `Directory.Build.props`, or `Directory.Packages.props`.\n2. Confirm the project is on MSTest v3 (3.x). If on v1 or v2, use `migrate-mstest-v1v2-to-v3` first.\n3. Check target framework(s) -- MSTest v4 drops support for .NET Core 3.1 through .NET 7. Supported target frameworks are: **net8.0**, **net9.0**, **net462** (.NET Framework 4.6.2+), **uap10.0.16299** (UWP), **net9.0-windows10.0.17763.0** (modern UWP), and **net8.0-windows10.0.18362.0** (WinUI).\n4. Check for custom `TestMethodAttribute` subclasses -- these require changes in v4.\n5. Check for usages of `ExpectedExceptionAttribute` -- removed in v4 (deprecated since v3 with analyzer MSTEST0006).\n6. Check for usages of `Assert.ThrowsException` (deprecated) -- removed in v4.\n7. Run a clean build to establish a baseline of existing errors\u002Fwarnings.\n\n### Step 2: Update packages to MSTest v4\n\nFirst resolve the latest stable v4 version from the configured package source. Pin that exact\nversion consistently in the metapackage, individual packages, `MSTest.Sdk`, and central package\nmanagement.\n\n- For the `MSTest` metapackage, update its `PackageReference` to the resolved exact version.\n- For individual packages, update `MSTest.TestFramework` and `MSTest.TestAdapter` to that same version.\n- For `MSTest.Sdk`, update the SDK version in the project or `global.json` pin to that same version.\n\nRun `dotnet restore`, then `dotnet build`. Collect all errors for Step 3.\n\n### Step 3: Resolve source breaking changes\n\nWork through compilation errors systematically. Use this quick-lookup table to identify all applicable changes, then apply each fix:\n\n| Error \u002F Pattern in code | Breaking change | Fix |\n|---|---|---|\n| Custom `TestMethodAttribute` overrides `Execute` | Execute removed | Change to `ExecuteAsync` returning `Task\u003CTestResult[]>` (3.1) |\n| `[TestMethod(\"name\")]` or custom attribute constructor | CallerInfo params added | Use `DisplayName = \"name\"` named param; propagate CallerInfo in subclasses (3.2) |\n| `ClassCleanupBehavior.EndOfClass` | Enum removed | Remove argument: just `[ClassCleanup]` (3.3) |\n| `TestContext.Properties.Contains(\"key\")` | `Properties` is `IDictionary\u003Cstring, object>` | Change to `ContainsKey(\"key\")` (3.4) |\n| `[Timeout(TestTimeout.Infinite)]` | `TestTimeout` enum removed | Replace with `[Timeout(int.MaxValue)]` (3.5) |\n| `TestContext.ManagedType` | Property removed | Use `FullyQualifiedTestClassName` (3.6) |\n| `Assert.AreEqual(a, b, \"msg {0}\", arg)` | Message+params overloads removed | Use string interpolation: `$\"msg {arg}\"` (3.7) |\n| `Assert.ThrowsException\u003CT>(...)` | Renamed | Replace with `Assert.ThrowsExactly\u003CT>(...)` or `Assert.Throws\u003CT>(...)` (3.7) |\n| `Assert.IsInstanceOfType\u003CT>(obj, out var t)` | Out parameter removed | Use `var t = Assert.IsInstanceOfType\u003CT>(obj)` (3.7) |\n| `[ExpectedException(typeof(T))]` | Attribute removed | Move assertion into test body: `Assert.ThrowsExactly\u003CT>(() => ...)` (3.8) |\n| Project targets net5.0, net6.0, or net7.0 | TFM dropped | Change to net8.0 or net9.0 (3.9) |\n\n> **Important**: Scan the entire project for ALL patterns above before starting fixes. Multiple breaking changes often coexist in the same project.\n\n#### 3.1 TestMethodAttribute.Execute -> ExecuteAsync\n\nIf you have custom `TestMethodAttribute` subclasses that override `Execute`, change to `ExecuteAsync`. This change was made because the v3 synchronous `Execute` API caused deadlocks when test code used `async`\u002F`await` internally -- the synchronous wrapper would block the thread while the async operation needed that same thread to complete.\n\n```csharp\n\u002F\u002F Before (v3)\npublic sealed class MyTestMethodAttribute : TestMethodAttribute\n{\n    public override TestResult[] Execute(ITestMethod testMethod)\n    {\n        \u002F\u002F custom logic\n        return result;\n    }\n}\n\n\u002F\u002F After (v4) -- Option A: wrap synchronous logic with Task.FromResult\npublic sealed class MyTestMethodAttribute : TestMethodAttribute\n{\n    public override Task\u003CTestResult[]> ExecuteAsync(ITestMethod testMethod)\n    {\n        \u002F\u002F custom logic (synchronous)\n        return Task.FromResult(result);\n    }\n}\n\n\u002F\u002F After (v4) -- Option B: make properly async\npublic sealed class MyTestMethodAttribute : TestMethodAttribute\n{\n    public override async Task\u003CTestResult[]> ExecuteAsync(ITestMethod testMethod)\n    {\n        \u002F\u002F custom async logic\n        return await base.ExecuteAsync(testMethod);\n    }\n}\n```\n\nUse `Task.FromResult` when your override logic is purely synchronous. Use `async`\u002F`await` when you call `base.ExecuteAsync` or other async methods.\n\n#### 3.2 TestMethodAttribute CallerInfo constructor\n\n`TestMethodAttribute` now uses `[CallerFilePath]` and `[CallerLineNumber]` parameters in its constructor.\n\n**If you inherit from TestMethodAttribute**, propagate caller info to the base class:\n\n```csharp\npublic class MyTestMethodAttribute : TestMethodAttribute\n{\n    public MyTestMethodAttribute(\n        [CallerFilePath] string callerFilePath = \"\",\n        [CallerLineNumber] int callerLineNumber = -1)\n        : base(callerFilePath, callerLineNumber)\n    {\n    }\n}\n```\n\nIf the subclass has its own display-name constructor, do not pass that string to\nthe v4 base constructor. Propagate only caller information and assign the\n`DisplayName` property:\n\n```csharp\npublic sealed class NamedTestMethodAttribute : TestMethodAttribute\n{\n    public NamedTestMethodAttribute(\n        string displayName,\n        [CallerFilePath] string callerFilePath = \"\",\n        [CallerLineNumber] int callerLineNumber = -1)\n        : base(callerFilePath, callerLineNumber)\n    {\n        DisplayName = displayName;\n    }\n}\n```\n\n**If you use `[TestMethodAttribute(\"Custom display name\")]`**, switch to the named parameter syntax:\n\n```csharp\n\u002F\u002F Before (v3)\n[TestMethodAttribute(\"Custom display name\")]\n\n\u002F\u002F After (v4)\n[TestMethodAttribute(DisplayName = \"Custom display name\")]\n```\n\n#### 3.3 ClassCleanupBehavior enum removed\n\nThe `ClassCleanupBehavior` enum is removed. In v3, this enum controlled whether class cleanup ran at end of class (`EndOfClass`) or end of assembly (`EndOfAssembly`). In v4, class cleanup always runs at end of class. Remove the enum argument:\n\n```csharp\n\u002F\u002F Before (v3)\n[ClassCleanup(ClassCleanupBehavior.EndOfClass)]\npublic static void ClassCleanup(TestContext testContext) { }\n\n\u002F\u002F After (v4)\n[ClassCleanup]\npublic static void ClassCleanup(TestContext testContext) { }\n```\n\nIf you previously used `ClassCleanupBehavior.EndOfAssembly`, move that cleanup logic to an `[AssemblyCleanup]` method instead.\n\n#### 3.4 TestContext.Properties type change\n\n`TestContext.Properties` changed from `IDictionary` to `IDictionary\u003Cstring, object>`. Update any `Contains` calls to `ContainsKey`:\n\n```csharp\n\u002F\u002F Before (v3)\ntestContext.Properties.Contains(\"key\");\n\n\u002F\u002F After (v4)\ntestContext.Properties.ContainsKey(\"key\");\n```\n\n#### 3.5 TestTimeout enum removed\n\nThe `TestTimeout` enum (with only `TestTimeout.Infinite`) is removed. Replace with `int.MaxValue`:\n\n```csharp\n\u002F\u002F Before (v3)\n[Timeout(TestTimeout.Infinite)]\n\n\u002F\u002F After (v4)\n[Timeout(int.MaxValue)]\n```\n\n#### 3.6 TestContext.ManagedType removed\n\nThe `TestContext.ManagedType` property is removed. Use `TestContext.FullyQualifiedTestClassName` instead.\n\n#### 3.7 Assert API signature changes\n\n- **Message + params removed**: Assert methods that accepted both `message` and `object[]` parameters now accept only `message`. Use string interpolation instead of format strings:\n\n```csharp\n\u002F\u002F Before (v3)\nAssert.AreEqual(expected, actual, \"Expected {0} but got {1}\", expected, actual);\n\n\u002F\u002F After (v4)\nAssert.AreEqual(expected, actual, $\"Expected {expected} but got {actual}\");\n```\n\n- **Assert.ThrowsException renamed**: The `Assert.ThrowsException` APIs are renamed. Use `Assert.ThrowsExactly` (strict type match) or `Assert.Throws` (accepts derived exception types):\n\n```csharp\n\u002F\u002F Before (v3)\nAssert.ThrowsException\u003CInvalidOperationException>(() => DoSomething());\n\n\u002F\u002F After (v4) -- exact type match (same behavior as old ThrowsException)\nAssert.ThrowsExactly\u003CInvalidOperationException>(() => DoSomething());\n\n\u002F\u002F After (v4) -- also catches derived exception types\nAssert.Throws\u003CInvalidOperationException>(() => DoSomething());\n```\n\n- **Assert.IsInstanceOfType out parameter changed**: `Assert.IsInstanceOfType\u003CT>(x, out var t)` changes to `var t = Assert.IsInstanceOfType\u003CT>(x)`:\n\n```csharp\n\u002F\u002F Before (v3)\nAssert.IsInstanceOfType\u003CMyType>(obj, out var typed);\n\n\u002F\u002F After (v4)\nvar typed = Assert.IsInstanceOfType\u003CMyType>(obj);\n```\n\nApply this assignment rewrite to every occurrence, preserving the concrete asserted type and all\nlater uses of the typed variable. When source is available, show or edit the actual method rather\nthan substituting a generic `MyType` example, then verify that the project compiles.\n\n- **Assert.AreEqual for IEquatable\\\u003CT\\> removed**: If you get generic type inference errors, explicitly specify the type argument as `object`.\n\n#### 3.8 ExpectedExceptionAttribute removed\n\nThe `[ExpectedException]` attribute is removed in v4. In MSTest 3.2, the `MSTEST0006` analyzer was introduced to flag `[ExpectedException]` usage and suggest migrating to `Assert.ThrowsExactly` while still on v3 (a non-breaking change). In v4, the attribute is gone entirely. Migrate to `Assert.ThrowsExactly`:\n\n```csharp\n\u002F\u002F Before (v3)\n[ExpectedException(typeof(InvalidOperationException))]\n[TestMethod]\npublic void TestMethod()\n{\n    MyCall();\n}\n\n\u002F\u002F After (v4)\n[TestMethod]\npublic void TestMethod()\n{\n    Assert.ThrowsExactly\u003CInvalidOperationException>(() => MyCall());\n}\n```\n\n**When the test has setup code before the throwing call**, wrap only the throwing call in the lambda -- keep Arrange\u002FAct separation clear:\n\n```csharp\n\u002F\u002F Before (v3)\n[ExpectedException(typeof(ArgumentNullException))]\n[TestMethod]\npublic void Validate_NullInput_Throws()\n{\n    var service = new ValidationService();\n    service.Validate(null);  \u002F\u002F throws here\n}\n\n\u002F\u002F After (v4)\n[TestMethod]\npublic void Validate_NullInput_Throws()\n{\n    var service = new ValidationService();\n    Assert.ThrowsExactly\u003CArgumentNullException>(() => service.Validate(null));\n}\n```\n\n**For async test methods**, use `Assert.ThrowsExactlyAsync`:\n\n```csharp\n\u002F\u002F Before (v3)\n[ExpectedException(typeof(HttpRequestException))]\n[TestMethod]\npublic async Task FetchData_BadUrl_Throws()\n{\n    await client.GetAsync(\"https:\u002F\u002Flocalhost:0\");\n}\n\n\u002F\u002F After (v4)\n[TestMethod]\npublic async Task FetchData_BadUrl_Throws()\n{\n    await Assert.ThrowsExactlyAsync\u003CHttpRequestException>(\n        () => client.GetAsync(\"https:\u002F\u002Flocalhost:0\"));\n}\n```\n\n**If `[ExpectedException]` used the `AllowDerivedTypes` property**, use `Assert.ThrowsAsync\u003CT>` (base type matching) instead of `Assert.ThrowsExactlyAsync\u003CT>` (exact type matching).\n\nFor a focused migration, convert every attributed method in the supplied source, wrap only the\nstatement expected to throw, preserve arrange\u002Fsetup statements outside the lambda, and run the\naffected tests. A prose-only API substitution is incomplete when editable project files are present.\n\n#### 3.9 Dropped target frameworks\n\nMSTest v4 supports **.NET 8 and later** and **.NET Framework 4.6.2 and later**. Platform-specific supported targets also include **uap10.0.16299** (UWP), with modern UWP and WinUI using their corresponding supported Windows-specific .NET TFMs. .NET Core 3.1 through .NET 7 are dropped.\n\nIf the test project targets an unsupported framework, update `TargetFramework`:\n\n```xml\n\u003C!-- Before -->\n\u003CTargetFramework>net6.0\u003C\u002FTargetFramework>\n\n\u003C!-- After -->\n\u003CTargetFramework>net8.0\u003C\u002FTargetFramework>\n```\n\n#### 3.10 Unfolding strategy moved to TestMethodAttribute\n\nThe `UnfoldingStrategy` property (introduced in MSTest 3.7) has moved from individual data source attributes (`DataRowAttribute`, `DynamicDataAttribute`) to `TestMethodAttribute`.\n\n#### 3.11 ConditionBaseAttribute.ShouldRun renamed\n\nThe `ConditionBaseAttribute.ShouldRun` property is renamed to `IsConditionMet`.\n\n#### 3.12 Internal\u002Fremoved types\n\nSeveral types previously public are now internal or removed:\n\n- `MSTestDiscoverer`, `MSTestExecutor`, `AssemblyResolver`, `LogMessageListener`\n- `TestExecutionManager`, `TestMethodInfo`, `TestResultExtensions`\n- `UnitTestOutcomeExtensions`, `GenericParameterHelper`\n- `ITestMethod` in PlatformServices assembly (the one in TestFramework is unchanged)\n\nIf your code references any of these, find alternative approaches or remove the dependency.\n\n### Step 4: Address behavioral changes\n\nThese changes won't cause build errors but may affect test runtime behavior.\n\n| Symptom | Cause | Fix |\n|---|---|---|\n| Tests show as new in Azure DevOps \u002F test history lost | `TestCase.Id` generation changed (4.3) | No code fix; history will re-baseline |\n| `TestContext.TestName` throws in `[ClassInitialize]` | v4 enforces lifecycle scope (4.2) | Move access to `[TestInitialize]` or test methods |\n| Tests not discovered \u002F discovery failures | `TreatDiscoveryWarningsAsErrors` now true (4.4) | Fix warnings, or set to false in .runsettings |\n| Tests hang that didn't before | AppDomain disabled by default (4.1) | Set `DisableAppDomain` to false in .runsettings `RunConfiguration` |\n| 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` |\n| New warnings from analyzers | Analyzer severities upgraded (4.6) | Fix warnings or suppress in .editorconfig |\n\n#### 4.1 DisableAppDomain defaults to true\n\nAppDomains are disabled by default. On .NET Framework, when running inside testhost (the default for `dotnet test` and VS), MSTest re-enables AppDomains automatically. If you need to explicitly control AppDomain isolation, set it via `.runsettings`:\n\n```xml\n\u003CRunSettings>\n  \u003CRunConfiguration>\n    \u003CDisableAppDomain>false\u003C\u002FDisableAppDomain>\n  \u003C\u002FRunConfiguration>\n\u003C\u002FRunSettings>\n```\n\n#### 4.2 TestContext throws when used incorrectly\n\nMSTest v4 now throws when accessing test-specific properties in the wrong lifecycle stage:\n\n- `TestContext.FullyQualifiedTestClassName` -- cannot be accessed in `[AssemblyInitialize]`\n- `TestContext.TestName` -- cannot be accessed in `[AssemblyInitialize]` or `[ClassInitialize]`\n\n**Fix**: Move any code that accesses `TestContext.TestName` from `[ClassInitialize]` to `[TestInitialize]` or individual test methods, where per-test context is available. Do not replace `TestName` with `FullyQualifiedTestClassName` as a workaround -- they have different semantics.\n\n#### 4.3 TestCase.Id generation changed\n\nThe generation algorithm for `TestCase.Id` has changed to fix long-standing bugs. This may affect Azure DevOps test result tracking (e.g., test failure tracking over time). There is no code fix needed, but be aware of test result history discontinuity.\n\n#### 4.4 TreatDiscoveryWarningsAsErrors defaults to true\n\nv4 uses stricter defaults. Discovery warnings are now treated as errors, which means tests that previously ran despite discovery issues may now fail entirely. If you see unexpected test failures after upgrading (not build errors, but tests not being discovered), check for discovery warnings. To restore v3 behavior while you investigate:\n\n```xml\n\u003CRunSettings>\n  \u003CMSTest>\n    \u003CTreatDiscoveryWarningsAsErrors>false\u003C\u002FTreatDiscoveryWarningsAsErrors>\n  \u003C\u002FMSTest>\n\u003C\u002FRunSettings>\n```\n\n> **Recommended**: Fix the underlying discovery warnings rather than suppressing this setting.\n\n#### 4.5 MSTest.Sdk and vstest.console compatibility\n\nMSTest.Sdk defaults to Microsoft.Testing.Platform (MTP) mode. MSTest.Sdk v3\nstill added `Microsoft.NET.Test.Sdk` in that mode; v4 removes the unnecessary\nreference. A CI pipeline that separately invokes `vstest.console` can therefore\ndrop to zero discovered tests immediately after the v4 upgrade.\n\n**Option A -- Preserve MTP and transitional VSTest discovery**: Add the exact\ncompatible `Microsoft.NET.Test.Sdk` package explicitly. This is the least\ndisruptive fix when MTP remains the primary runner but an existing\n`vstest.console` job cannot be removed yet:\n\nUse a direct `PackageReference` with the exact compatible version resolved from\nthe configured feed. Under Central Package Management, add or update the\n`Microsoft.NET.Test.Sdk` `PackageVersion` in `Directory.Packages.props` and keep\nthe project reference versionless. Do not copy a fixed example version.\n\nVerify with the actual `vstest.console` command; a passing `dotnet test` MTP run\ndoes not prove VSTest discovery.\n\n**Option B -- Switch the project to VSTest mode**: Set the `UseVSTest` property.\nMSTest.Sdk then adds `Microsoft.NET.Test.Sdk`:\n\n```xml\n\u003CPropertyGroup>\n  \u003CUseVSTest>true\u003C\u002FUseVSTest>\n\u003C\u002FPropertyGroup>\n```\n\nKeep the resolved exact `MSTest.Sdk` v4 pin from Step 2; this option changes the runner, not the\nselected MSTest version or target framework.\n\n**Option C -- Switch CI to `dotnet test`**: Replace `vstest.console` invocations in your CI pipeline with `dotnet test`. This works natively with MTP and is the recommended long-term approach for MSTest.Sdk projects.\n\nDo not say this behavior predates v4: removal of the transitive\n`Microsoft.NET.Test.Sdk` reference in MTP mode is one of the v4 behavioral\nbreaking changes.\n\n#### 4.6 Analyzer severity changes\n\nMultiple analyzers have been upgraded from Info to Warning by default:\n\n- MSTEST0001, MSTEST0007, MSTEST0017, MSTEST0023, MSTEST0024, MSTEST0025\n- MSTEST0030, MSTEST0031, MSTEST0032, MSTEST0035, MSTEST0037, MSTEST0045\n\nReview and fix any new warnings, or suppress them in `.editorconfig` if intentional.\n\n### Step 5: Verify\n\n1. Run `dotnet build` -- confirm zero errors and review any new warnings\n2. Run `dotnet test` -- confirm all tests pass\n3. Compare test results (pass\u002Ffail counts) to the pre-migration baseline\n4. If using Azure DevOps test tracking, be aware that `TestCase.Id` changes may affect history continuity\n5. Check that no tests were silently dropped due to stricter discovery\n\n## Validation\n\n- [ ] All MSTest packages updated to 4.x\n- [ ] Project builds with zero errors\n- [ ] All tests pass with `dotnet test`\n- [ ] Custom `TestMethodAttribute` subclasses updated for `ExecuteAsync` and CallerInfo\n- [ ] `ExpectedExceptionAttribute` replaced with `Assert.ThrowsExactly`\n- [ ] `Assert.ThrowsException` replaced with `Assert.ThrowsExactly` (or `Assert.Throws`)\n- [ ] `ClassCleanupBehavior` enum usages removed\n- [ ] `TestContext.Properties.Contains` updated to `ContainsKey`\n- [ ] All target frameworks are net8.0+, net9.0, net462+, uap10.0.16299, or WinUI\n- [ ] Behavioral changes reviewed and addressed\n- [ ] No tests were lost during migration (compare test counts)\n\n## Related Skills\n\n- `writing-mstest-tests` -- for modern MSTest v4 assertion APIs and test authoring best practices\n- `run-tests` -- for running tests after migration\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Custom `TestMethodAttribute` still overrides `Execute` | Change to `ExecuteAsync` returning `Task\u003CTestResult[]>` |\n| `TestMethodAttribute(\"display name\")` no longer compiles | Use `TestMethodAttribute(DisplayName = \"display name\")` |\n| `ClassCleanupBehavior` enum not found | Remove the enum argument; `[ClassCleanup]` now always runs at end of class. For end-of-assembly cleanup, use `[AssemblyCleanup]` |\n| `TestContext.Properties.Contains` missing | Use `ContainsKey` -- `Properties` is now `IDictionary\u003Cstring, object>` |\n| `ExpectedException` attribute not found | Replace with `Assert.ThrowsExactly\u003CT>(() => ...)` inside the test body |\n| `Assert.ThrowsException` not found | Replace with `Assert.ThrowsExactly` (or `Assert.Throws` for derived types) |\n| `Assert.AreEqual` with format string args fails | Use string interpolation: `$\"message {value}\"` |\n| Tests hang that didn't before | AppDomain is disabled by default; on .NET Fx in testhost it is re-enabled automatically |\n| Azure DevOps test history breaks | Expected -- `TestCase.Id` generation changed; no code fix, results will re-baseline |\n| Discovery warnings now fail the run | `TreatDiscoveryWarningsAsErrors` is true by default; fix the discovery warnings |\n| Net6.0\u002Fnet7.0 targets don't compile | Update to net8.0 -- MSTest v4 supports net8.0, net9.0, net462, uap10.0.16299, modern UWP, and WinUI |\n","# MSTest v3 -> v4 Migration\n\nMigrate 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.\n\n## First Action\n\nInspect the supplied project and source before searching the web or answering\nfrom memory. Classify the request as a focused source fix, runtime behavior\nchange, CI discovery issue, compatibility question, or full migration, then\nfollow the matching row below. A clean compile does not exclude this skill:\ndiscovery failures, `TestContext` lifecycle exceptions, and test-history\nchanges are runtime migration failures.\n\n## When to Use\n\n- Upgrading `MSTest.TestFramework`, `MSTest.TestAdapter`, or `MSTest` metapackage from 3.x to 4.x\n- Upgrading `MSTest.Sdk` from 3.x to 4.x\n- Fixing build errors after updating to MSTest v4 packages\n- Resolving behavioral changes in test execution after upgrading to MSTest v4\n- Updating custom `TestMethodAttribute` or `ConditionBaseAttribute` implementations for v4\n\n## When Not to Use\n\n- The project already uses MSTest v4 and builds cleanly -- migration is done\n- Upgrading from MSTest v1 or v2 -- use `migrate-mstest-v1v2-to-v3` first, then return here\n- The project does not use MSTest\n- Migrating between test frameworks (e.g., MSTest to xUnit or NUnit)\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| 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 |\n| Build command | No | How to build (e.g., `dotnet build`, a repo build script). Auto-detect if not provided |\n| Test command | No | How to run tests (e.g., `dotnet test`). Auto-detect if not provided |\n\n## Decisions That Change the Result\n\n| Detected request or state | Required action |\n|---|---|\n| 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\u002Feditor; do not ask the user for a path you can discover. |\n| User asks to apply changes to supplied files: \"fix my project\u002Ffiles\", \"please update this source\", \"make the changes\", or \"then build and run\" | Edit every affected occurrence. Run the narrowest meaningful build\u002Ftest command against the actual package version; skill activation is not a reason to stop at advice. |\n| 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. |\n| 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. |\n| Custom `TestMethodAttribute` subclass | Treat `ExecuteAsync`, CallerInfo propagation, display-name handling, and the subclass's retry\u002Fresult semantics as one coupled migration. Fix the actual class, not a placeholder example. |\n| `MSTest.Sdk` v4 source\u002FAPI 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. |\n| `MSTest.Sdk` v4 plus `vstest.console` | This is a v4 change: MTP mode no longer brings `Microsoft.NET.Test.Sdk`. Keep MTP and add that package for transitional VSTest discovery, opt into `UseVSTest`, or migrate CI to `dotnet test`; state which runner the choice preserves. |\n\n## Response Guidelines\n\n- **Always identify the current version first**: Before recommending any migration steps, explicitly state the current MSTest version detected in the project (e.g., \"Your project uses MSTest v3 (3.8.0)\"). This confirms you've read the project files and grounds the migration advice.\n- **Resolve, do not assume, the target version**: When the user asks for \"latest\", query the project's configured package source and select the latest stable MSTest v4 version available at execution time. Never copy the example version from this skill into the result without checking it. Keep all MSTest packages on the same resolved version.\n- **Focused fix requests** (user has specific compilation errors after upgrading): Address only the relevant breaking changes from Step 3. Make edits only when the requested deliverable is a source change; \"how do I fix these?\" remains an answer request. **Always provide concrete fixed code** using the user's actual types and method names. If the fixture still references v3, do not claim that a green v3 build verifies v4 compatibility; either update packages when requested or state the verification boundary. For custom `TestMethodAttribute` subclasses, show the full fixed class including CallerInfo propagation to the base constructor. Mention any related analyzer that could have caught this earlier (e.g., MSTEST0006 for ExpectedException). When the project uses `MSTest.Sdk`, also state that v4 MTP mode no longer supplies `Microsoft.NET.Test.Sdk` and whether that affects the visible runner. Do not walk through the entire migration workflow.\n- **\"What to expect\" questions** (user asks about breaking changes before upgrading): Present ALL major breaking changes from the Step 3 quick-lookup table -- not just the ones visible in the current code. For each, provide a one-line fix summary. Also mention key behavioral changes from Step 4 (especially TestCase.Id history impact and TreatDiscoveryWarningsAsErrors default). If project code is available, highlight which changes apply directly.\n- **Full migration requests** (user wants complete migration): Follow the complete workflow below.\n- **Behavioral\u002Fruntime symptom reports** (user describes test execution differences without build errors): Match described symptoms to the behavioral changes table in Step 4. Provide targeted, symptom-specific advice. Mention other behavioral changes the user should watch for. Do not walk through source breaking changes unless the user also has build errors.\n- **CI\u002Ftest-discovery issues** (tests not discovered, vstest.console stopped working, CI pipeline failures after upgrading): Focus on 4.5 (MSTest.Sdk v4 no longer includes Microsoft.NET.Test.Sdk in its default MTP mode -- it is still needed for vstest.console) and 4.4 (TreatDiscoveryWarningsAsErrors). Explain the root cause clearly and give all three paths: add Microsoft.NET.Test.Sdk while preserving MTP, set `UseVSTest` to switch the project runner, or switch CI to MTP-native `dotnet test`. Do not walk through the full migration workflow.\n- **Explanatory questions** (user asks \"is this a known change?\", \"what else should I watch out for?\"): Explain the relevant changes and advise. Mention related changes the user might encounter next. Do not prescribe a full migration procedure.\n- **Result proof**: End implementation work with the detected v3 version, resolved v4 version, runner choice, files changed, and actual build\u002Ftest counts. Never report a build, VSTest compatibility, discovery, or passing tests from inference.\n\n## Workflow\n\n> **Commit strategy:** Do not create commits unless the user asks. Keep package,\n> source, and behavioral changes logically separable in the diff, but finish and\n> verify the requested migration.\n\n### Step 1: Assess the project\n\n1. Identify the current MSTest version by checking package references for `MSTest`, `MSTest.TestFramework`, `MSTest.TestAdapter`, or `MSTest.Sdk` in `.csproj`, `Directory.Build.props`, or `Directory.Packages.props`.\n2. Confirm the project is on MSTest v3 (3.x). If on v1 or v2, use `migrate-mstest-v1v2-to-v3` first.\n3. Check target framework(s) -- MSTest v4 drops support for .NET Core 3.1 through .NET 7. Supported target frameworks are: **net8.0**, **net9.0**, **net462** (.NET Framework 4.6.2+), **uap10.0.16299** (UWP), **net9.0-windows10.0.17763.0** (modern UWP), and **net8.0-windows10.0.18362.0** (WinUI).\n4. Check for custom `TestMethodAttribute` subclasses -- these require changes in v4.\n5. Check for usages of `ExpectedExceptionAttribute` -- removed in v4 (deprecated since v3 with analyzer MSTEST0006).\n6. Check for usages of `Assert.ThrowsException` (deprecated) -- removed in v4.\n7. Run a clean build to establish a baseline of existing errors\u002Fwarnings.\n\n### Step 2: Update packages to MSTest v4\n\nFirst resolve the latest stable v4 version from the configured package source. Pin that exact\nversion consistently in the metapackage, individual packages, `MSTest.Sdk`, and central package\nmanagement.\n\n- For the `MSTest` metapackage, update its `PackageReference` to the resolved exact version.\n- For individual packages, update `MSTest.TestFramework` and `MSTest.TestAdapter` to that same version.\n- For `MSTest.Sdk`, update the SDK version in the project or `global.json` pin to that same version.\n\nRun `dotnet restore`, then `dotnet build`. Collect all errors for Step 3.\n\n### Step 3: Resolve source breaking changes\n\nWork through compilation errors systematically. Use this quick-lookup table to identify all applicable changes, then apply each fix:\n\n| Error \u002F Pattern in code | Breaking change | Fix |\n|---|---|---|\n| Custom `TestMethodAttribute` overrides `Execute` | Execute removed | Change to `ExecuteAsync` returning `Task\u003CTestResult[]>` (3.1) |\n| `[TestMethod(\"name\")]` or custom attribute constructor | CallerInfo params added | Use `DisplayName = \"name\"` named param; propagate CallerInfo in subclasses (3.2) |\n| `ClassCleanupBehavior.EndOfClass` | Enum removed | Remove argument: just `[ClassCleanup]` (3.3) |\n| `TestContext.Properties.Contains(\"key\")` | `Properties` is `IDictionary\u003Cstring, object>` | Change to `ContainsKey(\"key\")` (3.4) |\n| `[Timeout(TestTimeout.Infinite)]` | `TestTimeout` enum removed | Replace with `[Timeout(int.MaxValue)]` (3.5) |\n| `TestContext.ManagedType` | Property removed | Use `FullyQualifiedTestClassName` (3.6) |\n| `Assert.AreEqual(a, b, \"msg {0}\", arg)` | Message+params overloads removed | Use string interpolation: `$\"msg {arg}\"` (3.7) |\n| `Assert.ThrowsException\u003CT>(...)` | Renamed | Replace with `Assert.ThrowsExactly\u003CT>(...)` or `Assert.Throws\u003CT>(...)` (3.7) |\n| `Assert.IsInstanceOfType\u003CT>(obj, out var t)` | Out parameter removed | Use `var t = Assert.IsInstanceOfType\u003CT>(obj)` (3.7) |\n| `[ExpectedException(typeof(T))]` | Attribute removed | Move assertion into test body: `Assert.ThrowsExactly\u003CT>(() => ...)` (3.8) |\n| Project targets net5.0, net6.0, or net7.0 | TFM dropped | Change to net8.0 or net9.0 (3.9) |\n\n> **Important**: Scan the entire project for ALL patterns above before starting fixes. Multiple breaking changes often coexist in the same project.\n\n#### 3.1 TestMethodAttribute.Execute -> ExecuteAsync\n\nIf you have custom `TestMethodAttribute` subclasses that override `Execute`, change to `ExecuteAsync`. This change was made because the v3 synchronous `Execute` API caused deadlocks when test code used `async`\u002F`await` internally -- the synchronous wrapper would block the thread while the async operation needed that same thread to complete.\n\n```csharp\n\u002F\u002F Before (v3)\npublic sealed class MyTestMethodAttribute : TestMethodAttribute\n{\n    public override TestResult[] Execute(ITestMethod testMethod)\n    {\n        \u002F\u002F custom logic\n        return result;\n    }\n}\n\n\u002F\u002F After (v4) -- Option A: wrap synchronous logic with Task.FromResult\npublic sealed class MyTestMethodAttribute : TestMethodAttribute\n{\n    public override Task\u003CTestResult[]> ExecuteAsync(ITestMethod testMethod)\n    {\n        \u002F\u002F custom logic (synchronous)\n        return Task.FromResult(result);\n    }\n}\n\n\u002F\u002F After (v4) -- Option B: make properly async\npublic sealed class MyTestMethodAttribute : TestMethodAttribute\n{\n    public override async Task\u003CTestResult[]> ExecuteAsync(ITestMethod testMethod)\n    {\n        \u002F\u002F custom async logic\n        return await base.ExecuteAsync(testMethod);\n    }\n}\n```\n\nUse `Task.FromResult` when your override logic is purely synchronous. Use `async`\u002F`await` when you call `base.ExecuteAsync` or other async methods.\n\n#### 3.2 TestMethodAttribute CallerInfo constructor\n\n`TestMethodAttribute` now uses `[CallerFilePath]` and `[CallerLineNumber]` parameters in its constructor.\n\n**If you inherit from TestMethodAttribute**, propagate caller info to the base class:\n\n```csharp\npublic class MyTestMethodAttribute : TestMethodAttribute\n{\n    public MyTestMethodAttribute(\n        [CallerFilePath] string callerFilePath = \"\",\n        [CallerLineNumber] int callerLineNumber = -1)\n        : base(callerFilePath, callerLineNumber)\n    {\n    }\n}\n```\n\nIf the subclass has its own display-name constructor, do not pass that string to\nthe v4 base constructor. Propagate only caller information and assign the\n`DisplayName` property:\n\n```csharp\npublic sealed class NamedTestMethodAttribute : TestMethodAttribute\n{\n    public NamedTestMethodAttribute(\n        string displayName,\n        [CallerFilePath] string callerFilePath = \"\",\n        [CallerLineNumber] int callerLineNumber = -1)\n        : base(callerFilePath, callerLineNumber)\n    {\n        DisplayName = displayName;\n    }\n}\n```\n\n**If you use `[TestMethodAttribute(\"Custom display name\")]`**, switch to the named parameter syntax:\n\n```csharp\n\u002F\u002F Before (v3)\n[TestMethodAttribute(\"Custom display name\")]\n\n\u002F\u002F After (v4)\n[TestMethodAttribute(DisplayName = \"Custom display name\")]\n```\n\n#### 3.3 ClassCleanupBehavior enum removed\n\nThe `ClassCleanupBehavior` enum is removed. In v3, this enum controlled whether class cleanup ran at end of class (`EndOfClass`) or end of assembly (`EndOfAssembly`). In v4, class cleanup always runs at end of class. Remove the enum argument:\n\n```csharp\n\u002F\u002F Before (v3)\n[ClassCleanup(ClassCleanupBehavior.EndOfClass)]\npublic static void ClassCleanup(TestContext testContext) { }\n\n\u002F\u002F After (v4)\n[ClassCleanup]\npublic static void ClassCleanup(TestContext testContext) { }\n```\n\nIf you previously used `ClassCleanupBehavior.EndOfAssembly`, move that cleanup logic to an `[AssemblyCleanup]` method instead.\n\n#### 3.4 TestContext.Properties type change\n\n`TestContext.Properties` changed from `IDictionary` to `IDictionary\u003Cstring, object>`. Update any `Contains` calls to `ContainsKey`:\n\n```csharp\n\u002F\u002F Before (v3)\ntestContext.Properties.Contains(\"key\");\n\n\u002F\u002F After (v4)\ntestContext.Properties.ContainsKey(\"key\");\n```\n\n#### 3.5 TestTimeout enum removed\n\nThe `TestTimeout` enum (with only `TestTimeout.Infinite`) is removed. Replace with `int.MaxValue`:\n\n```csharp\n\u002F\u002F Before (v3)\n[Timeout(TestTimeout.Infinite)]\n\n\u002F\u002F After (v4)\n[Timeout(int.MaxValue)]\n```\n\n#### 3.6 TestContext.ManagedType removed\n\nThe `TestContext.ManagedType` property is removed. Use `TestContext.FullyQualifiedTestClassName` instead.\n\n#### 3.7 Assert API signature changes\n\n- **Message + params removed**: Assert methods that accepted both `message` and `object[]` parameters now accept only `message`. Use string interpolation instead of format strings:\n\n```csharp\n\u002F\u002F Before (v3)\nAssert.AreEqual(expected, actual, \"Expected {0} but got {1}\", expected, actual);\n\n\u002F\u002F After (v4)\nAssert.AreEqual(expected, actual, $\"Expected {expected} but got {actual}\");\n```\n\n- **Assert.ThrowsException renamed**: The `Assert.ThrowsException` APIs are renamed. Use `Assert.ThrowsExactly` (strict type match) or `Assert.Throws` (accepts derived exception types):\n\n```csharp\n\u002F\u002F Before (v3)\nAssert.ThrowsException\u003CInvalidOperationException>(() => DoSomething());\n\n\u002F\u002F After (v4) -- exact type match (same behavior as old ThrowsException)\nAssert.ThrowsExactly\u003CInvalidOperationException>(() => DoSomething());\n\n\u002F\u002F After (v4) -- also catches derived exception types\nAssert.Throws\u003CInvalidOperationException>(() => DoSomething());\n```\n\n- **Assert.IsInstanceOfType out parameter changed**: `Assert.IsInstanceOfType\u003CT>(x, out var t)` changes to `var t = Assert.IsInstanceOfType\u003CT>(x)`:\n\n```csharp\n\u002F\u002F Before (v3)\nAssert.IsInstanceOfType\u003CMyType>(obj, out var typed);\n\n\u002F\u002F After (v4)\nvar typed = Assert.IsInstanceOfType\u003CMyType>(obj);\n```\n\nApply this assignment rewrite to every occurrence, preserving the concrete asserted type and all\nlater uses of the typed variable. When source is available, show or edit the actual method rather\nthan substituting a generic `MyType` example, then verify that the project compiles.\n\n- **Assert.AreEqual for IEquatable\\\u003CT\\> removed**: If you get generic type inference errors, explicitly specify the type argument as `object`.\n\n#### 3.8 ExpectedExceptionAttribute removed\n\nThe `[ExpectedException]` attribute is removed in v4. In MSTest 3.2, the `MSTEST0006` analyzer was introduced to flag `[ExpectedException]` usage and suggest migrating to `Assert.ThrowsExactly` while still on v3 (a non-breaking change). In v4, the attribute is gone entirely. Migrate to `Assert.ThrowsExactly`:\n\n```csharp\n\u002F\u002F Before (v3)\n[ExpectedException(typeof(InvalidOperationException))]\n[TestMethod]\npublic void TestMethod()\n{\n    MyCall();\n}\n\n\u002F\u002F After (v4)\n[TestMethod]\npublic void TestMethod()\n{\n    Assert.ThrowsExactly\u003CInvalidOperationException>(() => MyCall());\n}\n```\n\n**When the test has setup code before the throwing call**, wrap only the throwing call in the lambda -- keep Arrange\u002FAct separation clear:\n\n```csharp\n\u002F\u002F Before (v3)\n[ExpectedException(typeof(ArgumentNullException))]\n[TestMethod]\npublic void Validate_NullInput_Throws()\n{\n    var service = new ValidationService();\n    service.Validate(null);  \u002F\u002F throws here\n}\n\n\u002F\u002F After (v4)\n[TestMethod]\npublic void Validate_NullInput_Throws()\n{\n    var service = new ValidationService();\n    Assert.ThrowsExactly\u003CArgumentNullException>(() => service.Validate(null));\n}\n```\n\n**For async test methods**, use `Assert.ThrowsExactlyAsync`:\n\n```csharp\n\u002F\u002F Before (v3)\n[ExpectedException(typeof(HttpRequestException))]\n[TestMethod]\npublic async Task FetchData_BadUrl_Throws()\n{\n    await client.GetAsync(\"https:\u002F\u002Flocalhost:0\");\n}\n\n\u002F\u002F After (v4)\n[TestMethod]\npublic async Task FetchData_BadUrl_Throws()\n{\n    await Assert.ThrowsExactlyAsync\u003CHttpRequestException>(\n        () => client.GetAsync(\"https:\u002F\u002Flocalhost:0\"));\n}\n```\n\n**If `[ExpectedException]` used the `AllowDerivedTypes` property**, use `Assert.ThrowsAsync\u003CT>` (base type matching) instead of `Assert.ThrowsExactlyAsync\u003CT>` (exact type matching).\n\nFor a focused migration, convert every attributed method in the supplied source, wrap only the\nstatement expected to throw, preserve arrange\u002Fsetup statements outside the lambda, and run the\naffected tests. A prose-only API substitution is incomplete when editable project files are present.\n\n#### 3.9 Dropped target frameworks\n\nMSTest v4 supports **.NET 8 and later** and **.NET Framework 4.6.2 and later**. Platform-specific supported targets also include **uap10.0.16299** (UWP), with modern UWP and WinUI using their corresponding supported Windows-specific .NET TFMs. .NET Core 3.1 through .NET 7 are dropped.\n\nIf the test project targets an unsupported framework, update `TargetFramework`:\n\n```xml\n\u003C!-- Before -->\n\u003CTargetFramework>net6.0\u003C\u002FTargetFramework>\n\n\u003C!-- After -->\n\u003CTargetFramework>net8.0\u003C\u002FTargetFramework>\n```\n\n#### 3.10 Unfolding strategy moved to TestMethodAttribute\n\nThe `UnfoldingStrategy` property (introduced in MSTest 3.7) has moved from individual data source attributes (`DataRowAttribute`, `DynamicDataAttribute`) to `TestMethodAttribute`.\n\n#### 3.11 ConditionBaseAttribute.ShouldRun renamed\n\nThe `ConditionBaseAttribute.ShouldRun` property is renamed to `IsConditionMet`.\n\n#### 3.12 Internal\u002Fremoved types\n\nSeveral types previously public are now internal or removed:\n\n- `MSTestDiscoverer`, `MSTestExecutor`, `AssemblyResolver`, `LogMessageListener`\n- `TestExecutionManager`, `TestMethodInfo`, `TestResultExtensions`\n- `UnitTestOutcomeExtensions`, `GenericParameterHelper`\n- `ITestMethod` in PlatformServices assembly (the one in TestFramework is unchanged)\n\nIf your code references any of these, find alternative approaches or remove the dependency.\n\n### Step 4: Address behavioral changes\n\nThese changes won't cause build errors but may affect test runtime behavior.\n\n| Symptom | Cause | Fix |\n|---|---|---|\n| Tests show as new in Azure DevOps \u002F test history lost | `TestCase.Id` generation changed (4.3) | No code fix; history will re-baseline |\n| `TestContext.TestName` throws in `[ClassInitialize]` | v4 enforces lifecycle scope (4.2) | Move access to `[TestInitialize]` or test methods |\n| Tests not discovered \u002F discovery failures | `TreatDiscoveryWarningsAsErrors` now true (4.4) | Fix warnings, or set to false in .runsettings |\n| Tests hang that didn't before | AppDomain disabled by default (4.1) | Set `DisableAppDomain` to false in .runsettings `RunConfiguration` |\n| 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` |\n| New warnings from analyzers | Analyzer severities upgraded (4.6) | Fix warnings or suppress in .editorconfig |\n\n#### 4.1 DisableAppDomain defaults to true\n\nAppDomains are disabled by default. On .NET Framework, when running inside testhost (the default for `dotnet test` and VS), MSTest re-enables AppDomains automatically. If you need to explicitly control AppDomain isolation, set it via `.runsettings`:\n\n```xml\n\u003CRunSettings>\n  \u003CRunConfiguration>\n    \u003CDisableAppDomain>false\u003C\u002FDisableAppDomain>\n  \u003C\u002FRunConfiguration>\n\u003C\u002FRunSettings>\n```\n\n#### 4.2 TestContext throws when used incorrectly\n\nMSTest v4 now throws when accessing test-specific properties in the wrong lifecycle stage:\n\n- `TestContext.FullyQualifiedTestClassName` -- cannot be accessed in `[AssemblyInitialize]`\n- `TestContext.TestName` -- cannot be accessed in `[AssemblyInitialize]` or `[ClassInitialize]`\n\n**Fix**: Move any code that accesses `TestContext.TestName` from `[ClassInitialize]` to `[TestInitialize]` or individual test methods, where per-test context is available. Do not replace `TestName` with `FullyQualifiedTestClassName` as a workaround -- they have different semantics.\n\n#### 4.3 TestCase.Id generation changed\n\nThe generation algorithm for `TestCase.Id` has changed to fix long-standing bugs. This may affect Azure DevOps test result tracking (e.g., test failure tracking over time). There is no code fix needed, but be aware of test result history discontinuity.\n\n#### 4.4 TreatDiscoveryWarningsAsErrors defaults to true\n\nv4 uses stricter defaults. Discovery warnings are now treated as errors, which means tests that previously ran despite discovery issues may now fail entirely. If you see unexpected test failures after upgrading (not build errors, but tests not being discovered), check for discovery warnings. To restore v3 behavior while you investigate:\n\n```xml\n\u003CRunSettings>\n  \u003CMSTest>\n    \u003CTreatDiscoveryWarningsAsErrors>false\u003C\u002FTreatDiscoveryWarningsAsErrors>\n  \u003C\u002FMSTest>\n\u003C\u002FRunSettings>\n```\n\n> **Recommended**: Fix the underlying discovery warnings rather than suppressing this setting.\n\n#### 4.5 MSTest.Sdk and vstest.console compatibility\n\nMSTest.Sdk defaults to Microsoft.Testing.Platform (MTP) mode. MSTest.Sdk v3\nstill added `Microsoft.NET.Test.Sdk` in that mode; v4 removes the unnecessary\nreference. A CI pipeline that separately invokes `vstest.console` can therefore\ndrop to zero discovered tests immediately after the v4 upgrade.\n\n**Option A -- Preserve MTP and transitional VSTest discovery**: Add the exact\ncompatible `Microsoft.NET.Test.Sdk` package explicitly. This is the least\ndisruptive fix when MTP remains the primary runner but an existing\n`vstest.console` job cannot be removed yet:\n\nUse a direct `PackageReference` with the exact compatible version resolved from\nthe configured feed. Under Central Package Management, add or update the\n`Microsoft.NET.Test.Sdk` `PackageVersion` in `Directory.Packages.props` and keep\nthe project reference versionless. Do not copy a fixed example version.\n\nVerify with the actual `vstest.console` command; a passing `dotnet test` MTP run\ndoes not prove VSTest discovery.\n\n**Option B -- Switch the project to VSTest mode**: Set the `UseVSTest` property.\nMSTest.Sdk then adds `Microsoft.NET.Test.Sdk`:\n\n```xml\n\u003CPropertyGroup>\n  \u003CUseVSTest>true\u003C\u002FUseVSTest>\n\u003C\u002FPropertyGroup>\n```\n\nKeep the resolved exact `MSTest.Sdk` v4 pin from Step 2; this option changes the runner, not the\nselected MSTest version or target framework.\n\n**Option C -- Switch CI to `dotnet test`**: Replace `vstest.console` invocations in your CI pipeline with `dotnet test`. This works natively with MTP and is the recommended long-term approach for MSTest.Sdk projects.\n\nDo not say this behavior predates v4: removal of the transitive\n`Microsoft.NET.Test.Sdk` reference in MTP mode is one of the v4 behavioral\nbreaking changes.\n\n#### 4.6 Analyzer severity changes\n\nMultiple analyzers have been upgraded from Info to Warning by default:\n\n- MSTEST0001, MSTEST0007, MSTEST0017, MSTEST0023, MSTEST0024, MSTEST0025\n- MSTEST0030, MSTEST0031, MSTEST0032, MSTEST0035, MSTEST0037, MSTEST0045\n\nReview and fix any new warnings, or suppress them in `.editorconfig` if intentional.\n\n### Step 5: Verify\n\n1. Run `dotnet build` -- confirm zero errors and review any new warnings\n2. Run `dotnet test` -- confirm all tests pass\n3. Compare test results (pass\u002Ffail counts) to the pre-migration baseline\n4. If using Azure DevOps test tracking, be aware that `TestCase.Id` changes may affect history continuity\n5. Check that no tests were silently dropped due to stricter discovery\n\n## Validation\n\n- [ ] All MSTest packages updated to 4.x\n- [ ] Project builds with zero errors\n- [ ] All tests pass with `dotnet test`\n- [ ] Custom `TestMethodAttribute` subclasses updated for `ExecuteAsync` and CallerInfo\n- [ ] `ExpectedExceptionAttribute` replaced with `Assert.ThrowsExactly`\n- [ ] `Assert.ThrowsException` replaced with `Assert.ThrowsExactly` (or `Assert.Throws`)\n- [ ] `ClassCleanupBehavior` enum usages removed\n- [ ] `TestContext.Properties.Contains` updated to `ContainsKey`\n- [ ] All target frameworks are net8.0+, net9.0, net462+, uap10.0.16299, or WinUI\n- [ ] Behavioral changes reviewed and addressed\n- [ ] No tests were lost during migration (compare test counts)\n\n## Related Skills\n\n- `writing-mstest-tests` -- for modern MSTest v4 assertion APIs and test authoring best practices\n- `run-tests` -- for running tests after migration\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Custom `TestMethodAttribute` still overrides `Execute` | Change to `ExecuteAsync` returning `Task\u003CTestResult[]>` |\n| `TestMethodAttribute(\"display name\")` no longer compiles | Use `TestMethodAttribute(DisplayName = \"display name\")` |\n| `ClassCleanupBehavior` enum not found | Remove the enum argument; `[ClassCleanup]` now always runs at end of class. For end-of-assembly cleanup, use `[AssemblyCleanup]` |\n| `TestContext.Properties.Contains` missing | Use `ContainsKey` -- `Properties` is now `IDictionary\u003Cstring, object>` |\n| `ExpectedException` attribute not found | Replace with `Assert.ThrowsExactly\u003CT>(() => ...)` inside the test body |\n| `Assert.ThrowsException` not found | Replace with `Assert.ThrowsExactly` (or `Assert.Throws` for derived types) |\n| `Assert.AreEqual` with format string args fails | Use string interpolation: `$\"message {value}\"` |\n| Tests hang that didn't before | AppDomain is disabled by default; on .NET Fx in testhost it is re-enabled automatically |\n| Azure DevOps test history breaks | Expected -- `TestCase.Id` generation changed; no code fix, results will re-baseline |\n| Discovery warnings now fail the run | `TreatDiscoveryWarningsAsErrors` is true by default; fix the discovery warnings |\n| Net6.0\u002Fnet7.0 targets don't compile | Update to net8.0 -- MSTest v4 supports net8.0, net9.0, net462, uap10.0.16299, modern UWP, and WinUI |\n",{"name":5,"license":15,"description":24},"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\u002FCS0103\u002FCS1061\u002FCS1615; ExecuteAsync, CallerInfo, DisplayName, or custom TestMethodAttribute; ClassCleanupBehavior; ContainsKey; ThrowsExactly or ExpectedException; IsInstanceOfType out parameters; TestTimeout.Infinite; ManagedType; net6\u002Fnet7 compatibility; TestCase.Id history; TestName in ClassInitialize; TreatDiscoveryWarningsAsErrors; discovery errors after a clean build; and MSTest.Sdk\u002FMTP or vstest.console discovery changes. Do not use for v1\u002Fv2-to-v3 leftovers, framework conversion, runner-only migration, or a general .NET upgrade.\n","main","30954af1dcd1a74b63f05deb2e2c41e5ecae4a82","13-Testing-QA\u002Fmigrate-mstest-v3-to-v4","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack","https:\u002F\u002Fgithub.com\u002Fitsmejay18","2026-09-18 16:06:36",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill migrate-mstest-v3-to-v4",{"tool":37,"command":38},"bunx","bunx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill migrate-mstest-v3-to-v4",{"tool":40,"command":41},"pnpm","pnpm dlx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill migrate-mstest-v3-to-v4","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F13-Testing-QA\u002Fmigrate-mstest-v3-to-v4\u002FSKILL.md",true,[],[46,53,60,67,74,81],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M7D2RKBHPZ3E1RNN5DWHT550","vectorization","Design, implement, optimize, and review SIMD code in .NET. USE FOR: vectorizing scalar loops with TensorPrimitives, Vector64\u002F128\u002F256\u002F512, or platform hardware intrinsics; reviewing existing SIMD code, including Vector\u003CT>, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. DO NOT USE FOR: performance work unrelated to SIMD or vectorization.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fvectorization\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7D2RDJ7RN3QK8GJR0QTER1D","resolve-project-references","Guide for interpreting ResolveProjectReferences time in MSBuild performance summaries. Activate when ResolveProjectReferences appears as the most expensive target and developers are trying to optimize it directly. Explains that the reported time includes wait time for dependent project builds and is misleading. Guides users to focus on task self-time instead. Do not activate for general build performance -- use build-perf-diagnostics instead.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fresolve-project-references\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7D2R1H2GTNZYHG9YRX3JDQW","optimizing-ef-core-queries","Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster. Use whenever an EF Core or DbContext query or data-access path is slow or should be made faster — whether or not EF Core owns the database schema. For EF Core, not Dapper or raw ADO.NET.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Foptimizing-ef-core-queries\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7D2QREG04W1YT0NEBHEW5C9","microbenchmarking","Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks. Also activate when microbenchmarking .NET code would be useful and BenchmarkDotNet is the likely tool. Consider activating when answering a .NET performance question requires measurement and BenchmarkDotNet may be needed. Covers microbenchmark design, BDN configuration and project setup, how to run BDN microbenchmarks efficiently and effectively, and using BDN for side-by-side performance comparisons. Do NOT use for profiling\u002Ftracing .NET code (dotnet-trace, PerfView), production telemetry, or load\u002Fstress testing (Crank, k6).","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fmicrobenchmarking\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7D2QGE175XWPZVACVH2868Z","incremental-build","Guide for optimizing MSBuild incremental builds. USE FOR: builds slower than expected on subsequent runs, 'nothing changed but it rebuilds anyway', diagnosing why targets re-execute unnecessarily, fixing broken no-op builds. Covers 8 common causes: missing Inputs\u002FOutputs on custom targets, volatile properties in output paths (timestamps\u002FGUIDs), file writes outside tracked Outputs, missing FileWrites registration, glob changes, Visual Studio Fast Up-to-Date Check (FUTDC) issues. Key diagnostic: look for 'Building target completely' vs 'Skipping target' in binlog. DO NOT USE FOR: first-time build slowness (use build-perf-baseline), parallelism issues (use build-parallelism), evaluation-phase slowness (use eval-performance), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fincremental-build\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7D2Q1DQTC6K49R73WQTTPSB","eval-performance","Guide for diagnosing and improving MSBuild project evaluation performance. USE FOR: builds slow before any compilation starts, high evaluation time in binlog analysis, expensive glob patterns walking large directories (node_modules, .git, bin\u002Fobj), deep import chains (>20 levels), preprocessed output >10K lines indicating heavy evaluation, property functions with file I\u002FO ($([System.IO.File]::ReadAllText(...))), multiple evaluations per project. Covers the 5 MSBuild evaluation phases, glob optimization via DefaultItemExcludes, import chain analysis with \u002Fpp preprocessing. DO NOT USE FOR: compilation-time slowness (use build-perf-diagnostics), incremental build issues (use incremental-build), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Feval-performance\u002FSKILL.md",[],[]]