From 0df9a838c7a49ec846fb333093f2911d21083390 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 7 Nov 2025 06:31:48 -0800 Subject: [PATCH 01/12] Update package index with latest published versions (#49658) --- docs/azure/includes/dotnet-all.md | 6 +++--- docs/azure/includes/dotnet-new.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/azure/includes/dotnet-all.md b/docs/azure/includes/dotnet-all.md index 716b318b12440..36537432566d4 100644 --- a/docs/azure/includes/dotnet-all.md +++ b/docs/azure/includes/dotnet-all.md @@ -28,7 +28,7 @@ | Conversational Language Understanding | NuGet [1.1.0](https://www.nuget.org/packages/Azure.AI.Language.Conversations/1.1.0)
NuGet [2.0.0-beta.4](https://www.nuget.org/packages/Azure.AI.Language.Conversations/2.0.0-beta.4) | [docs](/dotnet/api/overview/azure/AI.Language.Conversations-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_1.1.0/sdk/cognitivelanguage/Azure.AI.Language.Conversations/)
GitHub [2.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_2.0.0-beta.4/sdk/cognitivelanguage/Azure.AI.Language.Conversations/) | | Conversations Authoring | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.AI.Language.Conversations.Authoring/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/AI.Language.Conversations.Authoring-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations.Authoring_1.0.0-beta.2/sdk/cognitivelanguage/Azure.AI.Language.Conversations.Authoring/) | | Core - Client - AMQP | NuGet [1.3.1](https://www.nuget.org/packages/Azure.Core.Amqp/1.3.1) | [docs](/dotnet/api/overview/azure/Core.Amqp-readme) | GitHub [1.3.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core.Amqp_1.3.1/sdk/core/Azure.Core.Amqp/) | -| Core - Client - Core | NuGet [1.49.0](https://www.nuget.org/packages/Azure.Core/1.49.0) | [docs](/dotnet/api/overview/azure/Core-readme) | GitHub [1.49.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core_1.49.0/sdk/core/Azure.Core/) | +| Core - Client - Core | NuGet [1.50.0](https://www.nuget.org/packages/Azure.Core/1.50.0) | [docs](/dotnet/api/overview/azure/Core-readme) | GitHub [1.50.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core_1.50.0/sdk/core/Azure.Core/) | | Core - Client - Core | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Core.Expressions.DataFactory/1.0.0) | [docs](/dotnet/api/overview/azure/Core.Expressions.DataFactory-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core.Expressions.DataFactory_1.0.0/sdk/core/Azure.Core.Expressions.DataFactory/) | | Core Newtonsoft Json | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.Core.NewtonsoftJson/2.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Core.NewtonsoftJson-readme) | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.NewtonsoftJson_2.0.0/sdk/core/Microsoft.Azure.Core.NewtonsoftJson/) | | Core WCF Storage Queues | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Microsoft.CoreWCF.Azure.StorageQueues/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Microsoft.CoreWCF.Azure.StorageQueues-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.CoreWCF.Azure.StorageQueues_1.0.0-beta.1/sdk/extension-wcf/Microsoft.CoreWCF.Azure.StorageQueues/) | @@ -594,9 +594,9 @@ | Microsoft.Azure.Functions.Worker.Grpc | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Grpc/2.0.0)
NuGet [2.50.0-preview2](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Grpc/2.50.0-preview2) | | | | Microsoft.Azure.Functions.Worker.ItemTemplates | NuGet [4.0.5303](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.ItemTemplates/4.0.5303) | | | | Microsoft.Azure.Functions.Worker.ProjectTemplates | NuGet [4.0.5303](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.ProjectTemplates/4.0.5303) | | | -| Microsoft.Azure.Functions.Worker.Sdk | NuGet [2.0.5](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk/2.0.5) | | | +| Microsoft.Azure.Functions.Worker.Sdk | NuGet [2.0.6](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk/2.0.6) | | | | Microsoft.Azure.Functions.Worker.Sdk.Analyzers | NuGet [1.2.2](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk.Analyzers/1.2.2) | | | -| Microsoft.Azure.Functions.Worker.Sdk.Generators | NuGet [1.3.5](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk.Generators/1.3.5) | | | +| Microsoft.Azure.Functions.Worker.Sdk.Generators | NuGet [1.3.6](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk.Generators/1.3.6) | | | | Microsoft.Azure.WebJobs.CosmosDb.ChangeProcessor | NuGet [1.0.4](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.CosmosDb.ChangeProcessor/1.0.4) | | | | Microsoft.Azure.WebJobs.Extensions.Kusto | NuGet [1.0.13-Preview](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Kusto/1.0.13-Preview) | | | | Microsoft.Azure.WebJobs.Extensions.Rpc | NuGet [3.0.42](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Rpc/3.0.42) | | | diff --git a/docs/azure/includes/dotnet-new.md b/docs/azure/includes/dotnet-new.md index 68db1b766a7df..0160aff9f81cb 100644 --- a/docs/azure/includes/dotnet-new.md +++ b/docs/azure/includes/dotnet-new.md @@ -30,7 +30,7 @@ | Conversational Language Understanding | NuGet [1.1.0](https://www.nuget.org/packages/Azure.AI.Language.Conversations/1.1.0)
NuGet [2.0.0-beta.4](https://www.nuget.org/packages/Azure.AI.Language.Conversations/2.0.0-beta.4) | [docs](/dotnet/api/overview/azure/AI.Language.Conversations-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_1.1.0/sdk/cognitivelanguage/Azure.AI.Language.Conversations/)
GitHub [2.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_2.0.0-beta.4/sdk/cognitivelanguage/Azure.AI.Language.Conversations/) | | Conversations Authoring | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.AI.Language.Conversations.Authoring/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/AI.Language.Conversations.Authoring-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations.Authoring_1.0.0-beta.2/sdk/cognitivelanguage/Azure.AI.Language.Conversations.Authoring/) | | Core - Client - AMQP | NuGet [1.3.1](https://www.nuget.org/packages/Azure.Core.Amqp/1.3.1) | [docs](/dotnet/api/overview/azure/Core.Amqp-readme) | GitHub [1.3.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core.Amqp_1.3.1/sdk/core/Azure.Core.Amqp/) | -| Core - Client - Core | NuGet [1.49.0](https://www.nuget.org/packages/Azure.Core/1.49.0) | [docs](/dotnet/api/overview/azure/Core-readme) | GitHub [1.49.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core_1.49.0/sdk/core/Azure.Core/) | +| Core - Client - Core | NuGet [1.50.0](https://www.nuget.org/packages/Azure.Core/1.50.0) | [docs](/dotnet/api/overview/azure/Core-readme) | GitHub [1.50.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core_1.50.0/sdk/core/Azure.Core/) | | Core - Client - Core | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Core.Expressions.DataFactory/1.0.0) | [docs](/dotnet/api/overview/azure/Core.Expressions.DataFactory-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core.Expressions.DataFactory_1.0.0/sdk/core/Azure.Core.Expressions.DataFactory/) | | Core Newtonsoft Json | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.Core.NewtonsoftJson/2.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Core.NewtonsoftJson-readme) | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.NewtonsoftJson_2.0.0/sdk/core/Microsoft.Azure.Core.NewtonsoftJson/) | | Core WCF Storage Queues | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Microsoft.CoreWCF.Azure.StorageQueues/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Microsoft.CoreWCF.Azure.StorageQueues-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.CoreWCF.Azure.StorageQueues_1.0.0-beta.1/sdk/extension-wcf/Microsoft.CoreWCF.Azure.StorageQueues/) | From 78e27f3a090bf93875828391b1dde550b7840814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Pir=C3=B3g?= Date: Fri, 7 Nov 2025 15:40:39 +0100 Subject: [PATCH 02/12] Vb.net: Fix typo in enum member syntax description (#49666) - Was [] member name [ = initializer ], - Should be [] membername [ = initializer ], - Reason: `membername` is a single identifier; later in the document it is referred to as `membername` --- .../language-reference/statements/enum-statement.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/visual-basic/language-reference/statements/enum-statement.md b/docs/visual-basic/language-reference/statements/enum-statement.md index 0a4a89cbcbc55..ae0fcfe765e5f 100644 --- a/docs/visual-basic/language-reference/statements/enum-statement.md +++ b/docs/visual-basic/language-reference/statements/enum-statement.md @@ -66,7 +66,7 @@ End Enum Required. List of member constants being declared in this statement. Multiple members appear on individual source code lines. - Each `member` has the following syntax and parts: `[] member name [ = initializer ]` + Each `member` has the following syntax and parts: `[] membername [ = initializer ]` |Part|Description| |---|---| From 7bb6a1adfeddc0fb5e635bf4ed74ba45622cd833 Mon Sep 17 00:00:00 2001 From: Nigusu Solomon Yenework <59111203+Nigusu-Allehu@users.noreply.github.com> Date: Fri, 7 Nov 2025 10:12:00 -0800 Subject: [PATCH 03/12] Add documentation for dotnet package download command (#49659) --- docs/core/tools/dotnet-package-download.md | 89 ++++++++++++++++++++++ docs/core/tools/index.md | 1 + docs/navigate/tools-diagnostics/toc.yml | 2 + 3 files changed, 92 insertions(+) create mode 100644 docs/core/tools/dotnet-package-download.md diff --git a/docs/core/tools/dotnet-package-download.md b/docs/core/tools/dotnet-package-download.md new file mode 100644 index 0000000000000..d549f8f2f9028 --- /dev/null +++ b/docs/core/tools/dotnet-package-download.md @@ -0,0 +1,89 @@ +--- +title: dotnet package download command +description: Learn about the 'dotnet package download' command that downloads a NuGet package. +author: Nigusu-Allehu +ms.date: 11/06/2025 +ai-usage: ai-assisted +--- +# dotnet package download + +> Applies to: ✔️ .NET 10 SDK and later versions. + +## Name + +`dotnet package download` — Download one or more NuGet packages to disk. + +## Synopsis + +``` +dotnet package download [...] + [--output ] + [--configfile ] + [--prerelease] + [--source ] + [--allow-insecure-connections] + [--interactive] + [--verbosity ] + +dotnet package download -h|--help +``` + +## Description + +`dotnet package download` downloads NuGet packages to a local directory. It **does not** add or update `PackageReference` entries in project files and **does not** build or restore a project. +By default, the command downloads only the packages you specify (no transitive dependencies) to the current working directory. + +## Arguments + +* **`packages`** + + One or more package IDs to download. + Each package can optionally include a version with `@`. + If a package version isn't specified, the latest version of the package is downloaded. + For example, `dotnet package download Contoso.Utilities` or `dotnet package download Contoso.Utilities@3.2.1`. + +## Options + +* **`--allow-insecure-connections`** + + Allows downloading from HTTP sources. Without this flag, insecure sources cause the command to error per [HTTPS-everywhere](https://aka.ms/nuget-https-everywhere) guidance. + +* **`--configfile `** + + Path to a NuGet.config to use. + +* **`--interactive`** + + Enables interactive authentication if required. + +* **`-o, --output `** + + Directory where the package will be placed. Defaults to the current working directory. + +* **`--prerelease`** + + Allows downloading prerelease versions. + +* **`-s --source `** + + Specifies the NuGet package source to use. + +* **`-v, --verbosity `** + + Set the verbosity level of the command. Allowed values are `q[uiet]`, `m[inimal]`, `n[ormal]`, `d[etailed]`, and `diag[nostic]`. + +[!INCLUDE [help](../../../includes/cli-help.md)] + +## Examples + +### Download a single package at a specific version + +```ps1 +dotnet package download Contoso@13.0.3 --output My/Destination/For/packages +``` + +### Download multiple packages to a custom folder + +```ps1 +dotnet package download Contoso@3.1.2 Contoso.Utility@6.12.0 --output My/Destination/For/packages +``` diff --git a/docs/core/tools/index.md b/docs/core/tools/index.md index 5998715ea5d5e..fb36452000943 100644 --- a/docs/core/tools/index.md +++ b/docs/core/tools/index.md @@ -74,6 +74,7 @@ The following commands are installed by default: ### Project modification commands - [`package add`](dotnet-package-add.md) +- [`package download`](dotnet-package-download.md) - [`package list`](dotnet-package-list.md) - [`package remove`](dotnet-package-remove.md) - [`package search`](dotnet-package-search.md) diff --git a/docs/navigate/tools-diagnostics/toc.yml b/docs/navigate/tools-diagnostics/toc.yml index 302c82cd9adda..c504a4d148d37 100644 --- a/docs/navigate/tools-diagnostics/toc.yml +++ b/docs/navigate/tools-diagnostics/toc.yml @@ -182,6 +182,8 @@ items: items: - name: dotnet package add href: ../../core/tools/dotnet-package-add.md + - name: dotnet package download + href: ../../core/tools/dotnet-package-download.md - name: dotnet package list href: ../../core/tools/dotnet-package-list.md - name: dotnet package remove From c969230fe887a61c4c7070134c166544f7d4b50c Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 7 Nov 2025 10:29:33 -0800 Subject: [PATCH 04/12] Update package index with latest published versions (#49668) --- docs/azure/includes/dotnet-all.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/azure/includes/dotnet-all.md b/docs/azure/includes/dotnet-all.md index 36537432566d4..05ba167f03daa 100644 --- a/docs/azure/includes/dotnet-all.md +++ b/docs/azure/includes/dotnet-all.md @@ -417,13 +417,13 @@ | System Net Client Model | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/System.Net.ClientModel/1.0.0-beta.1) | | | | Unknown Display Name | NuGet [0.13.0](https://www.nuget.org/packages/Azure.Iot.Operations.Connector/0.13.0) | | | | Unknown Display Name | NuGet [0.1.0](https://www.nuget.org/packages/Azure.Iot.Operations.Templates/0.1.0) | | | -| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp/1.0.0)
NuGet [2.0.0-beta.1](https://www.nuget.org/packages/Azure.Mcp/2.0.0-beta.1) | | | -| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp.linux-arm64/1.0.0)
NuGet [2.0.0-beta.1](https://www.nuget.org/packages/Azure.Mcp.linux-arm64/2.0.0-beta.1) | | | -| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp.linux-x64/1.0.0)
NuGet [2.0.0-beta.1](https://www.nuget.org/packages/Azure.Mcp.linux-x64/2.0.0-beta.1) | | | -| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp.osx-arm64/1.0.0)
NuGet [2.0.0-beta.1](https://www.nuget.org/packages/Azure.Mcp.osx-arm64/2.0.0-beta.1) | | | -| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp.osx-x64/1.0.0)
NuGet [2.0.0-beta.1](https://www.nuget.org/packages/Azure.Mcp.osx-x64/2.0.0-beta.1) | | | -| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp.win-arm64/1.0.0)
NuGet [2.0.0-beta.1](https://www.nuget.org/packages/Azure.Mcp.win-arm64/2.0.0-beta.1) | | | -| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp.win-x64/1.0.0)
NuGet [2.0.0-beta.1](https://www.nuget.org/packages/Azure.Mcp.win-x64/2.0.0-beta.1) | | | +| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp/1.0.0)
NuGet [2.0.0-beta.2](https://www.nuget.org/packages/Azure.Mcp/2.0.0-beta.2) | | | +| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp.linux-arm64/1.0.0)
NuGet [2.0.0-beta.2](https://www.nuget.org/packages/Azure.Mcp.linux-arm64/2.0.0-beta.2) | | | +| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp.linux-x64/1.0.0)
NuGet [2.0.0-beta.2](https://www.nuget.org/packages/Azure.Mcp.linux-x64/2.0.0-beta.2) | | | +| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp.osx-arm64/1.0.0)
NuGet [2.0.0-beta.2](https://www.nuget.org/packages/Azure.Mcp.osx-arm64/2.0.0-beta.2) | | | +| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp.osx-x64/1.0.0)
NuGet [2.0.0-beta.2](https://www.nuget.org/packages/Azure.Mcp.osx-x64/2.0.0-beta.2) | | | +| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp.win-arm64/1.0.0)
NuGet [2.0.0-beta.2](https://www.nuget.org/packages/Azure.Mcp.win-arm64/2.0.0-beta.2) | | | +| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Mcp.win-x64/1.0.0)
NuGet [2.0.0-beta.2](https://www.nuget.org/packages/Azure.Mcp.win-x64/2.0.0-beta.2) | | | | Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Monitor.Query.Logs/1.0.0) | | | | Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Monitor.Query.Metrics/1.0.0) | | | | Unknown Display Name | NuGet [0.1.4-preview.2](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Aot/0.1.4-preview.2) | | | From 04e66f234d0fddcf9fef4eed415ceb497f439a06 Mon Sep 17 00:00:00 2001 From: alexwolfmsft <93200798+alexwolfmsft@users.noreply.github.com> Date: Fri, 7 Nov 2025 14:25:30 -0500 Subject: [PATCH 05/12] Refactor more language agnostic content into includes (#49651) * Refactor more language agnostic content into includes Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --------- Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- .../local-development-broker.md | 57 ++----------------- .../azure/sdk/includes/broker-assign-roles.md | 13 +++++ .../sdk/includes/broker-configure-app.md | 34 +++++++++++ docs/azure/sdk/includes/broker-intro.md | 14 +++++ docs/azure/sdk/includes/broker-linux.md | 6 ++ docs/azure/sdk/includes/broker-mac.md | 6 ++ docs/azure/sdk/includes/broker-windows.md | 8 +++ 7 files changed, 87 insertions(+), 51 deletions(-) create mode 100644 docs/azure/sdk/includes/broker-assign-roles.md create mode 100644 docs/azure/sdk/includes/broker-configure-app.md create mode 100644 docs/azure/sdk/includes/broker-intro.md create mode 100644 docs/azure/sdk/includes/broker-linux.md create mode 100644 docs/azure/sdk/includes/broker-mac.md create mode 100644 docs/azure/sdk/includes/broker-windows.md diff --git a/docs/azure/sdk/authentication/local-development-broker.md b/docs/azure/sdk/authentication/local-development-broker.md index 80a8b3a2f06d6..fb0cf004f2479 100644 --- a/docs/azure/sdk/authentication/local-development-broker.md +++ b/docs/azure/sdk/authentication/local-development-broker.md @@ -9,74 +9,29 @@ zone_pivot_groups: operating-systems-set-one # Authenticate .NET apps to Azure services during local development using brokered authentication -Brokered authentication collects user credentials using the system authentication broker to authenticate an app with . A system authentication broker is an app running on a user's machine that manages the authentication handshakes and token maintenance for all connected accounts. - -Brokered authentication offers the following benefits: - -- **Enables Single Sign-On (SSO):** Enables apps to simplify how users authenticate with Microsoft Entra ID and protects Microsoft Entra ID refresh tokens from exfiltration and misuse. -- **Enhanced security:** Many security enhancements are delivered with the broker, without needing to update the app logic. -- **Enhanced feature support:** With the help of the broker, developers can access rich OS and service capabilities. -- **System integration:** Applications that use the broker plug-and-play with the built-in account picker, allowing the user to quickly pick an existing account instead of reentering the same credentials over and over. -- **Token Protection:** Ensures that the refresh tokens are device bound and enables apps to acquire device bound access tokens. See [Token Protection](/azure/active-directory/conditional-access/concept-token-protection). +[!INCLUDE [broker-intro](../includes/broker-intro.md)] :::zone target="docs" pivot="os-windows" -Windows provides an authentication broker called [Web Account Manager (WAM)](/entra/msal/dotnet/acquiring-tokens/desktop-mobile/wam). WAM enables identity providers such as Microsoft Entra ID to natively plug into the OS and provide secure login services to apps. Brokered authentication enables the app for all operations allowed by the interactive login credentials. - -Personal Microsoft accounts and work or school accounts are supported. On supported Windows versions, the default browser-based UI is replaced with a smoother authentication experience, similar to built-in Windows apps. +[!INCLUDE [broker-windows](../includes/broker-windows.md)] :::zone-end :::zone target="docs" pivot="os-macos" -macOS doesn't natively include a built-in authentication broker. Brokered authentication is supported via the `Azure.Identity.Broker` library, which uses platform-specific mechanisms and may integrate with apps like Microsoft Company Portal when devices are managed. For more information, see [Microsoft Enterprise SSO plug-in for Apple devices](/entra/identity-platform/apple-sso-plugin). +[!INCLUDE [broker-mac](../includes/broker-mac.md)] :::zone-end :::zone target="docs" pivot="os-linux" -Linux uses [Microsoft single sign-on for Linux](/entra/identity/devices/sso-linux) as its authentication broker. +[!INCLUDE [broker-linux](../includes/broker-linux.md)] :::zone-end -## Configure the app for brokered authentication - -To enable brokered authentication in your application, follow these steps: - -1. In the [Azure portal](https://portal.azure.com), navigate to **Microsoft Entra ID** and select **App registrations** on the left-hand menu. -1. Select the registration for your app, then select **Authentication**. -1. Add the appropriate redirect URI to your app registration via a platform configuration: - 1. Under **Platform configurations**, select **+ Add a platform**. - 1. Under **Configure platforms**, select the tile for your application type (platform) to configure its settings, such as **mobile and desktop applications**. - 1. In **Custom redirect URIs**, enter the following redirect URI for your platform: - - | Platform | Redirect URI | - |-------------|-----------------------------------------------------------------------------------------------------------------------| - | Windows 10+ or WSL | `ms-appx-web://Microsoft.AAD.BrokerPlugin/{your_client_id}` | - | macOS | `msauth.com.msauth.unsignedapp://auth` for unsigned apps
`msauth.{bundle_id}://auth` for signed apps | - | Linux | `https://login.microsoftonline.com/common/oauth2/nativeclient` | - - Replace `{your_client_id}` or `{bundle_id}` with the **Application (client) ID** from the app registration's **Overview** pane. - - 1. Select **Configure**. - - To learn more, see [Add a redirect URI to an app registration](/entra/identity-platform/quickstart-register-app#add-a-redirect-uri). - -1. Back on the **Authentication** pane, under **Advanced settings**, select **Yes** for **Allow public client flows**. -1. Select **Save** to apply the changes. -1. To authorize the application for specific resources, navigate to the resource in question, select **API Permissions**, and enable **Microsoft Graph** and other resources you want to access. - - > [!IMPORTANT] - > You must also be the admin of your tenant to grant consent to your application when you sign in for the first time. - -## Assign roles - -To run your app code successfully with brokered authentication, grant your user account permissions using [Azure role-based access control (RBAC)](/azure/role-based-access-control/overview). Assign an appropriate role to your user account for the relevant Azure service. For example: - -- **Azure Blob Storage**: Assign the **Storage Account Data Contributor** role. -- **Azure Key Vault**: Assign the **Key Vault Secrets Officer** role. +[!INCLUDE [broker-configure-app](../includes/broker-configure-app.md)] -If an app is specified, it must have API permissions set for **user_impersonation Access Azure Storage** (step 6 in the previous section). This API permission allows the app to access Azure storage on behalf of the signed-in user after consent is granted during sign-in. +[!INCLUDE [broker-assign-roles](../includes/broker-assign-roles.md)] ## Implement the code diff --git a/docs/azure/sdk/includes/broker-assign-roles.md b/docs/azure/sdk/includes/broker-assign-roles.md new file mode 100644 index 0000000000000..0904833ce7086 --- /dev/null +++ b/docs/azure/sdk/includes/broker-assign-roles.md @@ -0,0 +1,13 @@ +--- +ms.topic: include +ms.date: 03/19/2025 +--- + +## Assign roles + +To run your app code successfully with brokered authentication, grant your user account permissions using [Azure role-based access control (RBAC)](/azure/role-based-access-control/overview). Assign an appropriate role to your user account for the relevant Azure service. For example: + +- **Azure Blob Storage**: Assign the **Storage Account Data Contributor** role. +- **Azure Key Vault**: Assign the **Key Vault Secrets Officer** role. + +If an app is specified, it must have API permissions set for **user_impersonation Access Azure Storage** (step 6 in the previous section). This API permission allows the app to access Azure storage on behalf of the signed-in user after consent is granted during sign-in. diff --git a/docs/azure/sdk/includes/broker-configure-app.md b/docs/azure/sdk/includes/broker-configure-app.md new file mode 100644 index 0000000000000..77ce644c20215 --- /dev/null +++ b/docs/azure/sdk/includes/broker-configure-app.md @@ -0,0 +1,34 @@ +--- +ms.topic: include +ms.date: 03/19/2025 +--- + +## Configure the app for brokered authentication + +To enable brokered authentication in your application, follow these steps: + +1. In the [Azure portal](https://portal.azure.com), navigate to **Microsoft Entra ID** and select **App registrations** on the left-hand menu. +1. Select the registration for your app, then select **Authentication**. +1. Add the appropriate redirect URI to your app registration via a platform configuration: + 1. Under **Platform configurations**, select **+ Add a platform**. + 1. Under **Configure platforms**, select the tile for your application type (platform) to configure its settings, such as **mobile and desktop applications**. + 1. In **Custom redirect URIs**, enter the following redirect URI for your platform: + + | Platform | Redirect URI | + |-------------|-----------------------------------------------------------------------------------------------------------------------| + | Windows 10+ or WSL | `ms-appx-web://Microsoft.AAD.BrokerPlugin/{your_client_id}` | + | macOS | `msauth.com.msauth.unsignedapp://auth` for unsigned apps
`msauth.{bundle_id}://auth` for signed apps | + | Linux | `https://login.microsoftonline.com/common/oauth2/nativeclient` | + + Replace `{your_client_id}` or `{bundle_id}` with the **Application (client) ID** from the app registration's **Overview** pane. + + 1. Select **Configure**. + + To learn more, see [Add a redirect URI to an app registration](/entra/identity-platform/quickstart-register-app#add-a-redirect-uri). + +1. Back on the **Authentication** pane, under **Advanced settings**, select **Yes** for **Allow public client flows**. +1. Select **Save** to apply the changes. +1. To authorize the application for specific resources, navigate to the resource in question, select **API Permissions**, and enable **Microsoft Graph** and other resources you want to access. + + > [!IMPORTANT] + > You must also be the admin of your tenant to grant consent to your application when you sign in for the first time. diff --git a/docs/azure/sdk/includes/broker-intro.md b/docs/azure/sdk/includes/broker-intro.md new file mode 100644 index 0000000000000..2ac265642c74d --- /dev/null +++ b/docs/azure/sdk/includes/broker-intro.md @@ -0,0 +1,14 @@ +--- +ms.topic: include +ms.date: 04/25/2025 +--- + +Brokered authentication collects user credentials using the system authentication broker to authenticate an app. A system authentication broker is an app running on a user's machine that manages the authentication handshakes and token maintenance for all connected accounts. + +Brokered authentication offers the following benefits: + +- **Enables Single Sign-On (SSO):** Enables apps to simplify how users authenticate with Microsoft Entra ID and protects Microsoft Entra ID refresh tokens from exfiltration and misuse. +- **Enhanced security:** Many security enhancements are delivered with the broker, without needing to update the app logic. +- **Enhanced feature support:** With the help of the broker, developers can access rich OS and service capabilities. +- **System integration:** Applications that use the broker plug-and-play with the built-in account picker, allowing the user to quickly pick an existing account instead of re-entering the same credentials over and over. +- **Token Protection:** Ensures that the refresh tokens are device bound and enables apps to acquire device bound access tokens. For more information, see [Token Protection](/azure/active-directory/conditional-access/concept-token-protection). diff --git a/docs/azure/sdk/includes/broker-linux.md b/docs/azure/sdk/includes/broker-linux.md new file mode 100644 index 0000000000000..87a5fa1de997c --- /dev/null +++ b/docs/azure/sdk/includes/broker-linux.md @@ -0,0 +1,6 @@ +--- +ms.topic: include +ms.date: 04/25/2025 +--- + +Linux uses [Microsoft single sign-on for Linux](/entra/identity/devices/sso-linux) as its authentication broker. diff --git a/docs/azure/sdk/includes/broker-mac.md b/docs/azure/sdk/includes/broker-mac.md new file mode 100644 index 0000000000000..93b027043a9ad --- /dev/null +++ b/docs/azure/sdk/includes/broker-mac.md @@ -0,0 +1,6 @@ +--- +ms.topic: include +ms.date: 04/25/2025 +--- + +macOS doesn't natively include a built-in authentication broker. The Azure Identity client library implements brokered authentication features using platform-specific mechanisms and can integrate with apps like Microsoft Company Portal when devices are managed. For more information, see [Microsoft Enterprise SSO plug-in for Apple devices](/entra/identity-platform/apple-sso-plugin). diff --git a/docs/azure/sdk/includes/broker-windows.md b/docs/azure/sdk/includes/broker-windows.md new file mode 100644 index 0000000000000..542b09c88a54d --- /dev/null +++ b/docs/azure/sdk/includes/broker-windows.md @@ -0,0 +1,8 @@ +--- +ms.topic: include +ms.date: 04/25/2025 +--- + +Windows provides an authentication broker called [Web Account Manager (WAM)](/entra/msal/dotnet/acquiring-tokens/desktop-mobile/wam). WAM enables identity providers such as Microsoft Entra ID to natively plug into the OS and provide secure login services to apps. Brokered authentication enables the app for all operations allowed by the interactive login credentials. + +Personal Microsoft accounts and work or school accounts are supported. On supported Windows versions, the default browser-based UI is replaced with a smoother authentication experience, similar to built-in Windows apps. From 871025ff8b9aadfc38c4008730a928941568596a Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Fri, 7 Nov 2025 15:01:14 -0500 Subject: [PATCH 06/12] Add errors for existing C# 14 themes (#49669) * Add errors for existing C# 14 themes Add all newly created diagnostics that map to existing consolidated error files. * Update docs/csharp/language-reference/compiler-messages/array-declaration-errors.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Edit pass on array errors. After adding the final C# 14 updates, perform an edit pass to match the current format. * edit pass on extension declarations Add final errors introduced in C# 14 for extensions. Perform an edit pass to match the improved format. * Edit pass and update dates After adding the final diagnostics for C# 14, update this file to match the more recent style. * Apply suggestions from code review Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- .../array-declaration-errors.md | 197 +++++++++++------- .../extension-declarations.md | 107 ++++++---- .../feature-version-errors.md | 6 + .../overloaded-operator-errors.md | 111 +++++++--- .../pattern-matching-warnings.md | 71 +++++-- docs/csharp/language-reference/toc.yml | 11 +- ...n-t-have-specifics-on-this-csharp-error.md | 3 - 7 files changed, 331 insertions(+), 175 deletions(-) diff --git a/docs/csharp/language-reference/compiler-messages/array-declaration-errors.md b/docs/csharp/language-reference/compiler-messages/array-declaration-errors.md index 211d07ae2b64f..51fc3bac11d09 100644 --- a/docs/csharp/language-reference/compiler-messages/array-declaration-errors.md +++ b/docs/csharp/language-reference/compiler-messages/array-declaration-errors.md @@ -42,6 +42,7 @@ f1_keywords: - "CS9214" - "CS9215" - "CS9222" + - "CS9332" helpviewer_keywords: - "CS0022" - "CS0178" @@ -83,7 +84,9 @@ helpviewer_keywords: - "CS9214" - "CS9215" - "CS9222" -ms.date: 11/02/2023 + - "CS9332" +ms.date: 11/07/2025 +ai-usage: ai-assisted --- # Resolve errors and warnings in array and collection declarations and initialization expressions @@ -125,6 +128,7 @@ That's by design. The text closely matches the text of the compiler error / warn - [**CS9214**](#invalid-collection-initializer): *Collection expression type must have an applicable constructor that can be called with no arguments.* - [**CS9215**](#invalid-collection-initializer): *Collection expression type 'type' must have an instance or extension method 'Add' that can be called with a single argument.* - [**CS9222**](#invalid-collection-initializer): *Collection initializer results in an infinite chain of instantiations of collection 'type'.* +- [**CS9332**](#invalid-collection-initializer): *Cannot use '..' spread operator in the filter expression of a catch clause.* In addition, the following warnings are covered in this article: @@ -135,75 +139,62 @@ In addition, the following warnings are covered in this article: - [**CS0251**](#invalid-array-element-access): *Indexing an array with a negative index (array indices always start at zero)* - [**CS9208**](#invalid-collection-initializer): *Collection expression may incur unexpected heap allocations. Consider explicitly creating an array, then converting to the final type to make the allocation explicit.* - [**CS9209**](#invalid-collection-initializer): *Collection expression may incur unexpected heap allocations due to use of '`..`' spreads. Consider explicitly creating an array, then converting to the final type to make the allocation explicit.* +- [**CS9332**](#invalid-collection-initializer): *Cannot use '..' spread operator in the filter expression of a catch clause.* -You can learn more about arrays, collection initializers and collection expressions in the following articles: +## Invalid array element access + +- **CS0022**: *Wrong number of indices inside [], expected 'number'* +- **CS0251**: *Indexing an array with a negative index (array indices always start at zero)* -- [Arrays](../builtin-types/arrays.md) -- [Object and Collection Initializers](../../programming-guide/classes-and-structs/object-and-collection-initializers.md) -- [Collection expressions](../operators/collection-expressions.md). +To access array elements correctly, follow these indexing rules. For more information, see [Arrays](../builtin-types/arrays.md). -## Invalid collection initializer +- Specify the same number of indices as declared dimensions (**CS0022**). A one-dimensional array needs one index; a three-dimensional array needs three indices. +- Use only non-negative integers for array indices (**CS0251**). Array indices always start at zero. -The following errors indicate that the code generated by the compiler for a collection initializer is invalid: +## Invalid collection initializer - **CS0747**: *Invalid initializer member declarator.* -- **CS1063**: *The best overloaded Add method for the collection initializer element is obsolete.* - **CS1920**: *Element initializer cannot be empty.* - **CS1921**: *The best overloaded method match has wrong signature for the initializer element. The initializable `Add` must be an accessible instance method.* +- **CS1922**: *Cannot initialize type 'type' with a collection initializer because 'type' doesn't implement 'System.Collections.IEnumerable'.* +- **CS1925**: *Cannot initialize object of type 'type' with a collection initializer.* +- **CS1927**: *Warning: Ignoring /win32manifest for module because it only applies to assemblies* - **CS1950**: *The best overloaded Add method for the collection initializer has some invalid arguments.* - **CS1954**: *The best overloaded method match for the collection initializer element cannot be used. Collection initializer '`Add`' methods cannot have `ref` or `out` parameters.* - **CS9174**: *Cannot initialize type with a collection literal because the type is not constructible.* - **CS9176**: *There is no target type for the collection literal.* - **CS9203**: *A collection expression of this type cannot be used in this context because it may be exposed outside of the current scope.* -- **CS9210**: *This version of cannot be used with collection expressions.* -- **CS9212**: *Spread operator '`..`' cannot operate on variables of type 'type' because 'type' does not contain a public instance or extension definition for 'member'.* +- **CS9210**: *This version of can't be used with collection expressions.* +- **CS9212**: *Spread operator '`..`' cannot operate on variables of type 'type' because 'type' doesn't contain a public instance or extension definition for 'member'.* - **CS9213**: *Collection expression target 'type' has no element type.* - **CS9214**: *Collection expression type must have an applicable constructor that can be called with no arguments.* - **CS9215**: *Collection expression type 'type' must have an instance or extension method 'Add' that can be called with a single argument.* - **CS9222**: *Collection initializer results in an infinite chain of instantiations of collection 'type'.* +- **CS9332**: *Cannot use '..' spread operator in the filter expression of a catch clause.* -The compiler might also generate the following warning: +The compiler might also generate the following warnings: - **CS1062**: *The best overloaded Add method for the collection initializer element is obsolete.* +- **CS1063**: *The best overloaded Add method for the collection initializer element is obsolete.* - **CS1064**: *The best overloaded Add method for the collection initializer element is obsolete.* - **CS9208**: *Collection expression may incur unexpected heap allocations. Consider explicitly creating an array, then converting to the final type to make the allocation explicit.* - **CS9209**: *Collection expression may incur unexpected heap allocations due to use of '`..`' spreads. Consider explicitly creating an array, then converting to the final type to make the allocation explicit.* -The errors all indicate that the code generated by the compiler for a collection initializer is invalid. Check the following: - -- A collection initializer contains a sequence of elements. You can't mix setting properties on the collection instance with adding elements in the same initializer. -- A collection initializer that includes braces (`{` and `}`) can't be empty. -- The class must implement IEnumerable and have a public `Add` method. -- A conforming `Add` method must be accessible and take one parameter that is the same type as the collection elements. The parameter can't include the `ref` or `out` modifier. -- Overload resolution must pick one `Add` method as a better match. There can't be multiple matching methods that are equally good. -- Collection expressions can initialize explicitly typed variables of a collection type. If the variable isn't a collection or array type, or is implicitly typed (using `var`), a collection initializer can't be used. -- A `ref struct` type, like can't be initialized with a collection expression that may violate ref safety. -- A collection expression can't correctly initialize an using the current version. Use a different version of the runtime, or change the initialization expression. -- The spread operator (`..`) in **CS9212** requires the type to implement a suitable method (like `GetEnumerator`) to enumerate its elements. Ensure your type implements the required enumeration pattern or provides an extension method. -- **CS9213** occurs when the compiler can't determine what element type to use for the collection expression. This typically happens with custom collection types. Make sure your collection type properly exposes its element type through its type definition or implements appropriate collection interfaces. -- **CS9214** is generated when a collection expression tries to initialize a type that doesn't have a parameterless constructor. Collection expressions require a constructor that can be called with no arguments to create the instance before adding elements. -- **CS9215** happens when the collection type doesn't provide an `Add` method that accepts a single parameter of the element type. The `Add` method must be accessible (typically public) and accept exactly one argument that matches the collection's element type. -- **CS9222** indicates a circular dependency in collection initialization. This occurs when initializing a collection triggers the creation of another instance of the same collection type, which in turn requires initializing another instance, creating an infinite loop. Review your collection type's constructor and initialization logic to break the circular dependency. - -The warnings indicates that the collection expression, including any [spread elements](../operators/collection-expressions.md#spread-element) might allocate memory. Creating different storage and converting might be more efficient. - -## Invalid array initializer - -- **CS0623**: *Array initializers can only be used in a variable or field initializer. Try using a new expression instead.* -- **CS0846**: *A nested array initializer is expected* -- **CS1925**: *Cannot initialize object of type 'type' with a collection initializer.* - -These errors indicate that you've created an invalid initializer. The likely cause is unbalanced braces `{` and `}` around one or more elements or child arrays. Ensure that the initializing expression matches the number of arrays in a jagged array initialization, and that the braces are balanced. - -## Invalid array element access - -- **CS0022**: *Wrong number of indices inside [], expected 'number'* -- **CS0251**: *Indexing an array with a negative index (array indices always start at zero)* - -You access an element of an array by specifying the index for each axis declared in the array. The indices are between `[` and `]` after the array name. There are two rules for the array indices: - -1. You must specify the same number of indices as used in the array declaration. If the array has one dimension, you must specify one index. If the array has three dimensions, you must specify three indices. -1. All indices must be non-negative integers. +To create valid collection initializers, follow these rules. For more information, see [Collection expressions](../operators/collection-expressions.md). + +- Don't mix property initialization with element addition in the same initializer (**CS0747**). +- Include at least one element in collection initializers with braces (**CS1920**). +- Ensure the collection type implements `IEnumerable` (**CS1922**). +- Use collection initializers only with collection types (**CS1925**). +- Verify the `Add` method is accessible, takes one parameter matching the element type, and doesn't use `ref` or `out` modifiers (**CS1921**, **CS1954**). +- Resolve ambiguous `Add` method overloads (**CS1950**). +- Provide an explicit target type for collection expressions when the compiler can't infer it (**CS9176**, **CS9213**). +- Ensure the collection type is constructible with a parameterless constructor (**CS9174**, **CS9214**). +- Don't use `ref struct` types in collection expressions that may violate ref safety (**CS9203**). +- Update to a compatible runtime version for `ImmutableArray` collection expressions (**CS9210**). +- Implement enumeration patterns (like `GetEnumerator`) for spread operator support (**CS9212**). +- Avoid circular dependencies in collection initialization (**CS9222**). +- Don't use the spread operator in catch clause filter expressions (**CS9332**). ## Invalid array rank @@ -211,31 +202,37 @@ You access an element of an array by specifying the index for each axis declared - **CS0650**: *Bad array declarator: To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type.* - **CS1552**: *Array type specifier, `[]`, must appear before parameter name* -An array declaration consists of the following tokens, in order: +To declare arrays correctly, follow the proper syntax order. For more information, see [Arrays](../builtin-types/arrays.md) and the [C# Language Specification](~/_csharpstandard/standard/arrays.md#177-array-initializers) section on array initializers. + +An array declaration consists of these tokens in order: -1. The type of the array elements. For example, `int`, `string`, or `SomeClassType`. -1. The array brackets, optionally including commas to represent multi dimensions. -1. The variable name. +1. The type of array elements (for example, `int`, `string`, or `SomeClassType`). +2. The array brackets, optionally including commas for multiple dimensions. +3. The variable name. -When an array initialization specifies the array dimensions, you can specify the following properties: +When specifying array dimensions, you can use: - A number of elements in braces (`{` and `}`) - Empty brackets - One or more commas enclosed in brackets -For example, the following are valid array declarations: +The following examples show valid array declarations: :::code language="csharp" source="./snippets/array-warnings/Program.cs" id="ArrayDeclarations"::: -For more information, see the C# specification ([C# Language Specification](~/_csharpstandard/standard/arrays.md#177-array-initializers)) section on array initializers. - ## Invalid array length - **CS0248**: *Cannot create an array with a negative size* -- **CS0270**: *Array size cannot be specified in a variable declaration (try initializing with a 'new' expression* +- **CS0270**: *Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)* - **CS1586**: *Array creation must have array size or array initializer* -The length of each dimension of an array must be specified as part of the array initialization, not its declaration. The length of each dimension must be positive. You can specify the length either by using a `new` expression to allocate the array, or using an array initializer to assign all the elements. The following example shows both mechanisms: +To create arrays with valid lengths, specify the size during initialization, not declaration. For more information, see [Arrays](../builtin-types/arrays.md). + +- Specify array length as part of initialization, not declaration (**CS0270**). +- Use only positive integers for array dimensions (**CS0248**). +- Provide either a size in a `new` expression or an array initializer (**CS1586**). + +The following example shows both mechanisms: :::code language="csharp" source="./snippets/array-warnings/Program.cs" id="ArrayInitializers"::: @@ -244,41 +241,97 @@ The length of each dimension of an array must be specified as part of the array - **CS0611**: *Array elements cannot be of type 'type'* - **CS0719**: *Array elements cannot be of static type* - **CS0820**: *Cannot assign array initializer to an implicitly typed local* -- **CS0826**: *No best type found for implicitly typed array.* +- **CS0826**: *No best type found for implicitly typed array* + +To use arrays with correct element types, follow these type restrictions. For more information, see [Implicitly typed local variables](../statements/declarations.md#implicitly-typed-local-variables) and [best common type](~/_csharpstandard/standard/expressions.md#126316-finding-the-best-common-type-of-a-set-of-expressions). -There are some types that cannot be used as the type of an array. These types include and . The type of an array can't be a `static` class, because instances of a `static` class can't be created. +- Don't use restricted types like and as array element types (**CS0611**). +- Don't use `static` classes as array element types because instances can't be created (**CS0719**). +- Initialize implicitly typed arrays with a `new` expression (**CS0820**). +- Ensure all elements in an implicitly typed array initializer have a best common type (**CS0826**). -You can declare arrays as [implicitly typed local variables](../statements/declarations.md#implicitly-typed-local-variables). The array must be initialized using a `new` expression. In addition, all elements in an array initializer must have a [best common type](~/_csharpstandard/standard/expressions.md#126316-finding-the-best-common-type-of-a-set-of-expressions). The following examples show how to declare an implicitly typed array: +The following examples show how to declare implicitly typed arrays: :::code language="csharp" source="./snippets/array-warnings/Program.cs" id="ImplicitInitializer"::: -You can ensure the best common type using any of the following techniques: +To ensure a best common type, use any of these techniques: - Give the array an explicit type. - Give all array elements the same type. -- Provide explicit casts on those elements that might be causing the problem. +- Provide explicit casts on elements that might be causing the problem. -## Invalid collection builder +## Invalid array initializer -The following errors indicate errors in your collection builder type: +- **CS0623**: *Array initializers can only be used in a variable or field initializer. Try using a new expression instead.* +- **CS0846**: *A nested array initializer is expected* +- **CS1925**: *Cannot initialize object of type 'type' with a collection initializer.* -- **CS9185**: *The `CollectionBuilderAttribute` builder type must be a non-generic class or struct.* -- **CS9186**: *The `CollectionBuilderAttribute` method name is invalid.* -- **CS9187**: *Could not find an accessible method with the expected signature: a static method with a single parameter of type `ReadOnlySpan`; and correct return type.* -- **CS9188**: *Type has a `CollectionBuilderAttribute` but no element type.* +These errors indicate invalid array initializer syntax. For more information, see [Arrays](../builtin-types/arrays.md). + +To create valid array initializers: -These errors indicate that your collection builder type needs modification. Remember the following rules: +- Use array initializers only in variable or field declarations (**CS0623**). Use a `new` expression in other contexts. +- Balance braces (`{` and `}`) around elements or child arrays (**CS0846**). +- Ensure the initializing expression matches the number of arrays in a jagged array initialization. +- Use collection initializers only with collection types, not with arrays or other types (**CS1925**). -- The collection type must have an iteration type. In other words, you can [`foreach`](~/_csharpstandard/standard/statements.md#1395-the-foreach-statement) the type as a collection. -- The collection builder type can't be a generic type. -- The method name specified on the must be a valid method name. For example, it can't be finalizer, or other name that contains invalid identifier characters. -- The collection builder method must be an accessible static method. It must return the collection type, and it must take a parameter of `ReadOnlySpan` where `T` matches the element type of the collection. +## Invalid collection builder + +- **CS9175**: *An expression tree may not contain a collection expression.* +- **CS9177**: *The 'CollectionBuilderAttribute' builder method return type must match collection type used in 'betterness'.* +- **CS9178**: *There is no target type for the natural type 'type'.* +- **CS9179**: *Collection expression type must have an applicable constructor that can be called with no arguments.* +- **CS9180**: *The 'CollectionBuilderAttribute' builder method must be a static method.* +- **CS9181**: *The 'CollectionBuilderAttribute' builder method parameter type must match parameter 'ReadOnlySpan<{0}>'* +- **CS9182**: *Invalid 'CollectionBuilderAttribute'. No matching '{0}' method found on builder type '{1}'.* +- **CS9183**: *The 'CollectionBuilderAttribute' method return type must be a non-abstract, non-interface type usable as a 'type'* +- **CS9185**: *A *static type* cannot be used as a type argument.* +- **CS9186**: *The `CollectionBuilderAttribute` method name is invalid.* +- **CS9187**: *Could not find an accessible 'Create' method with the expected signature: a static method with a single parameter of type 'ReadOnlySpan<{0}>' and return type '{1}'.* +- **CS9188**: *'scoped' cannot be used as a modifier on a collection expression type parameter.* +- **CS9190**: *The 'CollectionBuilderAttribute' method 'builderMethod' is inapplicable because it's generic.* +- **CS9192**: *Inline array conversions cannot be used with collection expressions.* +- **CS9193**: *Argument 'argument' may not be passed with the 'ref' keyword.* +- **CS9194**: *Argument 'argument' may not be passed with the 'out' keyword* +- **CS9195**: *Argument 'argument' may not be passed with the 'in' keyword* +- **CS9196**: *Feature 'collection expression' is not available in C# 'version'. Please use language version 'requiredVersion' or greater.* +- **CS9197**: *Feature 'inline arrays' is not available in C# 'version'. Please use language version 'requiredVersion' or greater.* +- **CS9198**: *Feature 'ref and unsafe in async and iterator methods' is not available in C# 'version'. Please use language version 'requiredVersion' or greater.* +- **CS9199**: *Feature 'collection expression' is not available in C# 'version'. Please use language version 'requiredVersion' or greater.* +- **CS9202**: *Feature 'ref readonly parameters' is not available in C# 'version'. Please use language version 'requiredVersion' or greater.* +- **CS9208**: *'nameof' operator cannot be used on an inline array access.* +- **CS9209**: *A ref-returning property 'property' cannot be used as a value argument.* +- **CS9211**: *The expression must be of type 'type' because it's being assigned by reference* +- **CS9212**: *Cannot use collection expression as the value in a fixed statement* +- **CS9217**: *A 'ref' local cannot be preserved across 'await' or 'yield' boundary.* +- **CS9218**: *'paramName' is a ref struct and cannot be the type of a parameter* +- **CS9221**: *The type 'type' may not be a ref struct or a type parameter allowing ref structs in order to use it as parameter 'parameter' in the generic type or method 'member'* +- **CS9223**: *A struct that contains 'ref' fields cannot be used in a collection expression.* +- **CS9228**: *Non-variable declaration of a ref struct is not allowed* +- **CS9232**: *Partial method declarations have signature differences.* +- **CS9233**: *The 'file' modifier can be used only on types defined in top level in a compilation unit* + +To create collection expressions with collection builder attributes correctly, follow these requirements. For more information, see [Collection expressions](../operators/collection-expressions.md). + +- Ensure the target type has an iteration type that supports `foreach` (**CS9188**). +- Don't use generic types as collection builder types (**CS9185**). +- Verify the method name specified in `CollectionBuilderAttribute` is valid (**CS9186**). +- Apply `CollectionBuilderAttribute` only with static methods that match the required signature: return the collection type and take a `ReadOnlySpan` parameter where `T` matches the element type (**CS9180**, **CS9181**, **CS9182**, **CS9183**, **CS9187**, **CS9190**). +- Ensure the return type matches and isn't abstract or an interface (**CS9177**, **CS9183**). +- Don't use ref structs or types with ref fields in collection expressions (**CS9218**, **CS9221**, **CS9223**, **CS9228**). +- Avoid using collection expressions in expression trees (**CS9175**). +- Use the correct language version for collection expressions and related features (**CS9196**, **CS9197**, **CS9198**, **CS9199**, **CS9202**). ## Common language specification warnings - **CS3007**: *Overloaded method 'method' differing only by unnamed array types is not CLS-compliant* - **CS3016**: *Arrays as attribute arguments is not CLS-compliant* +To write CLS-compliant code with arrays, follow these guidelines. For more information, see [Language independence](../../../standard/language-independence.md). + +- Don't create overloaded methods that differ only in array element types (**CS3007**). +- Don't use arrays as attribute arguments (**CS3016**). + CS3007 occurs if you have an overloaded method that takes a jagged array and the only difference between the method signatures is the element type of the array. To avoid this error, consider using a rectangular array rather than a jagged array or, if CLS Compliance isn't needed, remove the attribute. For more information on CLS Compliance, see [Language independence and language-independent components](../../../standard/language-independence.md). CS3016 indicates that not compliant with the Common Language Specification (CLS) to pass an array to an attribute. For more information on CLS compliance, see [Language independence and language-independent components](../../../standard/language-independence.md). diff --git a/docs/csharp/language-reference/compiler-messages/extension-declarations.md b/docs/csharp/language-reference/compiler-messages/extension-declarations.md index 6e0b9bb66c72a..3afc8068b58f5 100644 --- a/docs/csharp/language-reference/compiler-messages/extension-declarations.md +++ b/docs/csharp/language-reference/compiler-messages/extension-declarations.md @@ -1,7 +1,8 @@ --- -title: "Errors and warnings related to extension declarations" +title: "Resolve errors and warnings related to extension declarations" description: "These errors and warnings indicate that you need to modify the declaration of an extension method using the `this` modifier on the first parameter, or an extension declaration" -ms.date: 10/16/2025 +ms.date: 11/07/2025 +ai-usage: ai-assisted f1_keywords: - "CS1100" - "CS1101" @@ -44,6 +45,7 @@ f1_keywords: - "CS9323" - "CS9326" - "CS9329" + - "CS9339" helpviewer_keywords: - "CS1100" - "CS1101" @@ -88,9 +90,15 @@ helpviewer_keywords: - "CS9323" - "CS9326" - "CS9329" + - "CS9339" --- -# Errors and warnings related to extension methods declared with `this` parameters or `extension` blocks +# Resolve errors and warnings in extension member declarations +This article covers the following compiler errors: + + - [**CS1100**](#errors-related-to-this-parameter-extension-methods): *Method has a parameter modifier '`this`' which is not on the first parameter* - [**CS1101**](#errors-related-to-this-parameter-extension-methods): *The parameter modifier '`ref`' cannot be used with '`this`'.* - [**CS1102**](#common-errors-on-extension-declarations): *The parameter modifier '`out`' cannot be used with '`this`'.* @@ -134,14 +142,13 @@ helpviewer_keywords: - [**CS9323**](#errors-related-to-extension-block-declarations): *Cannot declare instance extension operator for a type that is not known to be a struct and is not known to be a class.* - [**CS9326**](#errors-related-to-extension-block-declarations): *'`name`': extension member names cannot be the same as their extended type.* - [**CS9329**](#errors-related-to-extension-block-declarations): *This extension block collides with another extension block. They result in conflicting content-based type names in metadata.* +- [**CS9339**](#errors-related-to-extension-block-declarations): *The extension resolution is ambiguous between the following members.* ## Common errors on extension declarations -The compiler emits these errors when you violate rules that apply to all extension member declarations, regardless of the syntax chosen: - - **CS1102**: *The parameter modifier '`out`' cannot be used with '`this`'.* -- **CS1106**: *Extension methods must be defined in a non generic static class.* - **CS1103**: *The first parameter of an extension method cannot be of a pointer type.* +- **CS1106**: *Extension methods must be defined in a non generic static class.* - **CS1109**: *Extension Methods must be defined on top level static classes, 'name' is a nested class.* - **CS1113**: *Extension method defined on a value type cannot be used to create delegates.* - **CS1743**: *Cannot specify a default value for the 'this' parameter.* @@ -149,18 +156,19 @@ The compiler emits these errors when you violate rules that apply to all extensi - **CS9284**: *The receiver parameter of an extension cannot have a default value.* - **CS9285**: *An extension container can have only one receiver parameter.* -Any extension declaration must follow these rules: +The compiler emits these errors when you violate rules that apply to all extension member declarations, regardless of the syntax chosen. For more information, see [Extension methods](../../programming-guide/classes-and-structs/extension-methods.md). -- Its containing type (`class` or `struct`) must be non-generic and `static`. -- Its containing type must be a top-level type. It can't be nested in another type. -- Members that extend an instance of a value type can't be converted to delegates. -- The receiver parameter can't include the `out` parameter modifier. -- The receiver parameter can't have a default argument value. -- Pointer types can't be extended. In other words, the parameter you apply the `this` modifier to can't be a pointer type. +To declare extension members correctly, follow these requirements: -## Errors related to extension block declarations +- Declare the containing type as a non-generic `static` class or struct (**CS1106**, **CS9283**). +- Declare the containing type at the top level, not nested within another type (**CS1109**, **CS9283**). +- Don't convert extension methods on value types to delegates (**CS1113**). Create a regular method instead. +- Don't use the `out` parameter modifier on the receiver parameter (**CS1102**). +- Don't provide default values for the receiver parameter (**CS1743**, **CS9284**). +- Don't extend pointer types (**CS1103**). The parameter you apply the `this` modifier to can't be a pointer type. +- Declare only one receiver parameter per extension container (**CS9285**). -These errors are specific to extension blocks, a C# 14 feature. Extension blocks are declared using the `extension` keyword in a static class. The `extension` declares the type and name of the receiver. All members inside the block declared with `extension` are extension members for that receiver: +## Errors related to extension block declarations - **CS9281**: *Extension declarations may not have a name.* - **CS9282**: *Extension declarations can include only methods or properties.* @@ -191,52 +199,59 @@ These errors are specific to extension blocks, a C# 14 feature. Extension blocks - **CS9323**: *Cannot declare instance extension operator for a type that is not known to be a struct and is not known to be a class.* - **CS9326**: *'`name`': extension member names cannot be the same as their extended type.* - **CS9329**: *This extension block collides with another extension block. They result in conflicting content-based type names in metadata.* +- **CS9339**: *The extension resolution is ambiguous between the following members.* -The contextual keyword [`extension`](../keywords/extension.md) declares an extension block. It can't be used for a type. - -Extension declarations must follow these rules: - -- The extension can't include a name token. The extension declares the receiver only. -- The receiver parameter can't have a default value. +These errors are specific to extension blocks, a C# 14 feature. Extension blocks are declared using the [`extension`](../keywords/extension.md) contextual keyword in a static class. For more information, see [Extension methods](../../programming-guide/classes-and-structs/extension-methods.md). -Extension members declared in an extension block must follow these rules, in addition to the [common rules](#common-errors-on-extension-declarations): +To declare extension blocks correctly, follow these requirements: -- Only methods and properties are valid extension member types. Extension members can extend an instance, or a type. -- The extension must provide a parameter name for the receiver in order to contain members that extend an instance. -- The receiver parameter name must be unique in that extension block. -- All extension members must use all type parameters declared on the extension. They can add more type parameters. -- Extension blocks can't be nested within another extension block. +- Don't include a name token in the extension declaration (**CS9281**). The extension declares the receiver only. +- Don't provide default values for the receiver parameter (**CS9284**, covered in [common errors](#common-errors-on-extension-declarations)). +- Don't use the `extension` keyword for types or aliases (**CS9306**). It's a contextual keyword for extension blocks only. -**CS9316** is emitted when you attempt to use an extension member as an argument to the `nameof` operator. Extension members aren't allowed in this context. +To declare extension members in extension blocks correctly, follow these requirements in addition to the [common rules](#common-errors-on-extension-declarations): -**CS9317**, **CS9318**, **CS9319**, **CS9320**, **CS9321**, **CS9322**, and **CS9323** are operator-related errors in extension blocks: +- Include only methods or properties as extension members (**CS9282**). Other member types aren't supported. +- Provide a parameter name for the receiver to contain instance extension members (**CS9303**). +- Ensure the receiver parameter name is unique within the extension block and doesn't conflict with type parameters (**CS9287**, **CS9288**, **CS9289**, **CS9290**, **CS9291**, **CS9292**, **CS9294**). +- Reference all type parameters declared on the extension in the extended type (**CS9295**). Additional type parameters can be added on individual members. +- Don't nest extension blocks within other extension blocks (**CS9309**). +- Use the `ref` modifier on the receiver parameter only with value types or generic types constrained to struct (**CS9300**). +- Use the `in` or `ref readonly` modifier on the receiver parameter only with concrete (non-generic) value types (**CS9301**). +- Don't use modifiers on unnamed receiver parameters (**CS9305**). +- Don't declare `protected` members in extension blocks (**CS9302**). Extension members must be accessible where the extension is in scope. +- Don't declare `init`-only accessors in extension blocks (**CS9304**). Use regular property setters instead. +- Don't use extension members as arguments to the `nameof` operator (**CS9316**). +- Choose member names that differ from the extended type name (**CS9326**). +- Ensure extension blocks have unique content-based type names in metadata (**CS9329**). Consolidate or differentiate extension blocks to avoid conflicts. +- Resolve ambiguous extension member calls by providing more specific type information or using qualified names (**CS9339**). -- **CS9317**: Unary operators must have the extended type as their parameter. -- **CS9318**: Increment (`++`) and decrement (`--`) operators must have the extended type as their parameter. -- **CS9319**: Binary operators must have at least one parameter that is the extended type. -- **CS9320**: Shift operators must have the extended type as their first operand. -- **CS9321**: You can't declare user-defined operators in extension blocks that extend static classes. -- **CS9322**: When extending a struct with instance operators, the receiver parameter must use the `ref` modifier. -- **CS9323**: You can't declare instance operators for types that aren't constrained to be either a struct or a class. +### Extension block operator requirements -**CS9326** is emitted when an extension member has the same name as the extended type. Choose a different name for the member. +Extension blocks support user-defined operators with specific requirements: -**CS9329** occurs when two extension blocks result in conflicting content-based type names in the compiled metadata. This typically happens when multiple extension blocks with the same receiver type and similar characteristics are declared. Consolidate the extension blocks or differentiate them in a way that produces unique metadata names. +- Unary operators must have the extended type as their parameter (**CS9317**). +- Increment (`++`) and decrement (`--`) operators must have the extended type as their parameter (**CS9318**). +- Binary operators must have at least one parameter that is the extended type (**CS9319**). +- Shift operators must have the extended type as their first operand (**CS9320**). +- Don't declare user-defined operators in extension blocks that extend static classes (**CS9321**). +- When extending a struct with instance operators, use the `ref` modifier on the receiver parameter (**CS9322**). +- Don't declare instance operators for types that aren't constrained to be either a struct or a class (**CS9323**). ## Errors related to `this` parameter extension methods -These errors are specific to extension methods where you declare the receiver by adding the `this` modifier to the first parameter of the method: - - **CS1100**: *Method has a parameter modifier '`this`' which is not on the first parameter* - **CS1101**: *The parameter modifier '`ref`' cannot be used with '`this`'.* - **CS1105**: *Extension methods must be static.* - **CS1110**: *Cannot define a new extension because the compiler required type cannot be found. Are you missing a reference to System.Core.dll?* - **CS1112**: *Do not use ''. Use the '`this`' keyword instead.* -An extension method where the receiver instance includes the `this` modifier must follow these rules, in addition to the [common rules](#common-errors-on-extension-declarations): +These errors are specific to extension methods where you declare the receiver by adding the `this` modifier to the first parameter. For more information, see [Extension methods](../../programming-guide/classes-and-structs/extension-methods.md). + +To declare `this` parameter extension methods correctly, follow these requirements in addition to the [common rules](#common-errors-on-extension-declarations): -- The method must have the `static` modifier. -- The `this` parameter modifier must be applied to the first parameter. It can't be applied to any other parameters on the method. -- The `ref` `out` parameter modifier can't be applied to the first parameter. To apply `ref`, you need to convert to an extension block. -- In .NET Framework apps, `System.Core.dll` must be added as a reference. -- You must specify the `this` modifier on the first parameter. You can't directly use the attribute instead. +- Add the `static` modifier to the method (**CS1105**). +- Apply the `this` parameter modifier only to the first parameter (**CS1100**). +- Don't combine the `ref` modifier with the `this` modifier (**CS1101**). To use `ref`, convert to an extension block. +- Add a reference to `System.Core.dll` in .NET Framework apps (**CS1110**). +- Use the `this` modifier on the first parameter instead of directly applying the attribute (**CS1112**). diff --git a/docs/csharp/language-reference/compiler-messages/feature-version-errors.md b/docs/csharp/language-reference/compiler-messages/feature-version-errors.md index 2f2ace8407605..d3eaae9a09ee4 100644 --- a/docs/csharp/language-reference/compiler-messages/feature-version-errors.md +++ b/docs/csharp/language-reference/compiler-messages/feature-version-errors.md @@ -58,6 +58,8 @@ f1_keywords: - "CS9268" - "CS9269" - "CS9271" + - "CS9327" + - "CS9328" helpviewer_keywords: - "CS0171" - "CS0188" @@ -115,6 +117,8 @@ helpviewer_keywords: - "CS9268" - "CS9269" - "CS9271" + - "CS9327" + - "CS9328" ms.date: 05/23/2025 --- # Resolve warnings related to language features and versions @@ -161,6 +165,8 @@ That's be design. The text closely matches the text of the compiler error / warn - **CS9268**: *Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.* - **CS9269**: *UnscopedRefAttribute is only valid in C# 11 or later or when targeting net7.0 or later.* - [**CS9271**](#implementation-specific-attributes): *The type '`Microsoft.CodeAnalysis.EmbeddedAttribute`' must be non-generic, internal, sealed, non-static, have a parameterless constructor, inherit from System.Attribute, and be able to be applied to any type.* +- **CS9327**: *Feature is not available in C# 14.0. Use newer language version.* +- **CS9328**: *Method uses a feature that is not supported by runtime async currently.* In addition, the following errors and warnings relate to struct initialization changes in recent versions: diff --git a/docs/csharp/language-reference/compiler-messages/overloaded-operator-errors.md b/docs/csharp/language-reference/compiler-messages/overloaded-operator-errors.md index 9458f1b54d92d..555ec6ab4b978 100644 --- a/docs/csharp/language-reference/compiler-messages/overloaded-operator-errors.md +++ b/docs/csharp/language-reference/compiler-messages/overloaded-operator-errors.md @@ -1,6 +1,6 @@ --- -title: Errors and warnings related to user defined operator declarations -description: This article helps you diagnose and correct compiler errors and warnings when you declare user defined operators in your types +title: Resolve errors and warnings related to user-defined operator declarations +description: This article helps you diagnose and correct compiler errors and warnings when you declare user-defined operators in your types f1_keywords: - "CS0056" - "CS0057" @@ -37,6 +37,9 @@ f1_keywords: - "CS9311" - "CS9312" - "CS9313" + - "CS9340" + - "CS9341" + - "CS9342" helpviewer_keywords: - "CS0056" - "CS0057" @@ -73,12 +76,15 @@ helpviewer_keywords: - "CS9311" - "CS9312" - "CS9313" -ms.date: 10/15/2025 + - "CS9340" + - "CS9341" + - "CS9342" +ms.date: 11/07/2025 ai-usage: ai-assisted --- -# Errors and warnings for overloaded, or user-defined operator declarations +# Resolve errors and warnings in user-defined operator declarations -There are several errors related to declaring overloaded operators. Overloaded operators are also referred to as user-defined operators +This article covers the following compiler errors: +- [**CS8509**](#incomplete-pattern-matching): *The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '...' is not covered.* +- [**CS9134**](#switch-expression-syntax-errors): *A switch expression arm does not begin with a 'case' keyword.* +- [**CS9135**](#switch-expression-syntax-errors): *A constant value of type is expected* +- [**CS9335, CS9336**](#redundant-patterns): *The pattern is redundant.* +- [**CS9337**](#redundant-patterns): *The pattern is too complex to analyze for redundancy.* + +## Switch expression syntax errors - **CS9134**: *A switch expression arm does not begin with a 'case' keyword.* - **CS9135**: *A constant value of type is expected* -- **CS9335**: *The pattern is redundant.* -- **CS9337**: *The pattern is too complex to analyze for redundancy.* -The compiler generates the following warnings for incomplete pattern matching expressions: +To write switch expressions correctly, follow the proper syntax rules. For more information, see [Switch expression](../operators/switch-expression.md). -- **CS8509**: *The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '...' is not covered.* +- Don't use the `case` keyword in switch expressions (**CS9134**). The `case` keyword is used in switch statements, not switch expressions. In a switch expression, each arm consists of a pattern, an optional case guard, the `=>` token, and an expression. +- Use constant values in patterns, not variables (**CS9135**). Pattern matching requires compile-time constants for value patterns. -The compiler generates CS9134 to help you convert a switch statement to a switch expression. The `case` keyword isn't used in a switch expression. If you have the `case` keyword in a switch expression, it must be removed: +The following example demonstrates the syntax error with `case`: ```csharp var answer = x switch @@ -38,24 +51,46 @@ var answer = x switch } ``` -The compiler generates CS9135 when the pattern isn't a constant value. You can't create pattern matching expressions to match against a variable. +To fix this error, remove the `case` keyword: + +```csharp +var answer = x switch +{ + 0 => false, + 1 => true, +} +``` + +## Incomplete pattern matching + +- **CS8509**: *The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '...' is not covered.* + +To create exhaustive switch expressions, cover all possible input values. For more information, see [Switch expression](../operators/switch-expression.md) and [Switch statement](../statements/selection-statements.md#the-switch-statement). + +Add switch arms that handle all possible input values. Use the discard pattern (`_`) to match any remaining values that you don't need to handle explicitly. -The following code snippets generate CS8509: +The following example generates CS8509: :::code language="csharp" source="./snippets/pattern-matching-warnings/Switch.cs" id="SwitchNotAllPossibleValues"::: -To address this warning, add switch arms that cover all possible input values. For example: +To fix this warning, add a default arm: :::code language="csharp" source="./snippets/pattern-matching-warnings/Switch.cs" id="SwitchAllPossibleValues"::: -The `_` pattern matches all remaining values. One scenario for the `_` pattern is matching invalid values, as shown in the preceding example. +The `_` pattern matches all remaining values. You can use this pattern to handle invalid or unexpected values. -The compiler generates CS9335 when you wrote a pattern where an `or` is redundant: +## Redundant patterns -:::code language="csharp" source="./snippets/pattern-matching-warnings/Switch.cs" id="RedundantPattern"::: +- **CS9335, CS9336**: *The pattern is redundant.* +- **CS9337**: *The pattern is too complex to analyze for redundancy.* + +To write clear pattern matching expressions, avoid redundant patterns. For more information, see [Patterns](../operators/patterns.md). -This warning indicates you likely meant `is not (null or 42)` or `is not (int or string)` instead. +- Review patterns that the compiler identifies as redundant (**CS9335**, **CS9336**). Redundant patterns can indicate a logic error where you meant to use `not` or different logical operators. +- Simplify complex patterns that are too difficult for the compiler to analyze (**CS9337**). Break down complex patterns into simpler, more maintainable expressions. -You can construct patterns that are too complex to analyze for redundancy. If you do that, the compiler warns you with CS9337. +The following example demonstrates a redundant pattern: + +:::code language="csharp" source="./snippets/pattern-matching-warnings/Switch.cs" id="RedundantPattern"::: -For more information, see [Switch](../statements/selection-statements.md#the-switch-statement). +This warning indicates you likely meant `is not (null or 42)` or `is not (int or string)` instead of using `or` at the top level. diff --git a/docs/csharp/language-reference/toc.yml b/docs/csharp/language-reference/toc.yml index 94decd6cadc06..ccba45bd2a50e 100644 --- a/docs/csharp/language-reference/toc.yml +++ b/docs/csharp/language-reference/toc.yml @@ -474,7 +474,7 @@ items: CS8320, CS8370, CS8371, CS8400, CS8401, CS8511, CS8627, CS8630, CS8652, CS8703, CS8704, CS8706, CS8773, CS8912, CS8919, CS8929, CS8936, CS8957, CS8967, CS9014, CS9015, CS9016, CS9017, CS9058, CS9064, CS9103, CS9171, CS9194, CS9202, CS9204, - CS9240, CS9260, CS9268, CS9269, CS9271 + CS9240, CS9260, CS9268, CS9269, CS9271, CS9327, CS9328 - name: Assembly references href: ./compiler-messages/assembly-references.md displayName: > @@ -496,7 +496,7 @@ items: CS0056, CS0057, CS0215, CS0216, CS0217, CS0218, CS0448, CS0552, CS0553, CS0554, CS0555, CS0556, CS0557, CS0558, CS0559, CS0562, CS0563, CS0564, CS0567, CS0590, CS0660, CS0661, CS0715, CS1037, CS1553, CS1554, CS8930, CS8931, CS9023, CS9024, - CS9025, CS9308, CS9310, CS9311, CS9312, CS9313 + CS9025, CS9308, CS9310, CS9311, CS9312, CS9313, CS9340, CS9341, CS9342 - name: Parameter / argument mismatch href: ./compiler-messages/parameter-argument-mismatch.md displayName: > @@ -533,7 +533,7 @@ items: CS1743, CS9281, CS9282, CS9283, CS9284, CS9285, CS9287, CS9288, CS9289, CS9290, CS9292, CS9293, CS9295, CS9300, CS9301, CS9302, CS9303, CS9304, CS9305, CS9306, CS9309, CS9316, CS9317, CS9318, CS9319, CS9320, CS9321, CS9322, CS9323, CS9326, - CS9329 + CS9329, CS9339 - name: Partial declarations href: ./compiler-messages/partial-declarations.md displayName: > @@ -560,7 +560,7 @@ items: CS8770, CS8774, CS8776, CS8775, CS8777, CS8819, CS8824, CS8825, CS8847 - name: Pattern matching warnings href: ./compiler-messages/pattern-matching-warnings.md - displayName: CS8509, CS9134, CS9135, CS9335, CS9337 + displayName: CS8509, CS9134, CS9135, CS9335, CS9336, CS9337 - name: String literal declarations href: ./compiler-messages/string-literal.md displayName: > @@ -573,7 +573,8 @@ items: CS0022, CS0178, CS0248, CS0251, CS0270, CS0611, CS0623, CS0650, CS0719, CS0747, CS0820, CS0826, CS0846, CS1062, CS1063, CS1064, CS1552, CS1586, CS1920, CS1921, CS1925, CS1950, CS1954, CS3007, CS3016, CS9174, CS9176, CS9185, CS9186, CS9187, - CS9188, CS9203, CS9208, CS9209, CS9210, CS9212, CS9213, CS9214, CS9215, CS9222 + CS9188, CS9203, CS9208, CS9209, CS9210, CS9212, CS9213, CS9214, CS9215, CS9222, + CS9332 - name: Inline arrays href: ./compiler-messages/inline-array-errors.md displayName: > diff --git a/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md b/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md index e33a9a15c0a6d..9fe1611f0a880 100644 --- a/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md +++ b/docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md @@ -548,11 +548,8 @@ f1_keywords: - "CS9096" - "CS9097" # C# 14 errors begin here - - "CS9327" - - "CS9328" - "CS9330" - "CS9331" - - "CS9332" - "CS9333" - "CS9334" - "CS9338" From ffda38411996fbd4ce28d6e6296ae7cd6c2e3369 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 12:10:27 -0800 Subject: [PATCH 07/12] Update System.Text.Json converter source links to main branch (#49670) --- .../system-text-json/converters-how-to.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/standard/serialization/system-text-json/converters-how-to.md b/docs/standard/serialization/system-text-json/converters-how-to.md index 05ebc619964d8..bc246901b9903 100644 --- a/docs/standard/serialization/system-text-json/converters-how-to.md +++ b/docs/standard/serialization/system-text-json/converters-how-to.md @@ -70,7 +70,7 @@ The following steps explain how to create a converter by following the basic pat * Override the `Write` method to serialize the incoming object of type `T`. Use the that is passed to the method to write the JSON. * Override the `CanConvert` method only if necessary. The default implementation returns `true` when the type to convert is of type `T`. Therefore, converters that support only type `T` don't need to override this method. For an example of a converter that does need to override this method, see the [polymorphic deserialization](#support-polymorphic-deserialization) section later in this article. -You can refer to the [built-in converters source code](https://github.com/dotnet/runtime/tree/81bf79fd9aa75305e55abe2f7e9ef3f60624a3a1/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/) as reference implementations for writing custom converters. +You can refer to the [built-in converters source code](https://github.com/dotnet/runtime/tree/main/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/) as reference implementations for writing custom converters. ## Steps to follow the factory pattern @@ -228,7 +228,7 @@ For scenarios that require type inference, the following code shows a custom con The example shows the converter code and a `WeatherForecast` class with `object` properties. The `Main` method deserializes a JSON string into a `WeatherForecast` instance, first without using the converter, and then using the converter. The console output shows that without the converter, the run-time type for the `Date` property is `JsonElement`; with the converter, the run-time type is `DateTime`. -The [unit tests folder](https://github.com/dotnet/runtime/tree/c72b54243ade2e1118ab24476220a2eba6057466/src/libraries/System.Text.Json/tests/Serialization/) in the `System.Text.Json.Serialization` namespace has more examples of custom converters that handle deserialization to `object` properties. +The [unit tests folder](https://github.com/dotnet/runtime/tree/main/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/CustomConverterTests) in the `System.Text.Json.Serialization` namespace has more examples of custom converters that handle deserialization to `object` properties. ### Support polymorphic deserialization @@ -364,18 +364,18 @@ When you use , The [Migrate from Newtonsoft.Json to System.Text.Json](migrate-from-newtonsoft.md) article contains additional samples of custom converters. -The [unit tests folder](https://github.com/dotnet/runtime/blob/81bf79fd9aa75305e55abe2f7e9ef3f60624a3a1/src/libraries/System.Text.Json/tests/Serialization/) in the `System.Text.Json.Serialization` source code includes other custom converter samples, such as: +The [unit tests folder](https://github.com/dotnet/runtime/tree/main/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/CustomConverterTests) in the `System.Text.Json.Serialization` source code includes other custom converter samples, such as: -* [Int32 converter that converts null to 0 on deserialize](https://github.com/dotnet/runtime/blob/81bf79fd9aa75305e55abe2f7e9ef3f60624a3a1/src/libraries/System.Text.Json/tests/Serialization/CustomConverterTests.NullValueType.cs) -* [Int32 converter that allows both string and number values on deserialize](https://github.com/dotnet/runtime/blob/81bf79fd9aa75305e55abe2f7e9ef3f60624a3a1/src/libraries/System.Text.Json/tests/Serialization/CustomConverterTests.Int32.cs) -* [Enum converter](https://github.com/dotnet/runtime/blob/81bf79fd9aa75305e55abe2f7e9ef3f60624a3a1/src/libraries/System.Text.Json/tests/Serialization/CustomConverterTests.Enum.cs) -* [List\ converter that accepts external data](https://github.com/dotnet/runtime/blob/81bf79fd9aa75305e55abe2f7e9ef3f60624a3a1/src/libraries/System.Text.Json/tests/Serialization/CustomConverterTests.List.cs) -* [Long[] converter that works with a comma-delimited list of numbers](https://github.com/dotnet/runtime/blob/81bf79fd9aa75305e55abe2f7e9ef3f60624a3a1/src/libraries/System.Text.Json/tests/Serialization/CustomConverterTests.Array.cs) +* [Int32 converter that converts null to 0 on deserialize](https://github.com/dotnet/runtime/blob/main/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/CustomConverterTests/CustomConverterTests.NullValueType.cs) +* [Int32 converter that allows both string and number values on deserialize](https://github.com/dotnet/runtime/blob/main/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/CustomConverterTests/CustomConverterTests.Int32.cs) +* [Enum converter](https://github.com/dotnet/runtime/blob/main/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/CustomConverterTests/CustomConverterTests.Enum.cs) +* [List\ converter that accepts external data](https://github.com/dotnet/runtime/blob/main/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/CustomConverterTests/CustomConverterTests.List.cs) +* [Long[] converter that works with a comma-delimited list of numbers](https://github.com/dotnet/runtime/blob/main/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/CustomConverterTests/CustomConverterTests.Array.cs) -If you need to make a converter that modifies the behavior of an existing built-in converter, you can get [the source code of the existing converter](https://github.com/dotnet/runtime/tree/81bf79fd9aa75305e55abe2f7e9ef3f60624a3a1/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters) to serve as a starting point for customization. +If you need to make a converter that modifies the behavior of an existing built-in converter, you can get [the source code of the existing converter](https://github.com/dotnet/runtime/tree/main/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters) to serve as a starting point for customization. ## Additional resources -* [Source code for built-in converters](https://github.com/dotnet/runtime/tree/81bf79fd9aa75305e55abe2f7e9ef3f60624a3a1/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters) +* [Source code for built-in converters](https://github.com/dotnet/runtime/tree/main/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters) * [System.Text.Json overview](overview.md) * [How to serialize and deserialize JSON](how-to.md) From 450e9e3094b1722bf63a5ddd2070e891020facc7 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 7 Nov 2025 13:49:05 -0800 Subject: [PATCH 08/12] Update package index with latest published versions (#49673) --- docs/azure/includes/dotnet-all.md | 1 + docs/azure/includes/dotnet-new.md | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/azure/includes/dotnet-all.md b/docs/azure/includes/dotnet-all.md index 05ba167f03daa..89e6780e1929c 100644 --- a/docs/azure/includes/dotnet-all.md +++ b/docs/azure/includes/dotnet-all.md @@ -149,6 +149,7 @@ | Provisioning - Container Service | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.Provisioning.ContainerService/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/Provisioning.ContainerService-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.ContainerService_1.0.0-beta.4/sdk/provisioning/Azure.Provisioning.ContainerService/) | | Provisioning - CosmosDB | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Provisioning.CosmosDB/1.0.0)
NuGet [1.1.0-beta.1](https://www.nuget.org/packages/Azure.Provisioning.CosmosDB/1.1.0-beta.1) | [docs](/dotnet/api/overview/azure/Provisioning.CosmosDB-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.CosmosDB_1.0.0/sdk/provisioning/Azure.Provisioning.CosmosDB/)
GitHub [1.1.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.CosmosDB_1.1.0-beta.1/sdk/provisioning/Azure.Provisioning.CosmosDB/) | | Provisioning - Deployment | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.Provisioning.Deployment/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/Provisioning.Deployment-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.Deployment_1.0.0-beta.2/sdk/provisioning/Azure.Provisioning.Deployment/) | +| Provisioning - Dns | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Provisioning.Dns/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Provisioning.Dns-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.Dns_1.0.0-beta.1/sdk/provisioning/Azure.Provisioning.Dns/) | | Provisioning - Event Grid | NuGet [1.1.0](https://www.nuget.org/packages/Azure.Provisioning.EventGrid/1.1.0) | [docs](/dotnet/api/overview/azure/Provisioning.EventGrid-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.EventGrid_1.1.0/sdk/provisioning/Azure.Provisioning.EventGrid/) | | Provisioning - Event Hubs | NuGet [1.1.0](https://www.nuget.org/packages/Azure.Provisioning.EventHubs/1.1.0) | [docs](/dotnet/api/overview/azure/Provisioning.EventHubs-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.EventHubs_1.1.0/sdk/provisioning/Azure.Provisioning.EventHubs/) | | Provisioning - Frontdoor | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Provisioning.FrontDoor/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Provisioning.FrontDoor-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.FrontDoor_1.0.0-beta.1/sdk/provisioning/Azure.Provisioning.FrontDoor/) | diff --git a/docs/azure/includes/dotnet-new.md b/docs/azure/includes/dotnet-new.md index 0160aff9f81cb..c130caa58020d 100644 --- a/docs/azure/includes/dotnet-new.md +++ b/docs/azure/includes/dotnet-new.md @@ -158,6 +158,7 @@ | Provisioning - Container Service | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.Provisioning.ContainerService/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/Provisioning.ContainerService-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.ContainerService_1.0.0-beta.4/sdk/provisioning/Azure.Provisioning.ContainerService/) | | Provisioning - CosmosDB | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Provisioning.CosmosDB/1.0.0)
NuGet [1.1.0-beta.1](https://www.nuget.org/packages/Azure.Provisioning.CosmosDB/1.1.0-beta.1) | [docs](/dotnet/api/overview/azure/Provisioning.CosmosDB-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.CosmosDB_1.0.0/sdk/provisioning/Azure.Provisioning.CosmosDB/)
GitHub [1.1.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.CosmosDB_1.1.0-beta.1/sdk/provisioning/Azure.Provisioning.CosmosDB/) | | Provisioning - Deployment | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.Provisioning.Deployment/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/Provisioning.Deployment-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.Deployment_1.0.0-beta.2/sdk/provisioning/Azure.Provisioning.Deployment/) | +| Provisioning - Dns | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Provisioning.Dns/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Provisioning.Dns-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.Dns_1.0.0-beta.1/sdk/provisioning/Azure.Provisioning.Dns/) | | Provisioning - Event Grid | NuGet [1.1.0](https://www.nuget.org/packages/Azure.Provisioning.EventGrid/1.1.0) | [docs](/dotnet/api/overview/azure/Provisioning.EventGrid-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.EventGrid_1.1.0/sdk/provisioning/Azure.Provisioning.EventGrid/) | | Provisioning - Event Hubs | NuGet [1.1.0](https://www.nuget.org/packages/Azure.Provisioning.EventHubs/1.1.0) | [docs](/dotnet/api/overview/azure/Provisioning.EventHubs-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.EventHubs_1.1.0/sdk/provisioning/Azure.Provisioning.EventHubs/) | | Provisioning - Frontdoor | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Provisioning.FrontDoor/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Provisioning.FrontDoor-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Provisioning.FrontDoor_1.0.0-beta.1/sdk/provisioning/Azure.Provisioning.FrontDoor/) | From 3ee81bf81346e5abb9e45e477d11a08587ea43cc Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Fri, 7 Nov 2025 16:50:05 -0500 Subject: [PATCH 09/12] Replace UWP with WinUI (#49672) The Windows docs team wants to emphasize WinUI over UWP --- docs/index.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.yml b/docs/index.yml index 8a30b9bde4abf..18ab3c0dfa31b 100644 --- a/docs/index.yml +++ b/docs/index.yml @@ -271,8 +271,8 @@ additionalContent: # Card - title: Desktop links: - - url: /uwp - text: Universal Windows apps + - url: /windows/apps/winui + text: WinUI apps - url: /dotnet/desktop/wpf/ text: Windows Presentation Foundation - url: /dotnet/desktop/winforms/ From 0803ef32b162802c82e377ac069cc9a024624c2d Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Fri, 7 Nov 2025 23:31:27 +0100 Subject: [PATCH 10/12] Fix note syntax for mstest analyzer docs (#49679) * Fix note syntax for mstest analyzer docs * Update mstest0034.md * Update mstest0053.md --- docs/core/testing/mstest-analyzers/mstest0034.md | 2 +- docs/core/testing/mstest-analyzers/mstest0039.md | 2 +- docs/core/testing/mstest-analyzers/mstest0053.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/core/testing/mstest-analyzers/mstest0034.md b/docs/core/testing/mstest-analyzers/mstest0034.md index f07e10d31fa3e..b13805dc2d593 100644 --- a/docs/core/testing/mstest-analyzers/mstest0034.md +++ b/docs/core/testing/mstest-analyzers/mstest0034.md @@ -24,7 +24,7 @@ ms.author: enjieid | **Introduced in version** | 3.6.0 | | **Is there a code fix** | No | -> [NOTE] +> [!NOTE] > This analyzer is no longer relevant for MSTest 4 as `ClassCleanupBehavior` was removed. ## Cause diff --git a/docs/core/testing/mstest-analyzers/mstest0039.md b/docs/core/testing/mstest-analyzers/mstest0039.md index bbe3078613846..7e9bfde4b087d 100644 --- a/docs/core/testing/mstest-analyzers/mstest0039.md +++ b/docs/core/testing/mstest-analyzers/mstest0039.md @@ -24,7 +24,7 @@ ms.author: ygerges | **Introduced in version** | 3.8.0 | | **Is there a code fix** | Yes | -> [NOTE] +> [!NOTE] > This analyzer is no longer relevant for MSTest 4 as the old assertion APIs were removed. ## Cause diff --git a/docs/core/testing/mstest-analyzers/mstest0053.md b/docs/core/testing/mstest-analyzers/mstest0053.md index eac408e4daa2d..8e5df69d3dbeb 100644 --- a/docs/core/testing/mstest-analyzers/mstest0053.md +++ b/docs/core/testing/mstest-analyzers/mstest0053.md @@ -25,7 +25,7 @@ ai-usage: ai-generated | **Introduced in version** | 3.11.0 | | **Is there a code fix** | Yes | -> [NOTE] +> [!NOTE] > This analyzer is no longer relevant for MSTest 4 as the assertion APIs with format parameters were removed. ## Cause From 9d4685bd4349b3838b31514ff30721ada4bdaada Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Fri, 7 Nov 2025 15:22:13 -0800 Subject: [PATCH 11/12] Add LSG diagnostic articles (#49678) --- .openpublishing.redirection.fundamentals.json | 16 --------- .../source-generator-overview.md | 14 +++++--- .../syslib-diagnostics/syslib1024.md | 17 ++++++++++ .../syslib-diagnostics/syslib1025.md | 17 ++++++++++ .../syslib-diagnostics/syslib1026.md | 17 ++++++++++ .../syslib-diagnostics/syslib1027.md | 33 +++++++++++++++++++ .../syslib-diagnostics/syslib1220-1229.md | 4 +-- docs/navigate/tools-diagnostics/toc.yml | 8 +++++ 8 files changed, 103 insertions(+), 23 deletions(-) create mode 100644 docs/fundamentals/syslib-diagnostics/syslib1024.md create mode 100644 docs/fundamentals/syslib-diagnostics/syslib1025.md create mode 100644 docs/fundamentals/syslib-diagnostics/syslib1026.md create mode 100644 docs/fundamentals/syslib-diagnostics/syslib1027.md diff --git a/.openpublishing.redirection.fundamentals.json b/.openpublishing.redirection.fundamentals.json index e5421abd3fa23..913887e237ead 100644 --- a/.openpublishing.redirection.fundamentals.json +++ b/.openpublishing.redirection.fundamentals.json @@ -249,22 +249,6 @@ "source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1004.md", "redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview" }, - { - "source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1024.md", - "redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview" - }, - { - "source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1025.md", - "redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview" - }, - { - "source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1026.md", - "redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview" - }, - { - "source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1027.md", - "redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview" - }, { "source_path_from_root": "/docs/fundamentals/syslib-diagnostics/syslib1028.md", "redirect_url": "/dotnet/fundamentals/syslib-diagnostics/source-generator-overview" diff --git a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md index 2b34cfaf71162..18794f73ea496 100644 --- a/docs/fundamentals/syslib-diagnostics/source-generator-overview.md +++ b/docs/fundamentals/syslib-diagnostics/source-generator-overview.md @@ -1,7 +1,7 @@ --- title: Analyzer diagnostics in .NET 6+ description: Learn about analyzer diagnostics created by source generators in .NET 6 and later versions that produce SYSLIB compiler warnings. -ms.date: 10/27/2023 +ms.date: 11/07/2025 --- # Source-generator diagnostics in .NET 6+ @@ -43,10 +43,10 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6 | [SYSLIB1021][1021] | Multiple message-template item names differ only by case | | [SYSLIB1022][1022] | Can't have malformed format strings (for example, dangling curly braces) | | [SYSLIB1023][1023] | Generating more than six arguments is not supported | -| SYSLIB1024 | Logging method argument uses unsupported `out` parameter modifier | -| SYSLIB1025 | Multiple logging methods cannot use the same event name within a class | -| SYSLIB1026 | C# language version not supported by the logging source generator. | -| SYSLIB1027 | Primary constructor parameter of type Microsoft.Extensions.Logging.ILogger is hidden by a field | +| [SYSLIB1024][1024] | Logging method argument uses unsupported `out` parameter modifier | +| [SYSLIB1025][1025] | Multiple logging methods cannot use the same event name within a class | +| [SYSLIB1026][1026] | C# language version not supported by the logging source generator. | +| [SYSLIB1027][1027] | Primary constructor parameter of type `Microsoft.Extensions.Logging.ILogger` is hidden by a field | | SYSLIB1028 | (Reserved for logging.) | | SYSLIB1029 | (Reserved for logging.) | | [SYSLIB1030][1030] | The `System.Text.Json` source generator did not generate serialization metadata for type | @@ -194,6 +194,10 @@ The following table provides an index to the `SYSLIB1XXX` diagnostics in .NET 6 [1021]: syslib1021.md [1022]: syslib1022.md [1023]: syslib1023.md +[1024]: syslib1024.md +[1025]: syslib1025.md +[1026]: syslib1026.md +[1027]: syslib1027.md [1030]: syslib1030.md [1031]: syslib1031.md [1032]: syslib1032.md diff --git a/docs/fundamentals/syslib-diagnostics/syslib1024.md b/docs/fundamentals/syslib-diagnostics/syslib1024.md new file mode 100644 index 0000000000000..bc6e68e003882 --- /dev/null +++ b/docs/fundamentals/syslib-diagnostics/syslib1024.md @@ -0,0 +1,17 @@ +--- +title: SYSLIB1024 error +description: Learn about the diagnostic that generates compile-time error SYSLIB1024. +ms.date: 11/07/2025 +f1_keywords: + - SYSLIB1024 +--- + +# SYSLIB1024: Argument is using the unsupported 'out' parameter modifier + +The `out` parameter modifier isn't supported for -annotated logging methods. + +## Workarounds + +Remove the `out` parameter modifier. + +[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] diff --git a/docs/fundamentals/syslib-diagnostics/syslib1025.md b/docs/fundamentals/syslib-diagnostics/syslib1025.md new file mode 100644 index 0000000000000..985bf09b8efb0 --- /dev/null +++ b/docs/fundamentals/syslib-diagnostics/syslib1025.md @@ -0,0 +1,17 @@ +--- +title: SYSLIB1025 error +description: Learn about the diagnostic that generates compile-time error SYSLIB1025. +ms.date: 11/07/2025 +f1_keywords: + - SYSLIB1025 +--- + +# SYSLIB1025: Multiple logging methods should not use the same event name within a class + +Within the scope of a class, log methods annotated with must use unique event names. + +## Workarounds + +Use a unique event name. + +[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] diff --git a/docs/fundamentals/syslib-diagnostics/syslib1026.md b/docs/fundamentals/syslib-diagnostics/syslib1026.md new file mode 100644 index 0000000000000..b29d6a508901d --- /dev/null +++ b/docs/fundamentals/syslib-diagnostics/syslib1026.md @@ -0,0 +1,17 @@ +--- +title: SYSLIB1026 error +description: Learn about the diagnostic that generates compile-time error SYSLIB1026. +ms.date: 11/07/2025 +f1_keywords: + - SYSLIB1026 +--- + +# SYSLIB1026: C# language version not supported by the source generator + +The logging source generator generates code using the [nullable](../../csharp/nullable-references.md) feature, which is only supported starting in C# 8. + +## Workarounds + +Set your C# language version to 8 or later. + +[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] diff --git a/docs/fundamentals/syslib-diagnostics/syslib1027.md b/docs/fundamentals/syslib-diagnostics/syslib1027.md new file mode 100644 index 0000000000000..bc9b616382676 --- /dev/null +++ b/docs/fundamentals/syslib-diagnostics/syslib1027.md @@ -0,0 +1,33 @@ +--- +title: SYSLIB1027 error +description: Learn about the diagnostic that generates compile-time error SYSLIB1027. +ms.date: 11/07/2025 +f1_keywords: + - SYSLIB1027 +--- + +# SYSLIB1027: Primary constructor parameter of type 'Microsoft.Extensions.Logging.ILogger' is hidden by a field + +A class has a primary constructor parameter of type that's hidden by a field in the class or a base class, which prevents its use. + +For example, the following class raises the `SYSLIB1027` diagnostic: + +```csharp +partial class C(ILogger logger) +{ + private readonly object logger = logger; + + [LoggerMessage(EventId = 0, Level = LogLevel.Debug, Message = "...")] + public partial void M1(); +} +``` + +## Workarounds + +Either remove the field or the primary constructor. For more information, see [Basic usage](../../core/extensions/logger-message-generator.md#basic-usage). + +[!INCLUDE [suppress-syslib-warning](includes/suppress-source-generator-diagnostics.md)] + +## See also + +- [Compile-time logging source generation](../../core/extensions/logger-message-generator.md) diff --git a/docs/fundamentals/syslib-diagnostics/syslib1220-1229.md b/docs/fundamentals/syslib-diagnostics/syslib1220-1229.md index 92576f7013c04..aeb2af99514bf 100644 --- a/docs/fundamentals/syslib-diagnostics/syslib1220-1229.md +++ b/docs/fundamentals/syslib-diagnostics/syslib1220-1229.md @@ -1,7 +1,7 @@ --- title: SYSLIB diagnostics for System.Text.Json.SourceGeneration description: Learn about the System.Text.Json source-generation analyzers that generate compile-time suggestions SYSLIB1220 through SYSLIB1229. -ms.date: 10/24/2023 +ms.date: 11/07/2025 f1_keywords: - syslib1220 - syslib1221 @@ -25,7 +25,7 @@ The following table shows the diagnostic IDs for System.Text.Json source-generat | `SYSLIB1222` | Constructor annotated with `JsonConstructorAttribute` is inaccessible. | | `SYSLIB1223` | Attributes deriving from `JsonConverterAttribute` are not supported by the source generator. | | `SYSLIB1224` | Types annotated with `JsonSerializableAttribute` must be classes deriving from `JsonSerializerContext`. | -| `SYSLIB1225` | Reserved for System.Text.Json.SourceGeneration. | +| `SYSLIB1225` | Type includes `ref` like property, field, or constructor parameter. | | `SYSLIB1226` | Reserved for System.Text.Json.SourceGeneration. | | `SYSLIB1227` | Reserved for System.Text.Json.SourceGeneration. | | `SYSLIB1228` | Reserved for System.Text.Json.SourceGeneration. | diff --git a/docs/navigate/tools-diagnostics/toc.yml b/docs/navigate/tools-diagnostics/toc.yml index c504a4d148d37..3bfea72f9aa3b 100644 --- a/docs/navigate/tools-diagnostics/toc.yml +++ b/docs/navigate/tools-diagnostics/toc.yml @@ -4112,6 +4112,14 @@ items: href: ../../fundamentals/syslib-diagnostics/syslib1022.md - name: SYSLIB1023 href: ../../fundamentals/syslib-diagnostics/syslib1023.md + - name: SYSLIB1024 + href: ../../fundamentals/syslib-diagnostics/syslib1024.md + - name: SYSLIB1025 + href: ../../fundamentals/syslib-diagnostics/syslib1025.md + - name: SYSLIB1026 + href: ../../fundamentals/syslib-diagnostics/syslib1026.md + - name: SYSLIB1027 + href: ../../fundamentals/syslib-diagnostics/syslib1027.md - name: SYSLIB1030 href: ../../fundamentals/syslib-diagnostics/syslib1030.md - name: SYSLIB1031 From 190e78f356350e0bb53b803b2c966ab2a89ec9ac Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 00:50:41 +0000 Subject: [PATCH 12/12] Add workaround for RID-specific tool publishing (#49295) --- .../compatibility/sdk/10.0/dotnet-tool-pack-publish.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/core/compatibility/sdk/10.0/dotnet-tool-pack-publish.md b/docs/core/compatibility/sdk/10.0/dotnet-tool-pack-publish.md index 6db7eca562eca..0f4d0080f841c 100644 --- a/docs/core/compatibility/sdk/10.0/dotnet-tool-pack-publish.md +++ b/docs/core/compatibility/sdk/10.0/dotnet-tool-pack-publish.md @@ -39,6 +39,15 @@ This change enables the creation of optimized, platform-specific .NET Tool packa If you want to create tools for only a subset of platforms, use `ToolPackageRuntimeIdentifiers`. If you want to disable RID-specific tool packages entirely, you should conditionally include or exclude the `RuntimeIdentifiers` property in your project file. +Alternatively, if you want to maintain the previous behavior (framework-dependent, platform-agnostic .NET Tools) even when a `RuntimeIdentifier` is specified, add the following properties to your project file: + +```xml + + false + false + +``` + ## Affected APIs None.