From 27d61c1ddcf2876f50d5b7f0d3839480d2188c81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jun 2026 15:59:44 -0700 Subject: [PATCH 01/11] Bump the dotnet group with 1 update (#54404) Bumps Microsoft.Extensions.Hosting from 10.0.5 to 10.0.8 --- updated-dependencies: - dependency-name: Microsoft.Extensions.Hosting dependency-version: 10.0.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Extensions.Hosting dependency-version: 10.0.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Extensions.Hosting dependency-version: 10.0.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../snippets/transactions/Abstractions/Abstractions.csproj | 2 +- docs/orleans/grains/snippets/transactions/Client/Client.csproj | 2 +- docs/orleans/grains/snippets/transactions/Server/Server.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/orleans/grains/snippets/transactions/Abstractions/Abstractions.csproj b/docs/orleans/grains/snippets/transactions/Abstractions/Abstractions.csproj index 91d3ed9daabf9..fbc756677e109 100644 --- a/docs/orleans/grains/snippets/transactions/Abstractions/Abstractions.csproj +++ b/docs/orleans/grains/snippets/transactions/Abstractions/Abstractions.csproj @@ -1,7 +1,7 @@ - + diff --git a/docs/orleans/grains/snippets/transactions/Client/Client.csproj b/docs/orleans/grains/snippets/transactions/Client/Client.csproj index fede8e757dd6c..cc2278e595fc1 100644 --- a/docs/orleans/grains/snippets/transactions/Client/Client.csproj +++ b/docs/orleans/grains/snippets/transactions/Client/Client.csproj @@ -5,7 +5,7 @@ - + diff --git a/docs/orleans/grains/snippets/transactions/Server/Server.csproj b/docs/orleans/grains/snippets/transactions/Server/Server.csproj index b28e7fbf738fa..115c1e042315f 100644 --- a/docs/orleans/grains/snippets/transactions/Server/Server.csproj +++ b/docs/orleans/grains/snippets/transactions/Server/Server.csproj @@ -5,7 +5,7 @@ - + From 0ab44c0148c9b87427e2fda545faed85793ce216 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:05:20 -0700 Subject: [PATCH 02/11] Bump the dotnet group with 3 updates (#54402) Bumps Microsoft.Extensions.AI.OpenAI from 10.5.2 to 10.6.0 Bumps Microsoft.Extensions.Configuration from 10.0.7 to 10.0.8 Bumps Microsoft.Extensions.Configuration.UserSecrets from 10.0.7 to 10.0.8 --- updated-dependencies: - dependency-name: Microsoft.Extensions.AI.OpenAI dependency-version: 10.6.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dotnet - dependency-name: Microsoft.Extensions.Configuration dependency-version: 10.0.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Extensions.Configuration.UserSecrets dependency-version: 10.0.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../azure-openai/ExtensionsAzureOpenAI.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/ai/quickstarts/snippets/prompt-completion/azure-openai/ExtensionsAzureOpenAI.csproj b/docs/ai/quickstarts/snippets/prompt-completion/azure-openai/ExtensionsAzureOpenAI.csproj index d15bd0545bd0f..601219c3b6fbe 100644 --- a/docs/ai/quickstarts/snippets/prompt-completion/azure-openai/ExtensionsAzureOpenAI.csproj +++ b/docs/ai/quickstarts/snippets/prompt-completion/azure-openai/ExtensionsAzureOpenAI.csproj @@ -10,9 +10,9 @@ - - - + + + From 18f192e3b6182916d527271a7aa4d2713365a3eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:06:07 -0700 Subject: [PATCH 03/11] Bump the dotnet group with 2 updates (#54401) Bumps Microsoft.Extensions.Configuration.Binder from 10.0.7 to 10.0.8 Bumps Microsoft.Extensions.Hosting from 10.0.7 to 10.0.8 --- updated-dependencies: - dependency-name: Microsoft.Extensions.Configuration.Binder dependency-version: 10.0.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Extensions.Hosting dependency-version: 10.0.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../console-ienumerable/console-di-ienumerable.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/core/extensions/dependency-injection/snippets/console-ienumerable/console-di-ienumerable.csproj b/docs/core/extensions/dependency-injection/snippets/console-ienumerable/console-di-ienumerable.csproj index f78753e0f767b..5db61a5b48163 100644 --- a/docs/core/extensions/dependency-injection/snippets/console-ienumerable/console-di-ienumerable.csproj +++ b/docs/core/extensions/dependency-injection/snippets/console-ienumerable/console-di-ienumerable.csproj @@ -9,8 +9,8 @@ - - + + From b97c55c3259cede78ca293b58c192a32cd143961 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:06:46 -0700 Subject: [PATCH 04/11] Bump the dotnet group with 2 updates (#54400) Bumps Microsoft.Extensions.Hosting from 10.0.5 to 10.0.8 Bumps Microsoft.Extensions.Logging.Console from 10.0.5 to 10.0.8 --- updated-dependencies: - dependency-name: Microsoft.Extensions.Hosting dependency-version: 10.0.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Extensions.Logging.Console dependency-version: 10.0.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../console-formatter-simple/console-formatter-simple.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/core/extensions/snippets/logging/console-formatter-simple/console-formatter-simple.csproj b/docs/core/extensions/snippets/logging/console-formatter-simple/console-formatter-simple.csproj index 0e9db4f790d2e..7283b8d295435 100644 --- a/docs/core/extensions/snippets/logging/console-formatter-simple/console-formatter-simple.csproj +++ b/docs/core/extensions/snippets/logging/console-formatter-simple/console-formatter-simple.csproj @@ -9,8 +9,8 @@ - - + + From 8ea4d167fd3ed0d955124e056def64db61137cc3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:07:26 -0700 Subject: [PATCH 05/11] Bump the dotnet group with 4 updates (#54393) Bumps Microsoft.Extensions.AI from 10.4.1 to 10.6.0 Bumps Microsoft.Extensions.AI.OpenAI from 10.4.1 to 10.6.0 Bumps Microsoft.Extensions.Configuration from 10.0.5 to 10.0.8 Bumps Microsoft.Extensions.Configuration.UserSecrets from 10.0.5 to 10.0.8 --- updated-dependencies: - dependency-name: Microsoft.Extensions.AI dependency-version: 10.6.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dotnet - dependency-name: Microsoft.Extensions.AI.OpenAI dependency-version: 10.6.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dotnet - dependency-name: Microsoft.Extensions.Configuration dependency-version: 10.0.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Extensions.Configuration.UserSecrets dependency-version: 10.0.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../function-calling/openai/FunctionCallingAI.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/ai/quickstarts/snippets/function-calling/openai/FunctionCallingAI.csproj b/docs/ai/quickstarts/snippets/function-calling/openai/FunctionCallingAI.csproj index a6f28d640889a..8076e05d18dc3 100644 --- a/docs/ai/quickstarts/snippets/function-calling/openai/FunctionCallingAI.csproj +++ b/docs/ai/quickstarts/snippets/function-calling/openai/FunctionCallingAI.csproj @@ -8,10 +8,10 @@ - - - - + + + + From 225dece41ecaa5485c6e8ae41c57fbda3242dfe8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:08:01 -0700 Subject: [PATCH 06/11] Bump the dotnet group with 1 update (#54385) Bumps Spectre.Console from 0.55.2 to 0.56.0 --- updated-dependencies: - dependency-name: Spectre.Console dependency-version: 0.56.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dotnet ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../snippets/resource-monitoring/resource-monitoring.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/diagnostics/snippets/resource-monitoring/resource-monitoring.csproj b/docs/core/diagnostics/snippets/resource-monitoring/resource-monitoring.csproj index 37ad5cf099f55..40f65e6c216e4 100644 --- a/docs/core/diagnostics/snippets/resource-monitoring/resource-monitoring.csproj +++ b/docs/core/diagnostics/snippets/resource-monitoring/resource-monitoring.csproj @@ -12,7 +12,7 @@ - + From 49f56c2fa1e1b88543a516e4284ddf10d1aed1ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:08:29 -0700 Subject: [PATCH 07/11] Bump the dotnet group with 1 update (#54384) Bumps Microsoft.NET.Test.Sdk from 18.3.0 to 18.6.0 --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-version: 18.6.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dotnet ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../csharp/PrimeService.Tests/PrimeService.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService.Tests.csproj b/samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService.Tests.csproj index 734f7082665a1..c7737fdf6092a 100644 --- a/samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService.Tests.csproj +++ b/samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService.Tests.csproj @@ -7,7 +7,7 @@ - + From 68cca494dfae5405a1aa674700d1a6a872d671ef Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Tue, 16 Jun 2026 17:37:47 +0200 Subject: [PATCH 08/11] Add NETSDK1242 SDK error documentation (#54379) * Add NETSDK1242 SDK error documentation Document the NETSDK1242 build error, raised when a project selects the Mono runtime for a mobile platform (android, ios, maccatalyst, tvos) while targeting .NET 11 or later. * Clarify NETSDK1242 applies to .NET 11 and later * Add trailing newline to index.md (MD047) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add trailing newline to netsdk1242.md (MD047) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Clarify NETSDK1242 resolution guidance The previous wording told users to build with the .NET 10 SDK, which does not resolve the error when the project targets .NET 11.0 or later. Recommend the two real fixes: use the CoreCLR runtime, or retarget the project to .NET 10. Drop the global.json approach, which is unnecessary, and align the title and body on ".NET 11.0 and later". Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Drop tools-diagnostics TOC change Remove the NETSDK1242 entry from the Tools diagnostics navigation. The error reference page and the SDK errors index cover the diagnostic. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add NETSDK1242 to tools-diagnostics TOC List the error reference page in the Tools diagnostics navigation, matching every other NETSDK error page and avoiding an orphaned-article build warning. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Drop UseMonoRuntime XML snippet from NETSDK1242 page Keep the resolution wording but remove the code block; the property change is clear from the text. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Tighten NETSDK1242 resolution list Remove the blank line between the two resolution bullets. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update docs/core/tools/sdk-errors/netsdk1242.md Co-authored-by: Vitek Karas <10670590+vitek-karas@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Milos Kotlar Co-authored-by: Vitek Karas <10670590+vitek-karas@users.noreply.github.com> --- docs/core/tools/sdk-errors/index.md | 1 + docs/core/tools/sdk-errors/netsdk1242.md | 27 ++++++++++++++++++++++++ docs/navigate/tools-diagnostics/toc.yml | 2 ++ 3 files changed, 30 insertions(+) create mode 100644 docs/core/tools/sdk-errors/netsdk1242.md diff --git a/docs/core/tools/sdk-errors/index.md b/docs/core/tools/sdk-errors/index.md index d608cf78d4362..35401e6bcc103 100644 --- a/docs/core/tools/sdk-errors/index.md +++ b/docs/core/tools/sdk-errors/index.md @@ -382,3 +382,4 @@ This list is a complete list of the errors that you might get from the .NET SDK |[NETSDK1238](netsdk1238.md)|The current .NET SDK ({0}) has known vulnerabilities ({1}).{2} See | |[NETSDK1239](netsdk1239.md)|The current .NET SDK ({0}) is end of life as of {1}. It will receive no further security updates: | |[NETSDK1240](netsdk1240.md)|The current .NET SDK ({0}) has no newer release in its feature band. Update to version {1}: | +|[NETSDK1242](netsdk1242.md)|Building {0} projects with the Mono runtime is not supported in .NET 11.0 and later. Use the CoreCLR runtime or target .NET 10.0.| diff --git a/docs/core/tools/sdk-errors/netsdk1242.md b/docs/core/tools/sdk-errors/netsdk1242.md new file mode 100644 index 0000000000000..b41e3aabaf210 --- /dev/null +++ b/docs/core/tools/sdk-errors/netsdk1242.md @@ -0,0 +1,27 @@ +--- +title: "NETSDK1242: Building projects with the Mono runtime is not supported in .NET 11.0 and later" +description: Learn how to resolve build error NETSDK1242, which reports that the Mono runtime is not supported for the target mobile platform in .NET 11.0 and later. +ms.topic: error-reference +ms.date: 06/16/2026 +ai-usage: ai-assisted +f1_keywords: +- NETSDK1242 +--- +# NETSDK1242: Building projects with the Mono runtime is not supported in .NET 11.0 and later + +This error indicates that the project selects the Mono runtime (the `UseMonoRuntime` property is set to `true`) for a mobile target platform while targeting .NET 11.0 or later, where the Mono runtime is no longer supported for that platform. The full error message is similar to the following example: + +> NETSDK1242: Building ios projects with the Mono runtime is not supported in .NET 11.0 and later. Use the CoreCLR runtime or target .NET 10.0. + +The error applies to the `android`, `ios`, `maccatalyst`, and `tvos` target platforms. + +## Resolve the error + +Choose one of the following options: + +- Build the project with the CoreCLR runtime. Remove the `UseMonoRuntime` property from the project, or set it to `false`. +- If the project requires the Mono runtime, target .NET 10. Change the target framework to a .NET 10 mobile target framework moniker, for example `net10.0-android` or `net10.0-ios` + +## See also + +- [.NET SDK error and warning reference](index.md) diff --git a/docs/navigate/tools-diagnostics/toc.yml b/docs/navigate/tools-diagnostics/toc.yml index 0956f23e88898..a2862948c859f 100644 --- a/docs/navigate/tools-diagnostics/toc.yml +++ b/docs/navigate/tools-diagnostics/toc.yml @@ -99,6 +99,8 @@ items: href: ../../core/tools/sdk-errors/netsdk1239.md - name: NETSDK1240 href: ../../core/tools/sdk-errors/netsdk1240.md + - name: NETSDK1242 + href: ../../core/tools/sdk-errors/netsdk1242.md - name: BuildCheck rules items: - name: Index of rules From 7f17c879999f28be0553ea1a90f9c09e171242d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Tue, 16 Jun 2026 19:07:35 +0200 Subject: [PATCH 09/11] Document Assert.That custom assertions and de-emphasize StringAssert/CollectionAssert (#54185) * Document Assert.That custom assertions and deprecate StringAssert/CollectionAssert guidance - Add 'Create custom assertions with Assert.That' section explaining the singleton extensibility hook with a worked extension method example. - Note that StringAssert.That and CollectionAssert.That exist for the same pattern but recommend Assert.That for new code. - Disambiguate the singleton property from the MSTest 3.8 Assert.That(() => condition) expression-tree method. - Strengthen messaging that StringAssert and CollectionAssert are likely to be deprecated and aren't recommended due to discoverability issues. - Add ai-usage: ai-assisted and bump ms.date. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review: fix IsPrime imports, clarify Assert.That wording, move disambiguation NOTE Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address MSTest assertions review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ...testing-mstest-writing-tests-assertions.md | 76 ++++++++++++++++--- 1 file changed, 64 insertions(+), 12 deletions(-) diff --git a/docs/core/testing/unit-testing-mstest-writing-tests-assertions.md b/docs/core/testing/unit-testing-mstest-writing-tests-assertions.md index 16a7bb4cbf08c..8e5a690d88834 100644 --- a/docs/core/testing/unit-testing-mstest-writing-tests-assertions.md +++ b/docs/core/testing/unit-testing-mstest-writing-tests-assertions.md @@ -3,7 +3,8 @@ title: MSTest assertions description: Learn about MSTest assertions including Assert, StringAssert, and CollectionAssert classes for validating test results. author: Evangelink ms.author: amauryleve -ms.date: 07/15/2025 +ms.date: 06/04/2026 +ai-usage: ai-assisted --- # MSTest assertions @@ -20,8 +21,8 @@ MSTest provides three assertion classes: | `StringAssert` | String-specific assertions for patterns, substrings, and comparisons. | | `CollectionAssert` | Collection assertions for comparing and validating collections. | -> [!TIP] -> When functionality exists in both `Assert` and `StringAssert`/`CollectionAssert`, prefer the `Assert` class. The `Assert` class provides better discoverability and is the recommended choice for new code. `StringAssert` and `CollectionAssert` are maintained for backward compatibility. +> [!IMPORTANT] +> For new code, always use the `Assert` class. The `StringAssert` and `CollectionAssert` classes are likely to be deprecated in a future release. They're maintained primarily for backward compatibility, but they're not recommended because splitting assertions across three types hurts discoverability. All assertion methods accept an optional message parameter that displays when the assertion fails, helping you identify the cause: @@ -107,8 +108,8 @@ public async Task AssertExamples() Use the class to compare and examine strings. -> [!NOTE] -> All `StringAssert` methods have equivalents in the `Assert` class. Prefer the `Assert` methods for better discoverability. The `StringAssert` class is maintained for backward compatibility. +> [!WARNING] +> The `StringAssert` class is likely to be deprecated in a future release. It's maintained for backward compatibility only and isn't recommended for new code. All `StringAssert` methods have equivalents on the `Assert` class, which offers better discoverability. To migrate existing usages, see analyzer [MSTEST0046](mstest-analyzers/mstest0046.md). Available APIs are: @@ -122,8 +123,8 @@ Available APIs are: Use the class to compare collections of objects, or to verify the state of a collection. -> [!NOTE] -> When an equivalent method exists in the `Assert` class (such as `Assert.Contains`, `Assert.DoesNotContain`), prefer using `Assert` for better discoverability. The `CollectionAssert` class is maintained primarily for backward compatibility. +> [!WARNING] +> The `CollectionAssert` class is likely to be deprecated in a future release. It's maintained primarily for backward compatibility and isn't recommended for new code. When an equivalent method exists on `Assert` (such as `Assert.Contains`, `Assert.DoesNotContain`, or `Assert.HasCount`), use `Assert` for better discoverability. Available APIs are: @@ -139,17 +140,68 @@ Available APIs are: - - +## Create custom assertions with `Assert.That` + +The built-in assertion methods don't cover every scenario. To extend the assertion infrastructure with your own checks, MSTest exposes the singleton property as an extensibility hook. You add custom assertions as C# extension methods on the `Assert` instance type, and callers invoke them with the familiar `Assert.That.MyAssertion(...)` syntax. + +For better discoverability, organize project-wide assertions in a dedicated static class. Custom assertions reached through `Assert.That` show up alongside the built-in methods in IntelliSense, so consumers don't have to remember a separate helper type. + +### Author a custom assertion + +Add an extension method that targets the `Assert` type and throws when the condition fails: + +```csharp +using System; +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +public static class CustomAssertExtensions +{ + public static void IsPrime(this Assert assert, int value) + { + if (value < 2 || Enumerable.Range(2, (int)Math.Sqrt(value) - 1).Any(i => value % i == 0)) + { + throw new AssertFailedException($"Assert.That.IsPrime failed. Value <{value}> is not a prime number."); + } + } +} +``` + +### Use a custom assertion + +After you import the namespace that contains your extension methods, call your custom assertion through `Assert.That`: + +```csharp +[TestMethod] +public void Compute_ReturnsPrime() +{ + int result = _calculator.NextPrime(10); + Assert.That.IsPrime(result); +} +``` + +### Extension hooks on `StringAssert` and `CollectionAssert` + +The and properties expose the same singleton pattern for backward compatibility. For new custom assertions, always target `Assert.That`. Otherwise, your helpers inherit the same discoverability problems as the legacy classes, and they'll need migration if `StringAssert` and `CollectionAssert` are deprecated. + +### `Assert.That` property versus `Assert.That(...)` method + +> [!NOTE] +> Don't confuse the `Assert.That` singleton *property*—used as an extensibility hook—with the `Assert.That(() => condition)` *method* added in MSTest 3.8. The latter accepts a Boolean expression and produces detailed failure messages by analyzing the expression tree (for example, `Assert.That(() => order.Total > 0)`). The two APIs share a name but serve different purposes. + ## Best practices -1. **Use specific assertions**: Prefer `AreEqual` over `IsTrue(a == b)` for better failure messages. +- **Use specific assertions**: Prefer `AreEqual` over `IsTrue(a == b)` for better failure messages. + +- **Include descriptive messages**: Help identify failures quickly with clear assertion messages. -1. **Include descriptive messages**: Help identify failures quickly with clear assertion messages. +- **Test one thing at a time**: Each test method should verify a single behavior. -1. **Test one thing at a time**: Each test method should verify a single behavior. +- **Use `Throws`/`ThrowsExactly` for exceptions**: In MSTest v3.8+, prefer `Assert.Throws`, `Assert.ThrowsExactly`, and their async counterparts (`ThrowsAsync`, `ThrowsExactlyAsync`) over the `ExpectedException` attribute. -1. **Use `Throws`/`ThrowsExactly` for exceptions**: In MSTest v3.8+, prefer `Assert.Throws`, `Assert.ThrowsExactly`, and their async counterparts (`ThrowsAsync`, `ThrowsExactlyAsync`) over the `ExpectedException` attribute. +- **Prefer `Assert` over `StringAssert`/`CollectionAssert`**: For better discoverability and consistency, use the `Assert` class. The `StringAssert` and `CollectionAssert` classes are likely to be deprecated in a future release. -1. **Prefer `Assert` over `StringAssert`/`CollectionAssert`**: When functionality exists in both classes, use the `Assert` class for better discoverability and consistency. +- **Extend `Assert.That` for custom assertions**: For consistent discoverability, add custom assertions as extension methods on `Assert` and invoke them through `Assert.That`. Don't target `StringAssert.That` or `CollectionAssert.That` in new code. ## Related analyzers From e3ea771872af4fcc8f1066b9c39efae26278c4bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Festim=20Re=C3=A7i?= <45433214+FestimReqi@users.noreply.github.com> Date: Tue, 16 Jun 2026 19:37:57 +0200 Subject: [PATCH 10/11] Add C# 8 parameter shadowing history item (#54372) * Add C# 8 parameter shadowing history item * Add parameter shadowing note to local functions article --- .../programming-guide/classes-and-structs/local-functions.md | 2 ++ docs/csharp/whats-new/csharp-version-history.md | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/csharp/programming-guide/classes-and-structs/local-functions.md b/docs/csharp/programming-guide/classes-and-structs/local-functions.md index d8571d6778b11..758cb893eeb8c 100644 --- a/docs/csharp/programming-guide/classes-and-structs/local-functions.md +++ b/docs/csharp/programming-guide/classes-and-structs/local-functions.md @@ -18,6 +18,8 @@ helpviewer_keywords: - Finalizers - Other local functions +Beginning with C# 8.0, local function parameters can shadow local variables and parameters from an enclosing scope. + However, local functions can't be declared inside an expression-bodied member. > [!NOTE] diff --git a/docs/csharp/whats-new/csharp-version-history.md b/docs/csharp/whats-new/csharp-version-history.md index 52927bcffba90..329cff11c0d54 100644 --- a/docs/csharp/whats-new/csharp-version-history.md +++ b/docs/csharp/whats-new/csharp-version-history.md @@ -212,6 +212,7 @@ C# 8.0 is the first major C# release that specifically targets .NET Core. Some f - Positional patterns - [Using declarations](../language-reference/statements/using.md) - [Static local functions](../programming-guide/classes-and-structs/local-functions.md) +- Lambda expressions, anonymous methods, and local functions can declare parameters that shadow local variables and parameters from an enclosing scope. - [Disposable ref structs](../language-reference/builtin-types/ref-struct.md) - [Nullable reference types](../language-reference/builtin-types/nullable-reference-types.md) - [Asynchronous streams](../language-reference/statements/iteration-statements.md#await-foreach) From b5419a78e44528e21ef7490004b57ad6a0f25fe3 Mon Sep 17 00:00:00 2001 From: sibber5 Date: Tue, 16 Jun 2026 23:26:21 +0300 Subject: [PATCH 11/11] Update outdated Nushell completions config (#54366) * Update outdated Nushell completions config * Add example to Nushell completions config * Update Nushell instructions for dynamic completions * Update Nushell and shell completion instructions * Make header sizes consistent --- docs/core/tools/enable-tab-autocomplete.md | 53 ++++++++-------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/docs/core/tools/enable-tab-autocomplete.md b/docs/core/tools/enable-tab-autocomplete.md index 85baf215df6e2..eae13e9d15431 100644 --- a/docs/core/tools/enable-tab-autocomplete.md +++ b/docs/core/tools/enable-tab-autocomplete.md @@ -91,11 +91,11 @@ dotnet completions script fish | source #### Nushell -Add the following to the beginning of your `config.nu` file: +Add the following line(s) to your `config.nu` file: ```nu -dotnet completions script nushell | save -f ~/.local/share/nushell/completions/dotnet.nu -use ~/.local/share/nushell/completions/dotnet.nu * +mkdir ($nu.data-dir | path join "vendor/autoload") # Only add this line if not already present in your config. +dotnet completions script nushell | save -f ($nu.data-dir | path join "vendor/autoload/dotnet-completions.nu") ``` ## Dynamic completion scripts (all versions) @@ -115,7 +115,9 @@ pack If that command doesn't work, make sure that .NET Core 2.0 SDK or later is installed. If it's installed but that command still doesn't work, make sure that the `dotnet` command resolves to a version of .NET Core 2.0 SDK or later. Use the `dotnet --version` command to see what version of `dotnet` your current path is resolving to. For more information, see [Select the .NET version to use](../versions/selection.md). -### PowerShell +### Configure shells to use native completions + +#### PowerShell To add tab completion to **PowerShell** for the .NET CLI, create or edit the profile stored in the variable `$PROFILE`. For more information, see [How to create your profile](/powershell/module/microsoft.powershell.core/about/about_profiles#how-to-create-a-profile) and [Profiles and execution policy](/powershell/module/microsoft.powershell.core/about/about_profiles#profiles-and-execution-policy). @@ -131,9 +133,9 @@ Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock { } ``` -### bash +#### Bash -To add tab completion to your **bash** shell for the .NET CLI, add the following code to your `.bashrc` file: +Add the following code to your `.bashrc` file: ```bash # bash parameter completion for the dotnet CLI @@ -151,9 +153,9 @@ function _dotnet_bash_complete() complete -f -F _dotnet_bash_complete dotnet ``` -### zsh +#### Zsh -To add tab completion to your **zsh** shell for the .NET CLI, add the following code to your `.zshrc` file: +Add the following code to your `.zshrc` file: ```zsh # zsh parameter completion for the dotnet CLI @@ -176,43 +178,26 @@ _dotnet_zsh_complete() compdef _dotnet_zsh_complete dotnet ``` -### fish +#### Fish -To add tab completion to your **fish** shell for the .NET CLI, add the following code to your `config.fish` file: +Add the following code to your `config.fish` file: ```fish complete -f -c dotnet -a "(dotnet complete (commandline -cp))" ``` -### nushell +#### Nushell -To add tab completion to your **nushell** for .NET CLI, add the following to the beginning of your `config.nu` file: +Add the following code to your `config.nu` file: ```nu -let external_completer = { |spans| - { - dotnet: { || - dotnet complete ( - $spans | skip 1 | str join " " - ) | lines - } - } | get $spans.0 | each { || do $in } +def "nu-complete dotnet" [context: string] { + ^dotnet complete $"($context)" | lines } -``` - -And then in the `config` record, find the `completions` section and add the `external_completer` that was defined earlier to `external`: -```nu -let-env config = { - # your options here - completions: { - # your options here - external: { - # your options here - completer: $external_completer # add it here - } - } -} +export extern "dotnet" [ + ...command: string@"nu-complete dotnet" +] ``` ## Completion examples