diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 3eb2f162addb8..b4d5cc3ab99ea 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -24,4 +24,4 @@ jobs: - name: 'Checkout Repository' uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: 'Dependency Review' - uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1 + uses: actions/dependency-review-action@bc41886e18ea39df68b1b1245f4184881938e050 # v4.7.2 diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index e39788bb6b09e..039d3e1dee3f4 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -71,6 +71,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@df559355d593797519d70b90fc8edd5db049e7a2 # v3.29.5 + uses: github/codeql-action/upload-sarif@96f518a34f7a870018057716cc4d7a5c014bd61c # v3.29.5 with: sarif_file: results.sarif diff --git a/docfx.json b/docfx.json index 6c77df53449db..5f42d09300ce8 100644 --- a/docfx.json +++ b/docfx.json @@ -920,7 +920,10 @@ "docs/csharp/specification/**/**.{md,yml}": "1825-days", "docs/framework/**/*.md": "3650-days", "docs/iot/**/**.{md,yml}": "1825-days", - "docs/visual-basic/**/**.{md,yml}": "3650-days" + "docs/visual-basic/**/**.{md,yml}": "3650-days", + "docs/visual-basic/whats-new/**/**.{md,yml}": "1095-days", + "docs/visual-basic/getting-started/**/**.{md,yml}": "1825-days", + "docs/visual-basic/developing-apps/**/**.{md,yml}": "1825-days" }, "no-loc": { "docs/orleans/**/**.md": [ diff --git a/docs/ai/quickstarts/snippets/local-ai/ollama.csproj b/docs/ai/quickstarts/snippets/local-ai/ollama.csproj index 705d81e328e2f..d499e3d5736ea 100644 --- a/docs/ai/quickstarts/snippets/local-ai/ollama.csproj +++ b/docs/ai/quickstarts/snippets/local-ai/ollama.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/ai/snippets/microsoft-extensions-ai/AI.Shared/AI.Shared.csproj b/docs/ai/snippets/microsoft-extensions-ai/AI.Shared/AI.Shared.csproj index cb165a841ea22..8e9407139a9a2 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/AI.Shared/AI.Shared.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/AI.Shared/AI.Shared.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CacheResponses/ConsoleAI.CacheResponses.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CacheResponses/ConsoleAI.CacheResponses.csproj index 7b7732d1dfc11..5050463a48195 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CacheResponses/ConsoleAI.CacheResponses.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CacheResponses/ConsoleAI.CacheResponses.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeClientMiddleware/ConsoleAI.ConsumeClientMiddleware.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeClientMiddleware/ConsoleAI.ConsumeClientMiddleware.csproj index a3dd7ce9e47e5..2c35d7418d2a2 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeClientMiddleware/ConsoleAI.ConsumeClientMiddleware.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeClientMiddleware/ConsoleAI.ConsumeClientMiddleware.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeRateLimitingEmbedding/ConsoleAI.ConsumeRateLimitingEmbedding.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeRateLimitingEmbedding/ConsoleAI.ConsumeRateLimitingEmbedding.csproj index ca3acb27f25bd..a174e5a00a793 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeRateLimitingEmbedding/ConsoleAI.ConsumeRateLimitingEmbedding.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeRateLimitingEmbedding/ConsoleAI.ConsumeRateLimitingEmbedding.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CreateEmbeddings/ConsoleAI.CreateEmbeddings.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CreateEmbeddings/ConsoleAI.CreateEmbeddings.csproj index ca3acb27f25bd..a174e5a00a793 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CreateEmbeddings/ConsoleAI.CreateEmbeddings.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CreateEmbeddings/ConsoleAI.CreateEmbeddings.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomClientMiddle/ConsoleAI.CustomClientMiddle.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomClientMiddle/ConsoleAI.CustomClientMiddle.csproj index 09a2464951608..03701415a1a65 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomClientMiddle/ConsoleAI.CustomClientMiddle.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomClientMiddle/ConsoleAI.CustomClientMiddle.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomEmbeddingsMiddle/ConsoleAI.CustomEmbeddingsMiddle.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomEmbeddingsMiddle/ConsoleAI.CustomEmbeddingsMiddle.csproj index 8da5bf14c42c2..3b39e3608c8f3 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomEmbeddingsMiddle/ConsoleAI.CustomEmbeddingsMiddle.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomEmbeddingsMiddle/ConsoleAI.CustomEmbeddingsMiddle.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.DependencyInjection/ConsoleAI.DependencyInjection.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.DependencyInjection/ConsoleAI.DependencyInjection.csproj index 14e5deb083513..00ea15e447225 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.DependencyInjection/ConsoleAI.DependencyInjection.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.DependencyInjection/ConsoleAI.DependencyInjection.csproj @@ -8,9 +8,9 @@ - - - + + + diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.FunctionalityPipelines/ConsoleAI.FunctionalityPipelines.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.FunctionalityPipelines/ConsoleAI.FunctionalityPipelines.csproj index 8dcfb965b9ac2..1c9e87f92b16f 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.FunctionalityPipelines/ConsoleAI.FunctionalityPipelines.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.FunctionalityPipelines/ConsoleAI.FunctionalityPipelines.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetResponseAsyncArgs/ConsoleAI.GetResponseAsyncArgs.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetResponseAsyncArgs/ConsoleAI.GetResponseAsyncArgs.csproj index ca3acb27f25bd..a174e5a00a793 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetResponseAsyncArgs/ConsoleAI.GetResponseAsyncArgs.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetResponseAsyncArgs/ConsoleAI.GetResponseAsyncArgs.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetStreamingResponseAsync/ConsoleAI.GetStreamingResponseAsync.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetStreamingResponseAsync/ConsoleAI.GetStreamingResponseAsync.csproj index 5a124aaa485f4..a174e5a00a793 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetStreamingResponseAsync/ConsoleAI.GetStreamingResponseAsync.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetStreamingResponseAsync/ConsoleAI.GetStreamingResponseAsync.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.StatelessStateful/ConsoleAI.StatelessStateful.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.StatelessStateful/ConsoleAI.StatelessStateful.csproj index 4b977f1d178e4..31f545a94a7e9 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.StatelessStateful/ConsoleAI.StatelessStateful.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.StatelessStateful/ConsoleAI.StatelessStateful.csproj @@ -8,11 +8,11 @@ - + - + diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ToolCalling/ConsoleAI.ToolCalling.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ToolCalling/ConsoleAI.ToolCalling.csproj index aa336f505dee2..02022ef75f2cf 100644 --- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ToolCalling/ConsoleAI.ToolCalling.csproj +++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ToolCalling/ConsoleAI.ToolCalling.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/azure/includes/dotnet-all.md b/docs/azure/includes/dotnet-all.md index d5718546ae9aa..05bdcdd2df041 100644 --- a/docs/azure/includes/dotnet-all.md +++ b/docs/azure/includes/dotnet-all.md @@ -111,7 +111,7 @@ | Synapse - Monitoring | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Analytics.Synapse.Monitoring/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Monitoring-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Monitoring_1.0.0-beta.3/sdk/synapse/Azure.Analytics.Synapse.Monitoring/) | | Synapse - Spark | NuGet [1.0.0-preview.8](https://www.nuget.org/packages/Azure.Analytics.Synapse.Spark/1.0.0-preview.8) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Spark-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-preview.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Spark_1.0.0-preview.8/sdk/synapse/Azure.Analytics.Synapse.Spark/) | | System Events | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Messaging.EventGrid.SystemEvents/1.0.0) | [docs](/dotnet/api/overview/azure/Messaging.EventGrid.SystemEvents-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid.SystemEvents_1.0.0/sdk/eventgrid/Azure.Messaging.EventGrid.SystemEvents/) | -| System.ClientModel | NuGet [1.6.0](https://www.nuget.org/packages/System.ClientModel/1.6.0) | [docs](/dotnet/api/overview/azure/System.ClientModel-readme) | GitHub [1.6.0](https://github.com/Azure/azure-sdk-for-net/tree/System.ClientModel_1.6.0/sdk/core/System.ClientModel/) | +| System.ClientModel | NuGet [1.6.1](https://www.nuget.org/packages/System.ClientModel/1.6.1) | [docs](/dotnet/api/overview/azure/System.ClientModel-readme) | GitHub [1.6.1](https://github.com/Azure/azure-sdk-for-net/tree/System.ClientModel_1.6.1/sdk/core/System.ClientModel/) | | Tables | NuGet [12.11.0](https://www.nuget.org/packages/Azure.Data.Tables/12.11.0) | [docs](/dotnet/api/overview/azure/Data.Tables-readme) | GitHub [12.11.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.Tables_12.11.0/sdk/tables/Azure.Data.Tables/) | | Text Analytics | NuGet [5.3.0](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.3.0) | [docs](/dotnet/api/overview/azure/AI.TextAnalytics-readme) | GitHub [5.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.3.0/sdk/textanalytics/Azure.AI.TextAnalytics/) | | Text Authoring | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.AI.Language.Text.Authoring/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/AI.Language.Text.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.Text.Authoring_1.0.0-beta.2/sdk/cognitivelanguage/Azure.AI.Language.Text.Authoring/) | @@ -348,7 +348,7 @@ | Resource Management - Resource Health | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.ResourceHealth/1.0.0)
NuGet [1.1.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.ResourceHealth/1.1.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.ResourceHealth-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ResourceHealth_1.0.0/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/)
GitHub [1.1.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ResourceHealth_1.1.0-beta.4/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/) | | Resource Management - Resource Manager | NuGet [1.13.2](https://www.nuget.org/packages/Azure.ResourceManager/1.13.2)
NuGet [1.14.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager/1.14.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager-readme) | GitHub [1.13.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager_1.13.2/sdk/resourcemanager/Azure.ResourceManager/)
GitHub [1.14.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager_1.14.0-beta.1/sdk/resourcemanager/Azure.ResourceManager/) | | Resource Management - Resource Mover | NuGet [1.1.1](https://www.nuget.org/packages/Azure.ResourceManager.ResourceMover/1.1.1)
NuGet [1.1.2-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.ResourceMover/1.1.2-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.ResourceMover-readme) | GitHub [1.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ResourceMover_1.1.1/sdk/resourcemover/Azure.ResourceManager.ResourceMover/)
GitHub [1.1.2-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ResourceMover_1.1.2-beta.2/sdk/resourcemover/Azure.ResourceManager.ResourceMover/) | -| Resource Management - Resources | NuGet [1.11.0](https://www.nuget.org/packages/Azure.ResourceManager.Resources/1.11.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Resources-readme) | GitHub [1.11.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Resources_1.11.0/sdk/resources/Azure.ResourceManager.Resources/) | +| Resource Management - Resources | NuGet [1.11.1](https://www.nuget.org/packages/Azure.ResourceManager.Resources/1.11.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Resources-readme) | GitHub [1.11.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Resources_1.11.1/sdk/resources/Azure.ResourceManager.Resources/) | | Resource Management - ScVmm | NuGet [1.0.0-beta.6](https://www.nuget.org/packages/Azure.ResourceManager.ScVmm/1.0.0-beta.6) | [docs](/dotnet/api/overview/azure/ResourceManager.ScVmm-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ScVmm_1.0.0-beta.6/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/) | | Resource Management - Secretsstoreextension | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.SecretsStoreExtension/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.SecretsStoreExtension-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.SecretsStoreExtension_1.0.0-beta.1/sdk/secretsstoreextension/Azure.ResourceManager.SecretsStoreExtension/) | | Resource Management - Security | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.SecurityCenter/1.1.0)
NuGet [1.2.0-beta.6](https://www.nuget.org/packages/Azure.ResourceManager.SecurityCenter/1.2.0-beta.6) | [docs](/dotnet/api/overview/azure/ResourceManager.SecurityCenter-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.SecurityCenter_1.1.0/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/)
GitHub [1.2.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.SecurityCenter_1.2.0-beta.6/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/) | @@ -414,7 +414,7 @@ | Speech Extension Telemetry | NuGet [1.45.0](https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech.Extension.Telemetry/1.45.0) | | | | 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.12.0](https://www.nuget.org/packages/Azure.Iot.Operations.Connector/0.12.0) | | | -| Unknown Display Name | NuGet [0.1.0-preview.1](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Aot/0.1.0-preview.1) | | | +| Unknown Display Name | NuGet [0.1.1-preview.1](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Aot/0.1.1-preview.1) | | | | Unknown Display Name | NuGet [1.1.2-preview](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.AzureCosmosDb.Mongo/1.1.2-preview) | | | | Unknown Display Name | NuGet [1.45.0](https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech.Extension.MAS/1.45.0) | | | | Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Extensions.Caching.Postgres/1.0.0) | | | diff --git a/docs/azure/includes/dotnet-new.md b/docs/azure/includes/dotnet-new.md index e1f66207790e5..60cc952a098f7 100644 --- a/docs/azure/includes/dotnet-new.md +++ b/docs/azure/includes/dotnet-new.md @@ -116,7 +116,7 @@ | Synapse - Monitoring | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Analytics.Synapse.Monitoring/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Monitoring-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Monitoring_1.0.0-beta.3/sdk/synapse/Azure.Analytics.Synapse.Monitoring/) | | Synapse - Spark | NuGet [1.0.0-preview.8](https://www.nuget.org/packages/Azure.Analytics.Synapse.Spark/1.0.0-preview.8) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Spark-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-preview.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Spark_1.0.0-preview.8/sdk/synapse/Azure.Analytics.Synapse.Spark/) | | System Events | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Messaging.EventGrid.SystemEvents/1.0.0) | [docs](/dotnet/api/overview/azure/Messaging.EventGrid.SystemEvents-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid.SystemEvents_1.0.0/sdk/eventgrid/Azure.Messaging.EventGrid.SystemEvents/) | -| System.ClientModel | NuGet [1.6.0](https://www.nuget.org/packages/System.ClientModel/1.6.0) | [docs](/dotnet/api/overview/azure/System.ClientModel-readme) | GitHub [1.6.0](https://github.com/Azure/azure-sdk-for-net/tree/System.ClientModel_1.6.0/sdk/core/System.ClientModel/) | +| System.ClientModel | NuGet [1.6.1](https://www.nuget.org/packages/System.ClientModel/1.6.1) | [docs](/dotnet/api/overview/azure/System.ClientModel-readme) | GitHub [1.6.1](https://github.com/Azure/azure-sdk-for-net/tree/System.ClientModel_1.6.1/sdk/core/System.ClientModel/) | | Tables | NuGet [12.11.0](https://www.nuget.org/packages/Azure.Data.Tables/12.11.0) | [docs](/dotnet/api/overview/azure/Data.Tables-readme) | GitHub [12.11.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.Tables_12.11.0/sdk/tables/Azure.Data.Tables/) | | Text Analytics | NuGet [5.3.0](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.3.0) | [docs](/dotnet/api/overview/azure/AI.TextAnalytics-readme) | GitHub [5.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.3.0/sdk/textanalytics/Azure.AI.TextAnalytics/) | | Text Authoring | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.AI.Language.Text.Authoring/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/AI.Language.Text.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.Text.Authoring_1.0.0-beta.2/sdk/cognitivelanguage/Azure.AI.Language.Text.Authoring/) | @@ -359,7 +359,7 @@ | Resource Management - Resource Health | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.ResourceHealth/1.0.0)
NuGet [1.1.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.ResourceHealth/1.1.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.ResourceHealth-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ResourceHealth_1.0.0/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/)
GitHub [1.1.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ResourceHealth_1.1.0-beta.4/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/) | | Resource Management - Resource Manager | NuGet [1.13.2](https://www.nuget.org/packages/Azure.ResourceManager/1.13.2)
NuGet [1.14.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager/1.14.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager-readme) | GitHub [1.13.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager_1.13.2/sdk/resourcemanager/Azure.ResourceManager/)
GitHub [1.14.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager_1.14.0-beta.1/sdk/resourcemanager/Azure.ResourceManager/) | | Resource Management - Resource Mover | NuGet [1.1.1](https://www.nuget.org/packages/Azure.ResourceManager.ResourceMover/1.1.1)
NuGet [1.1.2-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.ResourceMover/1.1.2-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.ResourceMover-readme) | GitHub [1.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ResourceMover_1.1.1/sdk/resourcemover/Azure.ResourceManager.ResourceMover/)
GitHub [1.1.2-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ResourceMover_1.1.2-beta.2/sdk/resourcemover/Azure.ResourceManager.ResourceMover/) | -| Resource Management - Resources | NuGet [1.11.0](https://www.nuget.org/packages/Azure.ResourceManager.Resources/1.11.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Resources-readme) | GitHub [1.11.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Resources_1.11.0/sdk/resources/Azure.ResourceManager.Resources/) | +| Resource Management - Resources | NuGet [1.11.1](https://www.nuget.org/packages/Azure.ResourceManager.Resources/1.11.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Resources-readme) | GitHub [1.11.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Resources_1.11.1/sdk/resources/Azure.ResourceManager.Resources/) | | Resource Management - ScVmm | NuGet [1.0.0-beta.6](https://www.nuget.org/packages/Azure.ResourceManager.ScVmm/1.0.0-beta.6) | [docs](/dotnet/api/overview/azure/ResourceManager.ScVmm-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ScVmm_1.0.0-beta.6/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/) | | Resource Management - Secretsstoreextension | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.SecretsStoreExtension/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.SecretsStoreExtension-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.SecretsStoreExtension_1.0.0-beta.1/sdk/secretsstoreextension/Azure.ResourceManager.SecretsStoreExtension/) | | Resource Management - Security | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.SecurityCenter/1.1.0)
NuGet [1.2.0-beta.6](https://www.nuget.org/packages/Azure.ResourceManager.SecurityCenter/1.2.0-beta.6) | [docs](/dotnet/api/overview/azure/ResourceManager.SecurityCenter-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.SecurityCenter_1.1.0/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/)
GitHub [1.2.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.SecurityCenter_1.2.0-beta.6/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/) | diff --git a/docs/azure/sdk/snippets/unit-testing/UnitTestingSampleApp.csproj b/docs/azure/sdk/snippets/unit-testing/UnitTestingSampleApp.csproj index 754b71e273021..f51b57f425e2d 100644 --- a/docs/azure/sdk/snippets/unit-testing/UnitTestingSampleApp.csproj +++ b/docs/azure/sdk/snippets/unit-testing/UnitTestingSampleApp.csproj @@ -10,13 +10,13 @@ - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/docs/core/compatibility/8.0.md b/docs/core/compatibility/8.0.md index b475fba01d0bf..6c56c864ba3aa 100644 --- a/docs/core/compatibility/8.0.md +++ b/docs/core/compatibility/8.0.md @@ -17,6 +17,7 @@ If you're migrating an app to .NET 8, the breaking changes listed here might aff | ---------------------------------------------------------------------------------------------------- | ------------------- | | [ConcurrencyLimiterMiddleware is obsolete](aspnet-core/8.0/concurrencylimitermiddleware-obsolete.md) | Source incompatible | | [Custom converters for serialization removed](aspnet-core/8.0/problemdetails-custom-converters.md) | Behavioral change | +| [Forwarded Headers Middleware ignores X-Forwarded-* headers from unknown proxies](aspnet-core/8.0/forwarded-headers-unknown-proxies.md) | Behavioral change | | [ISystemClock is obsolete](aspnet-core/8.0/isystemclock-obsolete.md) | Source incompatible | | [Minimal APIs: IFormFile parameters require anti-forgery checks](aspnet-core/8.0/antiforgery-checks.md) | Behavioral change | | [Rate-limiting middleware requires AddRateLimiter](aspnet-core/8.0/addratelimiter-requirement.md) | Behavioral change | diff --git a/docs/core/compatibility/9.0.md b/docs/core/compatibility/9.0.md index 4173ed2b3f948..aee1b828ef5af 100644 --- a/docs/core/compatibility/9.0.md +++ b/docs/core/compatibility/9.0.md @@ -13,13 +13,14 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff ## ASP.NET Core -| Title | Type of change | Introduced version | -|----------------------------------------------------------------------------------------------------------------------------|---------------------|--------------------| -| [DefaultKeyResolution.ShouldGenerateNewKey has altered meaning](aspnet-core/9.0/key-resolution.md) | Behavioral change | Preview 3 | -| [Dev cert export no longer creates folder](aspnet-core/9.0/certificate-export.md) | Behavioral change | RC 1 | -| [HostBuilder enables ValidateOnBuild/ValidateScopes in development environment](aspnet-core/9.0/hostbuilder-validation.md) | Behavioral change | Preview 7 | -| [Legacy Mono and Emscripten APIs not exported to global namespace](aspnet-core/9.0/legacy-apis.md) | Source incompatible | GA | -| [Middleware types with multiple constructors](aspnet-core/9.0/middleware-constructors.md) | Behavioral change | RC 1 | +| Title | Type of change | +|------------------------------------------------------------------------------------------------|-------------------| +| [DefaultKeyResolution.ShouldGenerateNewKey altered meaning](aspnet-core/9.0/key-resolution.md) | Behavioral change | +| [Dev cert export no longer creates folder](aspnet-core/9.0/certificate-export.md) | Behavioral change | +| [Forwarded Headers Middleware ignores X-Forwarded-* headers from unknown proxies](aspnet-core/8.0/forwarded-headers-unknown-proxies.md) | Behavioral change | +| [HostBuilder enables ValidateOnBuild/ValidateScopes in development environment](aspnet-core/9.0/hostbuilder-validation.md) | Behavioral change | +| [Legacy Mono and Emscripten APIs not exported to global namespace](aspnet-core/9.0/legacy-apis.md) | Source incompatible | +| [Middleware types with multiple constructors](aspnet-core/9.0/middleware-constructors.md) | Behavioral change | ## Containers diff --git a/docs/core/compatibility/aspnet-core/8.0/forwarded-headers-unknown-proxies.md b/docs/core/compatibility/aspnet-core/8.0/forwarded-headers-unknown-proxies.md new file mode 100644 index 0000000000000..62fcc4db7e592 --- /dev/null +++ b/docs/core/compatibility/aspnet-core/8.0/forwarded-headers-unknown-proxies.md @@ -0,0 +1,71 @@ +--- +title: "Breaking change: Forwarded Headers Middleware ignores X-Forwarded-* headers from unknown proxies" +description: Learn about the breaking change in ASP.NET Core where Forwarded Headers Middleware now ignores headers from proxies that aren't explicitly configured as trusted. +ms.date: 08/15/2025 +--- +# Forwarded Headers Middleware ignores X-Forwarded-* headers from unknown proxies + +Starting in ASP.NET Core 8.0.17 and 9.0.6, the Forwarded Headers Middleware ignores all `X-Forwarded-*` headers from proxies that aren't explicitly configured as trusted. This change was made for security hardening, as the proxy and IP lists weren't being applied in all cases. + +## Version introduced + +ASP.NET Core 8.0.17 +ASP.NET Core 9.0.6 + +## Previous behavior + +Previously, the middleware, when not configured to use `X-Forwarded-For`, processed `X-Forwarded-Prefix`, `X-Forwarded-Proto`, and `X-Forwarded-Host` headers from any source. That behavior potentially allowed malicious or misconfigured proxies/clients to spoof these headers and affect an application's understanding of client information. + +## New behavior + +Starting in .NET 8 and .NET 9 servicing releases, only headers sent by known, trusted proxies (as configured via and ) are processed. Headers from unknown sources are ignored. + +> [!NOTE] +> If your deployment relied on forwarded headers from proxies not configured in your application's trusted proxy list, those headers are no longer honored. + +This change can cause behavior like infinite redirects if you're using the HTTPS redirection middleware and using TLS termination in your proxy. It can also cause authentication to fail if you're using TLS termination and expecting an HTTPS request. + +## Type of breaking change + +This change is a [behavioral change](../../categories.md#behavioral-change). + +## Reason for change + +The change was made for security hardening, as the proxy and IP lists weren't being applied in all cases. + +## Recommended action + +Review your deployment topology. Ensure that all legitimate proxy servers in front of your app are properly added to or in your configuration. + +```csharp +app.UseForwardedHeaders(new ForwardedHeadersOptions +{ + KnownProxies = { IPAddress.Parse("YOUR_PROXY_IP") } +}); +``` + +Or, for a network: + +```csharp +app.UseForwardedHeaders(new ForwardedHeadersOptions +{ + KnownNetworks = { new IPNetwork(IPAddress.Parse("YOUR_NETWORK_IP"), PREFIX_LENGTH) } +}); +``` + +If you wish to enable the previous behavior, which isn't recommended due to security risks, you can do so by clearing the `KnownNetworks` and `KnownProxies` lists in to allow any proxy or network to forward these headers. + +You can also set the `ASPNETCORE_FORWARDEDHEADERS_ENABLED` environment variable to `true`, which clears the lists and enables `ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto`. + +For applications that target .NET 9 or earlier, you can set the `Microsoft.AspNetCore.HttpOverrides.IgnoreUnknownProxiesWithoutFor` [AppContext](/dotnet/fundamentals/runtime-libraries/system-appcontext) switch to `"true"` or `1` to get back to the previous behavior. Alternatively, set the `MICROSOFT_ASPNETCORE_HTTPOVERRIDES_IGNORE_UNKNOWN_PROXIES_WITHOUT_FOR` environment variable. + +> [!NOTE] +> In cloud environments, the proxy IPs can change over the lifetime of the app, and `ASPNETCORE_FORWARDEDHEADERS_ENABLED` is sometimes used to make forwarded headers work. + +## Affected APIs + +- + +## See also + +- [Configure ASP.NET Core to work with proxy servers and load balancers](/aspnet/core/host-and-deploy/proxy-load-balancer) diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index f546155657b7b..96ff8b33978a3 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -164,6 +164,8 @@ items: href: aspnet-core/9.0/key-resolution.md - name: Dev cert export no longer creates folder href: aspnet-core/9.0/certificate-export.md + - name: Forwarded Headers Middleware ignores X-Forwarded-* headers from unknown proxies + href: aspnet-core/8.0/forwarded-headers-unknown-proxies.md - name: HostBuilder enables ValidateOnBuild/ValidateScopes in development environment href: aspnet-core/9.0/hostbuilder-validation.md - name: Legacy Mono and Emscripten APIs not exported to global namespace @@ -320,6 +322,8 @@ items: href: aspnet-core/8.0/concurrencylimitermiddleware-obsolete.md - name: Custom converters for serialization removed href: aspnet-core/8.0/problemdetails-custom-converters.md + - name: Forwarded Headers Middleware ignores X-Forwarded-* headers from unknown proxies + href: aspnet-core/8.0/forwarded-headers-unknown-proxies.md - name: ISystemClock is obsolete href: aspnet-core/8.0/isystemclock-obsolete.md - name: "Minimal APIs: IFormFile parameters require anti-forgery checks" diff --git a/docs/core/testing/snippets/order-unit-tests/csharp/MSTest.Project/MSTest.Project.csproj b/docs/core/testing/snippets/order-unit-tests/csharp/MSTest.Project/MSTest.Project.csproj index 2ab27c1f1e28d..e5ee2a02c5832 100644 --- a/docs/core/testing/snippets/order-unit-tests/csharp/MSTest.Project/MSTest.Project.csproj +++ b/docs/core/testing/snippets/order-unit-tests/csharp/MSTest.Project/MSTest.Project.csproj @@ -9,8 +9,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/docs/core/testing/snippets/order-unit-tests/csharp/NUnit.TestProject/NUnit.Project.csproj b/docs/core/testing/snippets/order-unit-tests/csharp/NUnit.TestProject/NUnit.Project.csproj index ee5070f46a23b..0f4a8e25b0006 100644 --- a/docs/core/testing/snippets/order-unit-tests/csharp/NUnit.TestProject/NUnit.Project.csproj +++ b/docs/core/testing/snippets/order-unit-tests/csharp/NUnit.TestProject/NUnit.Project.csproj @@ -8,10 +8,10 @@ - - + + - + all runtime; build; native; contentfiles; analyzers diff --git a/docs/core/testing/snippets/order-unit-tests/csharp/XUnit.TestProject/XUnit.Project.csproj b/docs/core/testing/snippets/order-unit-tests/csharp/XUnit.TestProject/XUnit.Project.csproj index 0eb444dc93117..1dd7486bccd5b 100644 --- a/docs/core/testing/snippets/order-unit-tests/csharp/XUnit.TestProject/XUnit.Project.csproj +++ b/docs/core/testing/snippets/order-unit-tests/csharp/XUnit.TestProject/XUnit.Project.csproj @@ -10,7 +10,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/docs/core/testing/unit-testing-mstest-sdk.md b/docs/core/testing/unit-testing-mstest-sdk.md index fc27fba9e0064..026a397815c9e 100644 --- a/docs/core/testing/unit-testing-mstest-sdk.md +++ b/docs/core/testing/unit-testing-mstest-sdk.md @@ -19,7 +19,7 @@ By default, the MSTest SDK discovers and runs your tests using the [MSTest runne You can enable `MSTest.Sdk` in a project by simply updating the `Sdk` attribute of the `Project` node of your project: ```xml - + net8.0 @@ -29,7 +29,7 @@ You can enable `MSTest.Sdk` in a project by simply updating the `Sdk` attribute ``` > [!NOTE] -> `/3.8.3` is given as example and can be replaced with any newer version. +> `/3.10.2` is given as example and can be replaced with any newer version. To simplify handling of versions, we recommend setting the SDK version at solution level using the _global.json_ file. For example, your project file would look like: @@ -48,7 +48,7 @@ Then, specify the `MSTest.Sdk` version in the _global.json_ file as follows: ```json { "msbuild-sdks": { - "MSTest.Sdk": "3.8.3" + "MSTest.Sdk": "3.10.2" } } ``` @@ -63,6 +63,10 @@ You don't need anything else to build and run your tests and you can use the sam > By switching to the `MSTest.Sdk`, you opt in to using the [MSTest runner (enables Microsoft.Testing.Platform for MSTest)](./unit-testing-mstest-runner-intro.md), including with [dotnet test](./microsoft-testing-platform-integration-dotnet-test.md). That requires modifying your CI and local CLI calls, and also impacts the available entries of the _.runsettings_. You can use `MSTest.Sdk` and still keep the old integrations and tools by instead switching the [runner](#select-the-runner). > By default, MSTest.Sdk sets `EnableMSTestRunner` and `TestingPlatformDotnetTestSupport` to true. For more information about dotnet test and its different modes for running Microsoft.Testing.Platform, see [Testing with dotnet test](./unit-testing-with-dotnet-test.md). +## Test utility helper libraries + +If the project that uses MSTest.Sdk is intended to be a test utility helper library, and doesn't by itself contain any runnable tests, the project should have `false`. + ## Select the runner By default, MSTest SDK relies on [Microsoft.Testing.Platform](./unit-testing-mstest-runner-intro.md), but you can switch to [VSTest](/visualstudio/test/vstest-console-options) by adding the property `true`. @@ -111,7 +115,7 @@ You can set the profile using the property `TestingExtensionsProfile` with one o Here's a full example, using the `None` profile: ```xml - + net8.0 @@ -138,7 +142,7 @@ Extensions can be enabled and disabled by MSBuild properties with the pattern `E For example, to enable the crash dump extension (NuGet package [Microsoft.Testing.Extensions.CrashDump](https://www.nuget.org/packages/Microsoft.Testing.Extensions.CrashDump)), you can use the following property `EnableMicrosoftTestingExtensionsCrashDump` set to `true`: ```xml - + net8.0 @@ -160,7 +164,7 @@ This property pattern can be used to enable an additional extension on top of th You can also disable an extension that's coming from the selected profile. For example, disable the `MS Code Coverage` extension by setting `false`: ```xml - + net8.0 @@ -232,7 +236,7 @@ Add the version to your `global.json`: ```json { "msbuild-sdks": { - "MSTest.Sdk": "3.8.3" + "MSTest.Sdk": "3.10.2" } } ``` diff --git a/docs/csharp/fundamentals/coding-style/identifier-names.md b/docs/csharp/fundamentals/coding-style/identifier-names.md index 8f45b2518ad22..e93bc1ded9ff9 100644 --- a/docs/csharp/fundamentals/coding-style/identifier-names.md +++ b/docs/csharp/fundamentals/coding-style/identifier-names.md @@ -2,6 +2,7 @@ title: "Identifier names - rules and conventions" description: "Learn the rules for valid identifier names in the C# programming language. In addition, learn the common naming conventions used by the .NET runtime team and the .NET docs team." ms.date: 11/27/2023 +ai-usage: ai-assisted --- # C# identifier naming rules and conventions @@ -159,6 +160,22 @@ public T SomeMethod(int someNumber, bool isValid) } ``` +#### Primary constructor parameters + +How you name primary constructor parameters depends on the type being declared: + +- For `class` and `struct` types: Use camel casing, consistent with other method parameters. + + :::code language="csharp" source="./snippets/identifier-names/PrimaryConstructorExamples.cs" id="ClassPrimaryConstructor"::: + + :::code language="csharp" source="./snippets/identifier-names/PrimaryConstructorExamples.cs" id="StructPrimaryConstructor"::: + +- For `record` types: Use Pascal casing, as the parameters become public properties. + + :::code language="csharp" source="./snippets/identifier-names/PrimaryConstructorExamples.cs" id="RecordPrimaryConstructor"::: + +For more information on primary constructors, see [Primary constructors](../../programming-guide/classes-and-structs/instance-constructors.md#primary-constructors). + For more information on C# naming conventions, see the [.NET Runtime team's coding style](https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/coding-style.md). ### Type parameter naming guidelines diff --git a/docs/csharp/fundamentals/coding-style/snippets/identifier-names/PrimaryConstructorExamples.cs b/docs/csharp/fundamentals/coding-style/snippets/identifier-names/PrimaryConstructorExamples.cs new file mode 100644 index 0000000000000..ded26afcef2a3 --- /dev/null +++ b/docs/csharp/fundamentals/coding-style/snippets/identifier-names/PrimaryConstructorExamples.cs @@ -0,0 +1,48 @@ +using System; +using Microsoft.Extensions.Logging; + +namespace IdentifierNamingExamples; + +// +public class DataService(IWorkerQueue workerQueue, ILogger logger) +{ + public void ProcessData() + { + // Use the parameters directly + logger.LogInformation("Processing data"); + workerQueue.Enqueue("data"); + } +} +// + +// +public struct Point(double x, double y) +{ + public double Distance => Math.Sqrt(x * x + y * y); +} +// + +// +public record Person(string FirstName, string LastName); +public record Address(string Street, string City, string PostalCode); +// + +// Supporting interfaces for examples +public interface IWorkerQueue +{ + void Enqueue(string item); + int Count { get; } +} + +// Add a simple main method to make it an executable +public class Program +{ + public static void Main() + { + // Example usage + var person = new Person("John", "Doe"); + var address = new Address("123 Main St", "Anytown", "12345"); + Console.WriteLine($"{person.FirstName} {person.LastName}"); + Console.WriteLine($"{address.Street}, {address.City} {address.PostalCode}"); + } +} \ No newline at end of file diff --git a/docs/csharp/fundamentals/coding-style/snippets/identifier-names/identifier-names.csproj b/docs/csharp/fundamentals/coding-style/snippets/identifier-names/identifier-names.csproj new file mode 100644 index 0000000000000..1fbb9f630550c --- /dev/null +++ b/docs/csharp/fundamentals/coding-style/snippets/identifier-names/identifier-names.csproj @@ -0,0 +1,13 @@ + + + + net9.0 + Exe + IdentifierNamingExamples + + + + + + + \ No newline at end of file diff --git a/docs/csharp/language-reference/compiler-messages/cs1061.md b/docs/csharp/language-reference/compiler-messages/cs1061.md index 9e50e2031189f..c76283a67fc5c 100644 --- a/docs/csharp/language-reference/compiler-messages/cs1061.md +++ b/docs/csharp/language-reference/compiler-messages/cs1061.md @@ -46,9 +46,10 @@ public class Program ## To correct this error -1. Make sure you typed the member name correctly. -2. If you have access to modify this class, you can add the missing member and implement it. -3. If you don't have access to modify this class, you can add an [extension method](../../programming-guide/classes-and-structs/extension-methods.md). +- Make sure you typed the member name correctly. +- If you have access to modify this class, you can add the missing member and implement it. +- If you don't have access to modify this class, you can add an [extension method](../../programming-guide/classes-and-structs/extension-methods.md). +- If the member you're trying to access should exist but doesn't, you might be missing a required NuGet package. Search [NuGet.org](https://www.nuget.org/) to find packages that contain the missing member. ## See also diff --git a/docs/csharp/programming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md b/docs/csharp/programming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md index cf2143ee8b7e3..058d6671edfac 100644 --- a/docs/csharp/programming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md +++ b/docs/csharp/programming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md @@ -13,7 +13,8 @@ ms.assetid: 4084581e-b931-498b-9534-cf7ef5b68690 --- # How to define value equality for a class or struct (C# Programming Guide) -[Records](../../fundamentals/types/records.md) automatically implement value equality. Consider defining a `record` instead of a `class` when your type models data and should implement value equality. +> [!TIP] +> **Consider using [records](../../fundamentals/types/records.md) first.** Records automatically implement value equality with minimal code, making them the recommended approach for most data-focused types. If you need custom value equality logic or cannot use records, continue with the manual implementation steps below. When you define a class or struct, you decide whether it makes sense to create a custom definition of value equality (or equivalence) for the type. Typically, you implement value equality when you expect to add objects of the type to a collection, or when their primary purpose is to store a set of fields or properties. You can base your definition of value equality on a comparison of all the fields and properties in the type, or you can base the definition on a subset. @@ -33,26 +34,39 @@ Any struct that you define already has a default implementation of value equalit The implementation details for value equality are different for classes and structs. However, both classes and structs require the same basic steps for implementing equality: -1. Override the [virtual](../../language-reference/keywords/virtual.md) method. In most cases, your implementation of `bool Equals( object obj )` should just call into the type-specific `Equals` method that is the implementation of the interface. (See step 2.) +1. **Override the [virtual](../../language-reference/keywords/virtual.md) method.** This provides polymorphic equality behavior, allowing your objects to be compared correctly when treated as `object` references. It ensures proper behavior in collections and when using polymorphism. In most cases, your implementation of `bool Equals( object obj )` should just call into the type-specific `Equals` method that is the implementation of the interface. (See step 2.) -2. Implement the interface by providing a type-specific `Equals` method. This is where the actual equivalence comparison is performed. For example, you might decide to define equality by comparing only one or two fields in your type. Don't throw exceptions from `Equals`. For classes that are related by inheritance: +2. **Implement the interface by providing a type-specific `Equals` method.** This provides type-safe equality checking without boxing, resulting in better performance. It also avoids unnecessary casting and enables compile-time type checking. This is where the actual equivalence comparison is performed. For example, you might decide to define equality by comparing only one or two fields in your type. Don't throw exceptions from `Equals`. For classes that are related by inheritance: * This method should examine only fields that are declared in the class. It should call `base.Equals` to examine fields that are in the base class. (Don't call `base.Equals` if the type inherits directly from , because the implementation of performs a reference equality check.) * Two variables should be deemed equal only if the run-time types of the variables being compared are the same. Also, make sure that the `IEquatable` implementation of the `Equals` method for the run-time type is used if the run-time and compile-time types of a variable are different. One strategy for making sure run-time types are always compared correctly is to implement `IEquatable` only in `sealed` classes. For more information, see the [class example](#class-example) later in this article. -3. Optional but recommended: Overload the [==](../../language-reference/operators/equality-operators.md#equality-operator-) and [!=](../../language-reference/operators/equality-operators.md#inequality-operator-) operators. +3. **Optional but recommended: Overload the [==](../../language-reference/operators/equality-operators.md#equality-operator-) and [!=](../../language-reference/operators/equality-operators.md#inequality-operator-) operators.** This provides consistent and intuitive syntax for equality comparisons, matching user expectations from built-in types. It ensures that `obj1 == obj2` and `obj1.Equals(obj2)` behave the same way. -4. Override so that two objects that have value equality produce the same hash code. +4. **Override so that two objects that have value equality produce the same hash code.** This is required for correct behavior in hash-based collections like `Dictionary` and `HashSet`. Objects that are equal must have equal hash codes, or these collections won't work correctly. -5. Optional: To support definitions for "greater than" or "less than," implement the interface for your type, and also overload the [<=](../../language-reference/operators/comparison-operators.md#less-than-or-equal-operator-) and [>=](../../language-reference/operators/comparison-operators.md#greater-than-or-equal-operator-) operators. +5. **Optional: To support definitions for "greater than" or "less than," implement the interface for your type, and also overload the [<=](../../language-reference/operators/comparison-operators.md#less-than-or-equal-operator-) and [>=](../../language-reference/operators/comparison-operators.md#greater-than-or-equal-operator-) operators.** This enables sorting operations and provides a complete ordering relationship for your type, useful when adding objects to sorted collections or when sorting arrays or lists. -> [!NOTE] -> You can use records to get value equality semantics without any unnecessary boilerplate code. +## Record example + +The following example shows how records automatically implement value equality with minimal code. The first record `TwoDPoint` is a simple record type that automatically implements value equality. The second record `ThreeDPoint` demonstrates that records can be derived from other records and still maintain proper value equality behavior: + +:::code language="csharp" source="snippets/how-to-define-value-equality-for-a-type/ValueEqualityRecord/Program.cs"::: + +Records provide several advantages for value equality: + +- **Automatic implementation**: Records automatically implement `IEquatable` and override `Equals(object?)`, `GetHashCode()`, and the `==`/`!=` operators. +- **Correct inheritance behavior**: Unlike the class example shown earlier, records handle inheritance scenarios correctly. +- **Immutability by default**: Records encourage immutable design, which works well with value equality semantics. +- **Concise syntax**: Positional parameters provide a compact way to define data types. +- **Better performance**: The compiler-generated equality implementation is optimized and doesn't use reflection like the default struct implementation. + +Use records when your primary goal is to store data and you need value equality semantics. ## Class example -The following example shows how to implement value equality in a class (reference type). +The following example shows how to implement value equality in a class (reference type). This manual approach is needed when you can't use records or need custom equality logic: :::code language="csharp" source="snippets/how-to-define-value-equality-for-a-type/ValueEqualityClass/Program.cs"::: @@ -75,11 +89,13 @@ The `==` and `!=` operators can be used with classes even if the class does not ## Struct example -The following example shows how to implement value equality in a struct (value type): +The following example shows how to implement value equality in a struct (value type). While structs have default value equality, a custom implementation can improve performance: :::code language="csharp" source="snippets/how-to-define-value-equality-for-a-type/ValueEqualityStruct/Program.cs"::: -For structs, the default implementation of (which is the overridden version in ) performs a value equality check by using reflection to compare the values of every field in the type. When an implementer overrides the virtual `Equals` method in a struct, the purpose is to provide a more efficient means of performing the value equality check and optionally to base the comparison on some subset of the struct's fields or properties. +For structs, the default implementation of (which is the overridden version in ) performs a value equality check by using reflection to compare the values of every field in the type. Although this implementation produces correct results, it is relatively slow compared to a custom implementation that you write specifically for the type. + +When you override the virtual `Equals` method in a struct, the purpose is to provide a more efficient means of performing the value equality check and optionally to base the comparison on some subset of the struct's fields or properties. The [==](../../language-reference/operators/equality-operators.md#equality-operator-) and [!=](../../language-reference/operators/equality-operators.md#inequality-operator-) operators can't operate on a struct unless the struct explicitly overloads them. diff --git a/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityRecord/Program.cs b/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityRecord/Program.cs new file mode 100644 index 0000000000000..f9041b9ce482d --- /dev/null +++ b/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityRecord/Program.cs @@ -0,0 +1,99 @@ +namespace ValueEqualityRecord; + +public record TwoDPoint(int X, int Y); + +public record ThreeDPoint(int X, int Y, int Z) : TwoDPoint(X, Y); + +class Program +{ + static void Main(string[] args) + { + // Create some points + TwoDPoint pointA = new TwoDPoint(3, 4); + TwoDPoint pointB = new TwoDPoint(3, 4); + TwoDPoint pointC = new TwoDPoint(5, 6); + + ThreeDPoint point3D_A = new ThreeDPoint(3, 4, 5); + ThreeDPoint point3D_B = new ThreeDPoint(3, 4, 5); + ThreeDPoint point3D_C = new ThreeDPoint(3, 4, 7); + + Console.WriteLine("=== Value Equality with Records ==="); + + // Value equality works automatically + Console.WriteLine($"pointA.Equals(pointB) = {pointA.Equals(pointB)}"); // True + Console.WriteLine($"pointA == pointB = {pointA == pointB}"); // True + Console.WriteLine($"pointA.Equals(pointC) = {pointA.Equals(pointC)}"); // False + Console.WriteLine($"pointA == pointC = {pointA == pointC}"); // False + + Console.WriteLine("\n=== Hash Codes ==="); + + // Equal objects have equal hash codes automatically + Console.WriteLine($"pointA.GetHashCode() = {pointA.GetHashCode()}"); + Console.WriteLine($"pointB.GetHashCode() = {pointB.GetHashCode()}"); + Console.WriteLine($"pointC.GetHashCode() = {pointC.GetHashCode()}"); + + Console.WriteLine("\n=== Inheritance with Records ==="); + + // Inheritance works correctly with value equality + Console.WriteLine($"point3D_A.Equals(point3D_B) = {point3D_A.Equals(point3D_B)}"); // True + Console.WriteLine($"point3D_A == point3D_B = {point3D_A == point3D_B}"); // True + Console.WriteLine($"point3D_A.Equals(point3D_C) = {point3D_A.Equals(point3D_C)}"); // False + + // Different types are not equal (unlike problematic class example) + Console.WriteLine($"pointA.Equals(point3D_A) = {pointA.Equals(point3D_A)}"); // False + + Console.WriteLine("\n=== Collections ==="); + + // Works seamlessly with collections + var pointSet = new HashSet { pointA, pointB, pointC }; + Console.WriteLine($"Set contains {pointSet.Count} unique points"); // 2 unique points + + var pointDict = new Dictionary + { + { pointA, "First point" }, + { pointC, "Different point" } + }; + + // Demonstrate that equivalent points work as the same key + var duplicatePoint = new TwoDPoint(3, 4); + Console.WriteLine($"Dictionary contains key for {duplicatePoint}: {pointDict.ContainsKey(duplicatePoint)}"); // True + Console.WriteLine($"Dictionary contains {pointDict.Count} entries"); // 2 entries + + Console.WriteLine("\n=== String Representation ==="); + + // Automatic ToString implementation + Console.WriteLine($"pointA.ToString() = {pointA}"); + Console.WriteLine($"point3D_A.ToString() = {point3D_A}"); + + Console.WriteLine("Press any key to exit."); + Console.ReadKey(); + } +} + +/* Expected Output: +=== Value Equality with Records === +pointA.Equals(pointB) = True +pointA == pointB = True +pointA.Equals(pointC) = False +pointA == pointC = False + +=== Hash Codes === +pointA.GetHashCode() = -1400834708 +pointB.GetHashCode() = -1400834708 +pointC.GetHashCode() = -148136000 + +=== Inheritance with Records === +point3D_A.Equals(point3D_B) = True +point3D_A == point3D_B = True +point3D_A.Equals(point3D_C) = False +pointA.Equals(point3D_A) = False + +=== Collections === +Set contains 2 unique points +Dictionary contains key for TwoDPoint { X = 3, Y = 4 }: True +Dictionary contains 2 entries + +=== String Representation === +pointA.ToString() = TwoDPoint { X = 3, Y = 4 } +point3D_A.ToString() = ThreeDPoint { X = 3, Y = 4, Z = 5 } +*/ \ No newline at end of file diff --git a/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityRecord/ValueEqualityRecord.csproj b/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityRecord/ValueEqualityRecord.csproj new file mode 100644 index 0000000000000..fd4dd4565750e --- /dev/null +++ b/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityRecord/ValueEqualityRecord.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + \ No newline at end of file diff --git a/docs/csharp/roslyn-sdk/tutorials/snippets/how-to-write-csharp-analyzer-code-fix/MakeConst/MakeConst.Test/MakeConst.Test.csproj b/docs/csharp/roslyn-sdk/tutorials/snippets/how-to-write-csharp-analyzer-code-fix/MakeConst/MakeConst.Test/MakeConst.Test.csproj index 01c05c7179397..ef37d5d3d7386 100644 --- a/docs/csharp/roslyn-sdk/tutorials/snippets/how-to-write-csharp-analyzer-code-fix/MakeConst/MakeConst.Test/MakeConst.Test.csproj +++ b/docs/csharp/roslyn-sdk/tutorials/snippets/how-to-write-csharp-analyzer-code-fix/MakeConst/MakeConst.Test/MakeConst.Test.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/docs/csharp/roslyn-sdk/tutorials/snippets/how-to-write-csharp-analyzer-code-fix/MakeConst/MakeConst.Vsix/MakeConst.Vsix.csproj b/docs/csharp/roslyn-sdk/tutorials/snippets/how-to-write-csharp-analyzer-code-fix/MakeConst/MakeConst.Vsix/MakeConst.Vsix.csproj index 71e00497ba8d6..7861ef1d1faa1 100644 --- a/docs/csharp/roslyn-sdk/tutorials/snippets/how-to-write-csharp-analyzer-code-fix/MakeConst/MakeConst.Vsix/MakeConst.Vsix.csproj +++ b/docs/csharp/roslyn-sdk/tutorials/snippets/how-to-write-csharp-analyzer-code-fix/MakeConst/MakeConst.Vsix/MakeConst.Vsix.csproj @@ -24,7 +24,7 @@ - + diff --git a/docs/fundamentals/apicompat/package-validation/baseline-version-validator.md b/docs/fundamentals/apicompat/package-validation/baseline-version-validator.md index 01c8a73c37f97..072b0867b0f7e 100644 --- a/docs/fundamentals/apicompat/package-validation/baseline-version-validator.md +++ b/docs/fundamentals/apicompat/package-validation/baseline-version-validator.md @@ -134,3 +134,6 @@ After you've released version 2.0.0 of the package, you can delete the *Compatib ``` + +> [!TIP] +> Instead of deleting the *CompatibilitySuppressions.xml* file, you can also consider setting properties such as [ApiCompatPreserveUnnecessarySuppressions](../../../core/project-sdk/msbuild-props.md#apicompatpreserveunnecessarysuppressions). diff --git a/docs/fundamentals/apicompat/package-validation/overview.md b/docs/fundamentals/apicompat/package-validation/overview.md index 5a9db3e4e7154..4f7b41eb9c0a9 100644 --- a/docs/fundamentals/apicompat/package-validation/overview.md +++ b/docs/fundamentals/apicompat/package-validation/overview.md @@ -43,3 +43,7 @@ There are three different validators that verify your package as part of the `Pa ## Suppress compatibility warnings For information about suppressing compatibility warnings, see [How to suppress](../diagnostic-ids.md#how-to-suppress). + +## See also + +- [Package validation properties](../../../core/project-sdk/msbuild-props.md#package-validation-properties) diff --git a/docs/fundamentals/code-analysis/style-rules/ide2000.md b/docs/fundamentals/code-analysis/style-rules/ide2000.md new file mode 100644 index 0000000000000..ab686af3430a2 --- /dev/null +++ b/docs/fundamentals/code-analysis/style-rules/ide2000.md @@ -0,0 +1,97 @@ +--- +title: "IDE2000: Avoid multiple blank lines" +description: "Learn about code analysis rule IDE2000: Avoid multiple blank lines" +ms.date: 08/19/2025 +f1_keywords: +- IDE2000 +helpviewer_keywords: +- IDE2000 +dev_langs: +- CSharp +ai-usage: ai-assisted +--- +# Avoid multiple blank lines (IDE2000) + +| Property | Value | +|--------------------------|--------------------------------------------------------| +| **Rule ID** | IDE2000 | +| **Title** | Avoid multiple blank lines | +| **Category** | Style | +| **Subcategory** | Language rules (new-line preferences) | +| **Applicable languages** | C# and Visual Basic | +| **Options** | `dotnet_style_allow_multiple_blank_lines_experimental` | + +> [!NOTE] +> This rule is experimental and subject to change or removal. + +## Overview + +This style rule flags the presence of multiple consecutive blank lines in source code. Having multiple blank lines can reduce code readability and is generally considered poor formatting practice. + +## Options + +Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format). + +### dotnet_style_allow_multiple_blank_lines_experimental + +| Property | Value | Description | +|--------------------------|--------------------------------------------------------|-------------| +| **Option name** | `dotnet_style_allow_multiple_blank_lines_experimental` | | +| **Option values** | `true` | Allow multiple consecutive blank lines | +| | `false` | Don't allow consecutive blank lines | +| **Default option value** | `true` | | + +## Example + +```csharp +// dotnet_style_allow_multiple_blank_lines_experimental = true +if (true) +{ + DoWork(); +} + + +return; +``` + +```csharp +// dotnet_style_allow_multiple_blank_lines_experimental = false +if (true) +{ + DoWork(); +} + +return; +``` + +## Suppress a warning + +If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable IDE2000 +// The code that's violating the rule is on this line. +#pragma warning restore IDE2000 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.IDE2000.severity = none +``` + +To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_analyzer_diagnostic.category-style.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../suppress-warnings.md). + +## See also + +- [New-line preferences](language-rules.md#new-line-preferences) +- [Code style language rules](language-rules.md) +- [Code style rules reference](index.md) diff --git a/docs/fundamentals/code-analysis/style-rules/ide2001.md b/docs/fundamentals/code-analysis/style-rules/ide2001.md new file mode 100644 index 0000000000000..ba499fade3ec3 --- /dev/null +++ b/docs/fundamentals/code-analysis/style-rules/ide2001.md @@ -0,0 +1,88 @@ +--- +title: "IDE2001: Embedded statements must be on their own line" +description: "Learn about code analysis rule IDE2001: Embedded statements must be on their own line" +ms.date: 08/19/2025 +f1_keywords: +- IDE2001 +helpviewer_keywords: +- IDE2001 +dev_langs: +- CSharp +- VB +ai-usage: ai-assisted +--- +# Embedded statements must be on their own line (IDE2001) + +| Property | Value | +|--------------------------|--------------------------------------------------------------------| +| **Rule ID** | IDE2001 | +| **Title** | Embedded statements must be on their own line | +| **Category** | Style | +| **Subcategory** | Language rules (new-line preferences) | +| **Applicable languages** | C# | +| **Options** | `csharp_style_allow_embedded_statements_on_same_line_experimental` | + +> [!NOTE] +> This rule is experimental and subject to change or removal. + +## Overview + +This style rule enforces that embedded statements (statements that are part of control flow constructs like `if`, `while`, and `for`) must be placed on their own line rather than on the same line as the control keyword. + +## Options + +Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format). + +### csharp_style_allow_embedded_statements_on_same_line_experimental + +| Property | Value | Description | +|--------------------------|----------------------------------------------|-------------| +| **Option name** | `csharp_style_allow_embedded_statements_on_same_line_experimental` | | +| **Option values** | `true` | Allow embedded statements on same line as control keyword | +| | `false` | Require embedded statements to be on their own line | +| **Default option value** | `true` | | + +## Example + +```csharp +// csharp_style_allow_embedded_statements_on_same_line_experimental = true +for (int i = 0; i < 10; i++) Console.WriteLine(i); +``` + +```csharp +// csharp_style_allow_embedded_statements_on_same_line_experimental = false +for (int i = 0; i < 10; i++) + Console.WriteLine(i); +``` + +## Suppress a warning + +If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable IDE2001 +// The code that's violating the rule is on this line. +#pragma warning restore IDE2001 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.IDE2001.severity = none +``` + +To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_analyzer_diagnostic.category-style.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../suppress-warnings.md). + +## See also + +- [New-line preferences](language-rules.md#new-line-preferences) +- [Code style language rules](language-rules.md) +- [Code style rules reference](index.md) diff --git a/docs/fundamentals/code-analysis/style-rules/ide2002.md b/docs/fundamentals/code-analysis/style-rules/ide2002.md new file mode 100644 index 0000000000000..a07d50712885a --- /dev/null +++ b/docs/fundamentals/code-analysis/style-rules/ide2002.md @@ -0,0 +1,99 @@ +--- +title: "IDE2002: Consecutive braces must not have blank line between them" +description: "Learn about code analysis rule IDE2002: Consecutive braces must not have blank line between them" +ms.date: 08/19/2025 +f1_keywords: +- IDE2002 +helpviewer_keywords: +- IDE2002 +dev_langs: +- CSharp +ai-usage: ai-assisted +--- +# Consecutive braces must not have blank line between them (IDE2002) + +| Property | Value | +|--------------------------|--------------------------------------------------------------------------| +| **Rule ID** | IDE2002 | +| **Title** | Consecutive braces must not have blank line between them | +| **Category** | Style | +| **Subcategory** | Language rules (new-line preferences) | +| **Applicable languages** | C# | +| **Options** | `csharp_style_allow_blank_lines_between_consecutive_braces_experimental` | + +> [!NOTE] +> This rule is experimental and subject to change or removal. + +## Overview + +This style rule enforces that consecutive braces should not have blank lines between them. This helps maintain consistent and clean code formatting. + +## Options + +Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format). + +### csharp_style_allow_blank_lines_between_consecutive_braces_experimental + +| Property | Value | Description | +|--------------------------|----------------------------------------------|-------------| +| **Option name** | `csharp_style_allow_blank_lines_between_consecutive_braces_experimental` | | +| **Option values** | `true` | Allow blank lines between consecutive braces | +| | `false` | Don't allow blank lines between consecutive braces | +| **Default option value** | `true` | | + +## Example + +```csharp +// csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true +public void Method +{ + if (true) + { + DoWork(); + } + +} +``` + +```csharp +// csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false +public void Method +{ + if (true) + { + DoWork(); + } +} +``` + +## Suppress a warning + +If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable IDE2002 +// The code that's violating the rule is on this line. +#pragma warning restore IDE2002 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.IDE2002.severity = none +``` + +To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_analyzer_diagnostic.category-style.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../suppress-warnings.md). + +## See also + +- [New-line preferences](language-rules.md#new-line-preferences) +- [Code style language rules](language-rules.md) +- [Code style rules reference](index.md) diff --git a/docs/fundamentals/code-analysis/style-rules/ide2003.md b/docs/fundamentals/code-analysis/style-rules/ide2003.md new file mode 100644 index 0000000000000..8b47b66366d05 --- /dev/null +++ b/docs/fundamentals/code-analysis/style-rules/ide2003.md @@ -0,0 +1,95 @@ +--- +title: "IDE2003: Blank line required between block and subsequent statement" +description: "Learn about code analysis rule IDE2003: Blank line required between block and subsequent statement" +ms.date: 08/19/2025 +f1_keywords: +- IDE2003 +helpviewer_keywords: +- IDE2003 +dev_langs: +- CSharp +ai-usage: ai-assisted +--- +# Blank line required between block and subsequent statement (IDE2003) + +| Property | Value | +|--------------------------|---------------------------------------------------------------------| +| **Rule ID** | IDE2003 | +| **Title** | Blank line required between block and subsequent statement | +| **Category** | Style | +| **Subcategory** | Language rules (new-line preferences) | +| **Applicable languages** | C# and Visual Basic | +| **Options** | `dotnet_style_allow_statement_immediately_after_block_experimental` | + +> [!NOTE] +> This rule is experimental and subject to change or removal. + +## Overview + +This style rule enforces that there should be a blank line between a block statement and any subsequent statement at the same scope level. This improves code readability by visually separating different logical sections of code. + +## Options + +Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format). + +### dotnet_style_allow_statement_immediately_after_block_experimental + +| Property | Value | Description | +|--------------------------|----------------------------------------------|-------------| +| **Option name** | `dotnet_style_allow_statement_immediately_after_block_experimental` | | +| **Option values** | `true` | Allow subsequent statement to immediately follow block statement without a blank line in between | +| | `false` | Require a blank line between a block statement and the subsequent statement | +| **Default option value** | `true` | | + +## Example + +```csharp +// dotnet_style_allow_statement_immediately_after_block_experimental = true +if (true) +{ + DoWork(); +} +return; +``` + +```csharp +// dotnet_style_allow_statement_immediately_after_block_experimental = false +if (true) +{ + DoWork(); +} + +return; +``` + +## Suppress a warning + +If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable IDE2003 +// The code that's violating the rule is on this line. +#pragma warning restore IDE2003 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.IDE2003.severity = none +``` + +To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_analyzer_diagnostic.category-style.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../suppress-warnings.md). + +## See also + +- [New-line preferences](language-rules.md#new-line-preferences) +- [Code style language rules](language-rules.md) +- [Code style rules reference](index.md) diff --git a/docs/fundamentals/code-analysis/style-rules/ide2004.md b/docs/fundamentals/code-analysis/style-rules/ide2004.md new file mode 100644 index 0000000000000..bed66532ab851 --- /dev/null +++ b/docs/fundamentals/code-analysis/style-rules/ide2004.md @@ -0,0 +1,92 @@ +--- +title: "IDE2004: Blank line not allowed after constructor initializer colon" +description: "Learn about code analysis rule IDE2004: Blank line not allowed after constructor initializer colon" +ms.date: 08/19/2025 +f1_keywords: +- IDE2004 +helpviewer_keywords: +- IDE2004 +dev_langs: +- CSharp +ai-usage: ai-assisted +--- +# Blank line not allowed after constructor initializer colon (IDE2004) + +| Property | Value | +|--------------------------|------------------------------------------------------------| +| **Rule ID** | IDE2004 | +| **Title** | Blank line not allowed after constructor initializer colon | +| **Category** | Style | +| **Subcategory** | Language rules (new-line preferences) | +| **Applicable languages** | C# | +| **Options** | `csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental` | + +> [!NOTE] +> This rule is experimental and subject to change or removal. + +## Overview + +This style rule enforces that there should not be a blank line after the colon (`:`) in a constructor initializer. The `base()` or `this()` call should immediately follow the colon without any blank lines in between. + +## Options + +Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format). + +### csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental + +| Property | Value | Description | +|--------------------------|----------------------------------------------|-------------| +| **Option name** | `csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental` | | +| **Option values** | `true` | Allow a blank line after the colon in a constructor initializer | +| | `false` | Don't allow blank line after colon in constructor initializer | +| **Default option value** | `true` | | + +## Example + +```csharp +// csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +public Class() : + base() +{ +} +``` + +```csharp +// csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false +public Class() + : base() +{ +} +``` + +## Suppress a warning + +If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable IDE2004 +// The code that's violating the rule is on this line. +#pragma warning restore IDE2004 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.IDE2004.severity = none +``` + +To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_analyzer_diagnostic.category-style.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../suppress-warnings.md). + +## See also + +- [New-line preferences](language-rules.md#new-line-preferences) +- [Code style language rules](language-rules.md) +- [Code style rules reference](index.md) diff --git a/docs/fundamentals/code-analysis/style-rules/ide2005.md b/docs/fundamentals/code-analysis/style-rules/ide2005.md new file mode 100644 index 0000000000000..f80d973e6d10f --- /dev/null +++ b/docs/fundamentals/code-analysis/style-rules/ide2005.md @@ -0,0 +1,90 @@ +--- +title: "IDE2005: Blank line not allowed after conditional expression token" +description: "Learn about code analysis rule IDE2005: Blank line not allowed after conditional expression token" +ms.date: 08/19/2025 +f1_keywords: +- IDE2005 +helpviewer_keywords: +- IDE2005 +dev_langs: +- CSharp +ai-usage: ai-assisted +--- +# Blank line not allowed after conditional expression token (IDE2005) + +| Property | Value | +|--------------------------|-----------------------------------------------------------| +| **Rule ID** | IDE2005 | +| **Title** | Blank line not allowed after conditional expression token | +| **Category** | Style | +| **Subcategory** | Language rules (new-line preferences) | +| **Applicable languages** | C# | +| **Options** | `csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental` | + +> [!NOTE] +> This rule is experimental and subject to change or removal. + +## Overview + +This style rule enforces that there should not be a blank line after the question mark (`?`) or colon (`:`) tokens in conditional (ternary) expressions. These operators should be immediately followed by their respective expressions without blank lines. + +## Options + +Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format). + +### csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental + +| Property | Value | Description | +|--------------------------|----------------------------------------------|-------------| +| **Option name** | `csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental` | | +| **Option values** | `true` | Allow a blank line after the token in a conditional expression | +| | `false` | Require statement to immediately follow token in a conditional expression | +| **Default option value** | `true` | | + +## Example + +```csharp +// csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true +int result = IsTrue ? + ComplexExpr1() : + ComplexExpr2(); +``` + +```csharp +// csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false +int result = IsTrue + ? ComplexExpr1() + : ComplexExpr2(); +``` + +## Suppress a warning + +If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable IDE2005 +// The code that's violating the rule is on this line. +#pragma warning restore IDE2005 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.IDE2005.severity = none +``` + +To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_analyzer_diagnostic.category-style.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../suppress-warnings.md). + +## See also + +- [New-line preferences](language-rules.md#new-line-preferences) +- [Code style language rules](language-rules.md) +- [Code style rules reference](index.md) diff --git a/docs/fundamentals/code-analysis/style-rules/ide2006.md b/docs/fundamentals/code-analysis/style-rules/ide2006.md new file mode 100644 index 0000000000000..34c6f82644cc6 --- /dev/null +++ b/docs/fundamentals/code-analysis/style-rules/ide2006.md @@ -0,0 +1,88 @@ +--- +title: "IDE2006: Blank line not allowed after arrow expression clause token" +description: "Learn about code analysis rule IDE2006: Blank line not allowed after arrow expression clause token" +ms.date: 08/19/2025 +f1_keywords: +- IDE2006 +helpviewer_keywords: +- IDE2006 +dev_langs: +- CSharp +ai-usage: ai-assisted +--- +# Blank line not allowed after arrow expression clause token (IDE2006) + +| Property | Value | +|--------------------------|------------------------------------------------------------| +| **Rule ID** | IDE2006 | +| **Title** | Blank line not allowed after arrow expression clause token | +| **Category** | Style | +| **Subcategory** | Language rules (new-line preferences) | +| **Applicable languages** | C# | +| **Options** | `csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental` | + +> [!NOTE] +> This rule is experimental and subject to change or removal. + +## Overview + +This style rule enforces that there should not be blank lines after the arrow (`=>`) token in expression-bodied members, lambda expressions, or switch expressions. The expression should immediately follow the arrow without any blank lines. + +## Options + +Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format). + +### csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental + +| Property | Value | Description | +|--------------------------|------------------------------|-------------| +| **Option name** | `csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental` | | +| **Option values** | `true` | Allow a blank line after the token in an arrow expression clause | +| | `false` | Require expression to immediately follow token in an arrow expression clause | +| **Default option value** | `true` | | + +## Example + +```csharp +// csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true +public int Method() => + 9 + 1; +``` + +```csharp +// csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false +public int Method() + => 9 + 1; +``` + +## Suppress a warning + +If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable IDE2006 +// The code that's violating the rule is on this line. +#pragma warning restore IDE2006 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.IDE2006.severity = none +``` + +To disable all of the code-style rules, set the severity for the category `Style` to `none` in the [configuration file](../configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_analyzer_diagnostic.category-style.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../suppress-warnings.md). + +## See also + +- [New-line preferences](language-rules.md#new-line-preferences) +- [Code style language rules](language-rules.md) +- [Code style rules reference](index.md) diff --git a/docs/fundamentals/code-analysis/style-rules/index.md b/docs/fundamentals/code-analysis/style-rules/index.md index 6216dece4ddfa..fec923289f122 100644 --- a/docs/fundamentals/code-analysis/style-rules/index.md +++ b/docs/fundamentals/code-analysis/style-rules/index.md @@ -148,8 +148,17 @@ The following table list all the code-style rules by ID and [options](../code-st > | [IDE0350](ide0350.md) | Use implicitly typed lambda | [csharp_style_prefer_implicitly_typed_lambda_expression](ide0350.md#csharp_style_prefer_implicitly_typed_lambda_expression) | > | [IDE1005](ide1005.md) | Use conditional delegate call | [csharp_style_conditional_delegate_call](ide1005.md#csharp_style_conditional_delegate_call) | > | [IDE1006](naming-rules.md) | Naming styles | | +> | [IDE2000](ide2000.md) | Avoid multiple blank lines | [dotnet_style_allow_multiple_blank_lines_experimental](ide2000.md#dotnet_style_allow_multiple_blank_lines_experimental)† | +> | [IDE2001](ide2001.md) | Embedded statements must be on their own line | [csharp_style_allow_embedded_statements_on_same_line_experimental](ide2001.md#csharp_style_allow_embedded_statements_on_same_line_experimental)† | +> | [IDE2002](ide2002.md) | Consecutive braces must not have blank line between them | [csharp_style_allow_blank_lines_between_consecutive_braces_experimental](ide2002.md#csharp_style_allow_blank_lines_between_consecutive_braces_experimental)† | +> | [IDE2003](ide2003.md) | Blank line required between block and subsequent statement | [dotnet_style_allow_statement_immediately_after_block_experimental](ide2003.md#dotnet_style_allow_statement_immediately_after_block_experimental)† | +> | [IDE2004](ide2004.md) | Blank line not allowed after constructor initializer colon | [csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental](ide2004.md#csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental)† | +> | [IDE2005](ide2005.md) | Blank line not allowed after conditional expression token | [csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental](ide2005.md#csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental)† | +> | [IDE2006](ide2006.md) | Blank line not allowed after arrow expression clause token | [csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental](ide2006.md#csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental)† | > | [IDE3000](ide3000.md) | Implement with Copilot | | +†These rules are experimental and subject to change or removal. + > [!NOTE] > There are some rules that only surface in the Visual Studio IDE, and these regard JSON and regular expression pattern strings. For more information, see [JSON001](/visualstudio/ide/reference/json001), [JSON002](/visualstudio/ide/reference/json002), and [RE0001](/visualstudio/ide/reference/re0001). diff --git a/docs/fundamentals/code-analysis/style-rules/language-rules.md b/docs/fundamentals/code-analysis/style-rules/language-rules.md index 6fed9722133a1..5aca6f4db12ca 100644 --- a/docs/fundamentals/code-analysis/style-rules/language-rules.md +++ b/docs/fundamentals/code-analysis/style-rules/language-rules.md @@ -208,13 +208,20 @@ C# style rules: ### New-line preferences -- Allow multiple blank lines (IDE2000) -- Allow embedded statements on same line (IDE2001) -- Allow blank lines between consecutive braces (IDE2002) -- Allow statement immediately after block (IDE2003) -- Allow blank line after colon in constructor initializer (IDE2004) -- Allow blank line after token in conditional expression (IDE2005) -- Allow blank line after token in arrow expression (IDE2006) +.NET style rules (C# and Visual Basic): + +- [Avoid multiple blank lines (IDE2000)](ide2000.md)† +- [Blank line required between block and subsequent statement (IDE2003)](ide2003.md)† + +C# style rules: + +- [Embedded statements must be on their own line (IDE2001)](ide2001.md)† +- [Consecutive braces must not have blank line between them (IDE2002)](ide2002.md)† +- [Blank line not allowed after constructor initializer colon (IDE2004)](ide2004.md)† +- [Blank line not allowed after conditional expression token (IDE2005)](ide2005.md)† +- [Blank line not allowed after arrow expression clause token (IDE2006)](ide2006.md)† + +†These rules are experimental and subject to change or removal. ### Null-checking preferences diff --git a/docs/navigate/tools-diagnostics/toc.yml b/docs/navigate/tools-diagnostics/toc.yml index 9bf569ad7a258..d5aaac67663a8 100644 --- a/docs/navigate/tools-diagnostics/toc.yml +++ b/docs/navigate/tools-diagnostics/toc.yml @@ -2192,6 +2192,20 @@ items: href: ../../fundamentals/code-analysis/style-rules/ide0350.md - name: IDE1005 href: ../../fundamentals/code-analysis/style-rules/ide1005.md + - name: IDE2000 + href: ../../fundamentals/code-analysis/style-rules/ide2000.md + - name: IDE2001 + href: ../../fundamentals/code-analysis/style-rules/ide2001.md + - name: IDE2002 + href: ../../fundamentals/code-analysis/style-rules/ide2002.md + - name: IDE2003 + href: ../../fundamentals/code-analysis/style-rules/ide2003.md + - name: IDE2004 + href: ../../fundamentals/code-analysis/style-rules/ide2004.md + - name: IDE2005 + href: ../../fundamentals/code-analysis/style-rules/ide2005.md + - name: IDE2006 + href: ../../fundamentals/code-analysis/style-rules/ide2006.md - name: Miscellaneous rules items: - name: Overview diff --git a/samples/snippets/core/testing/unit-testing-best-practices/csharp/after/unit-testing-best-practices-after.csproj b/samples/snippets/core/testing/unit-testing-best-practices/csharp/after/unit-testing-best-practices-after.csproj index ced2c3ddd2f1a..43aefd5c2694e 100644 --- a/samples/snippets/core/testing/unit-testing-best-practices/csharp/after/unit-testing-best-practices-after.csproj +++ b/samples/snippets/core/testing/unit-testing-best-practices/csharp/after/unit-testing-best-practices-after.csproj @@ -10,7 +10,7 @@ - + diff --git a/samples/snippets/core/testing/unit-testing-best-practices/csharp/before/unit-testing-best-practices-before.csproj b/samples/snippets/core/testing/unit-testing-best-practices/csharp/before/unit-testing-best-practices-before.csproj index ced2c3ddd2f1a..43aefd5c2694e 100644 --- a/samples/snippets/core/testing/unit-testing-best-practices/csharp/before/unit-testing-best-practices-before.csproj +++ b/samples/snippets/core/testing/unit-testing-best-practices/csharp/before/unit-testing-best-practices-before.csproj @@ -10,7 +10,7 @@ - + diff --git a/samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService.Tests.csproj b/samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService.Tests.csproj index 16beed063089d..b3a13fc4e5cb4 100644 --- a/samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService.Tests.csproj +++ b/samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService.Tests.csproj @@ -9,7 +9,7 @@ - +