diff --git a/.github/policies/request-review.yml b/.github/policies/request-review.yml deleted file mode 100644 index 4077bab9e4587..0000000000000 --- a/.github/policies/request-review.yml +++ /dev/null @@ -1,26 +0,0 @@ -id: -name: GitOps.PullRequestIssueManagement -description: GitOps.PullRequestIssueManagement primitive -owner: -resource: repository -disabled: false -where: -configuration: - resourceManagementConfiguration: - eventResponderTasks: - - description: (Test policy) Request review for code analysis files. - if: - - payloadType: Pull_Request - - isAction: - action: Opened - - filesMatchPattern: - pattern: docs/fundamentals/code-analysis/* - matchAny: true - then: - - mentionUsers: - mentionees: - - diberry - replyTemplate: "Mentioning as a test: ${mentionees}" - assignMentionees: true - - requestReview: - reviewer: BillWagner diff --git a/.openpublishing.redirection.csharp.json b/.openpublishing.redirection.csharp.json index e77151c721d41..e1ac81e6e7225 100644 --- a/.openpublishing.redirection.csharp.json +++ b/.openpublishing.redirection.csharp.json @@ -4052,6 +4052,10 @@ "source_path_from_root": "/docs/csharp/roslyn/index.md", "redirect_url": "/dotnet/csharp/roslyn-sdk/" }, + { + "source_path_from_root": "/docs/csharp/roslyn-sdk/source-generators-overview.md", + "redirect_url": "/dotnet/csharp/roslyn-sdk/#source-generators" + }, { "source_path_from_root": "/docs/csharp/whats-new/tutorials/static-abstract-interface-methods.md", "redirect_url": "/dotnet/csharp/whats-new/tutorials/static-virtual-interface-members" diff --git a/docs/architecture/maui/mvvm-community-toolkit-features.md b/docs/architecture/maui/mvvm-community-toolkit-features.md index f308e8deba49f..0431160aa614c 100644 --- a/docs/architecture/maui/mvvm-community-toolkit-features.md +++ b/docs/architecture/maui/mvvm-community-toolkit-features.md @@ -115,7 +115,7 @@ For more detailed information on implementing commands, see the section [Impleme ## Source Generators -Using the MVVM Toolkit components out-of-the-box allows you to greatly simplify our ViewModel. The MVVM Toolkit allows you to simplify common code use cases even further by using [Source Generators](../../csharp/roslyn-sdk/source-generators-overview.md). The MVVM Toolkit source generators look for specific attributes in our code and can generate wrappers for properties and commands. +Using the MVVM Toolkit components out-of-the-box allows you to greatly simplify our ViewModel. The MVVM Toolkit allows you to simplify common code use cases even further by using [Source Generators](../../csharp/roslyn-sdk/index.md#source-generators). The MVVM Toolkit source generators look for specific attributes in our code and can generate wrappers for properties and commands. > [!IMPORTANT] > The MVVM Toolkit Source Generators generate code that is additive to our existing objects. Because of this, any object that is leveraging a source generator will need to be marked as `partial`. diff --git a/docs/azure/includes/dotnet-all.md b/docs/azure/includes/dotnet-all.md index 6ef424862700e..a258f856dac71 100644 --- a/docs/azure/includes/dotnet-all.md +++ b/docs/azure/includes/dotnet-all.md @@ -1,9 +1,9 @@ | Name | Package | Docs | Source | | ---- | ------- | ---- | ------ | -| AI Model Inference | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.AI.Inference/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/AI.Inference-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Inference_1.0.0-beta.1/sdk/ai/Azure.AI.Inference/) | +| AI Model Inference | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.AI.Inference/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/AI.Inference-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.Inference_1.0.0-beta.2/sdk/ai/Azure.AI.Inference/) | | Anomaly Detector | NuGet [3.0.0-preview.7](https://www.nuget.org/packages/Azure.AI.AnomalyDetector/3.0.0-preview.7) | [docs](/dotnet/api/overview/azure/AI.AnomalyDetector-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [3.0.0-preview.7](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.AnomalyDetector_3.0.0-preview.7/sdk/anomalydetector/Azure.AI.AnomalyDetector/) | | App Configuration | NuGet [1.5.0](https://www.nuget.org/packages/Azure.Data.AppConfiguration/1.5.0) | [docs](/dotnet/api/overview/azure/Data.AppConfiguration-readme) | GitHub [1.5.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.AppConfiguration_1.5.0/sdk/appconfiguration/Azure.Data.AppConfiguration/) | -| App Configuration Provider | NuGet [8.0.0](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.AzureAppConfiguration/8.0.0) | | GitHub [8.0.0](https://github.com/Azure/AppConfiguration-DotnetProvider) | +| App Configuration Provider | NuGet [8.0.0](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.AzureAppConfiguration/8.0.0)
NuGet [8.1.0-preview](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.AzureAppConfiguration/8.1.0-preview) | | GitHub [8.0.0](https://github.com/Azure/AppConfiguration-DotnetProvider) | | Attestation | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Security.Attestation/1.0.0) | [docs](/dotnet/api/overview/azure/Security.Attestation-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.Attestation_1.0.0/sdk/attestation/Azure.Security.Attestation/) | | Azure AI Search | NuGet [11.6.0](https://www.nuget.org/packages/Azure.Search.Documents/11.6.0)
NuGet [11.7.0-beta.1](https://www.nuget.org/packages/Azure.Search.Documents/11.7.0-beta.1) | [docs](/dotnet/api/overview/azure/Search.Documents-readme) | GitHub [11.6.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Search.Documents_11.6.0/sdk/search/Azure.Search.Documents/)
GitHub [11.7.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Search.Documents_11.7.0-beta.1/sdk/search/Azure.Search.Documents/) | | Azure Object Anchors Conversion | NuGet [0.3.0-beta.6](https://www.nuget.org/packages/Azure.MixedReality.ObjectAnchors.Conversion/0.3.0-beta.6) | [docs](/dotnet/api/overview/azure/MixedReality.ObjectAnchors.Conversion-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [0.3.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.ObjectAnchors.Conversion_0.3.0-beta.6/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/) | @@ -51,9 +51,9 @@ | Health Insights Cancer Profiling | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Health.Insights.CancerProfiling/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Health.Insights.CancerProfiling-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Health.Insights.CancerProfiling_1.0.0-beta.1/sdk/healthinsights/Azure.Health.Insights.CancerProfiling/) | | Health Insights Clinical Matching | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Health.Insights.ClinicalMatching/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Health.Insights.ClinicalMatching-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Health.Insights.ClinicalMatching_1.0.0-beta.1/sdk/healthinsights/Azure.Health.Insights.ClinicalMatching/) | | Health Insights Radiology Insights | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Health.Insights.RadiologyInsights/1.0.0) | [docs](/dotnet/api/overview/azure/Health.Insights.RadiologyInsights-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Health.Insights.RadiologyInsights_1.0.0/sdk/healthinsights/Azure.Health.Insights.RadiologyInsights/) | -| Identity | NuGet [1.13.0](https://www.nuget.org/packages/Azure.Identity/1.13.0) | [docs](/dotnet/api/overview/azure/Identity-readme) | GitHub [1.13.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity_1.13.0/sdk/identity/Azure.Identity/) | +| Identity | NuGet [1.13.1](https://www.nuget.org/packages/Azure.Identity/1.13.1) | [docs](/dotnet/api/overview/azure/Identity-readme) | GitHub [1.13.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity_1.13.1/sdk/identity/Azure.Identity/) | | Identity Broker | NuGet [1.1.0](https://www.nuget.org/packages/Azure.Identity.Broker/1.1.0)
NuGet [1.2.0-beta.1](https://www.nuget.org/packages/Azure.Identity.Broker/1.2.0-beta.1) | [docs](/dotnet/api/overview/azure/Identity.Broker-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity.Broker_1.1.0/sdk/identity/Azure.Identity.Broker/)
GitHub [1.2.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity.Broker_1.2.0-beta.1/sdk/identity/Azure.Identity.Broker/) | -| Image Analysis | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.AI.Vision.ImageAnalysis/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.Vision.ImageAnalysis-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Vision.ImageAnalysis_1.0.0-beta.3/sdk/vision/Azure.AI.Vision.ImageAnalysis/) | +| Image Analysis | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.Vision.ImageAnalysis/1.0.0) | [docs](/dotnet/api/overview/azure/AI.Vision.ImageAnalysis-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Vision.ImageAnalysis_1.0.0/sdk/vision/Azure.AI.Vision.ImageAnalysis/) | | Key Vault - Administration | NuGet [4.5.0](https://www.nuget.org/packages/Azure.Security.KeyVault.Administration/4.5.0) | [docs](/dotnet/api/overview/azure/Security.KeyVault.Administration-readme) | GitHub [4.5.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.KeyVault.Administration_4.5.0/sdk/keyvault/Azure.Security.KeyVault.Administration/) | | Key Vault - Certificates | NuGet [4.7.0](https://www.nuget.org/packages/Azure.Security.KeyVault.Certificates/4.7.0) | [docs](/dotnet/api/overview/azure/Security.KeyVault.Certificates-readme) | GitHub [4.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.KeyVault.Certificates_4.7.0/sdk/keyvault/Azure.Security.KeyVault.Certificates/) | | Key Vault - Keys | NuGet [4.7.0](https://www.nuget.org/packages/Azure.Security.KeyVault.Keys/4.7.0) | [docs](/dotnet/api/overview/azure/Security.KeyVault.Keys-readme) | GitHub [4.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.KeyVault.Keys_4.7.0/sdk/keyvault/Azure.Security.KeyVault.Keys/) | @@ -351,8 +351,8 @@ | Resource Management - Web PubSub | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.WebPubSub/1.1.0)
NuGet [1.2.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.WebPubSub/1.2.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.WebPubSub-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.WebPubSub_1.1.0/sdk/webpubsub/Azure.ResourceManager.WebPubSub/)
GitHub [1.2.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.WebPubSub_1.2.0-beta.2/sdk/webpubsub/Azure.ResourceManager.WebPubSub/) | | Resource Management - Workload Monitor | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.WorkloadMonitor/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.WorkloadMonitor-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.WorkloadMonitor_1.0.0-beta.4/sdk/workloadmonitor/Azure.ResourceManager.WorkloadMonitor/) | | Resource Management - Workloads | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.Workloads/1.1.0)
NuGet [1.2.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Workloads/1.2.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Workloads-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Workloads_1.1.0/sdk/workloads/Azure.ResourceManager.Workloads/)
GitHub [1.2.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Workloads_1.2.0-beta.1/sdk/workloads/Azure.ResourceManager.Workloads/) | -| App Configuration Extension | NuGet [8.0.0](https://www.nuget.org/packages/Microsoft.Azure.AppConfiguration.Functions.Worker/8.0.0) | | | -| App Configuration Provider | NuGet [8.0.0](https://www.nuget.org/packages/Microsoft.Azure.AppConfiguration.AspNetCore/8.0.0) | | | +| App Configuration Extension | NuGet [8.0.0](https://www.nuget.org/packages/Microsoft.Azure.AppConfiguration.Functions.Worker/8.0.0)
NuGet [8.1.0-preview](https://www.nuget.org/packages/Microsoft.Azure.AppConfiguration.Functions.Worker/8.1.0-preview) | | | +| App Configuration Provider | NuGet [8.0.0](https://www.nuget.org/packages/Microsoft.Azure.AppConfiguration.AspNetCore/8.0.0)
NuGet [8.1.0-preview](https://www.nuget.org/packages/Microsoft.Azure.AppConfiguration.AspNetCore/8.1.0-preview) | | | | Azure.Communication.Administration | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Communication.Administration/1.0.0-beta.3) | | | | Communication Calling Windows Client | NuGet [1.9.0](https://www.nuget.org/packages/Azure.Communication.Calling.WindowsClient/1.9.0)
NuGet [1.10.0-beta.1](https://www.nuget.org/packages/Azure.Communication.Calling.WindowsClient/1.10.0-beta.1) | | | | DotNetty | NuGet [0.7.6](https://www.nuget.org/packages/DotNetty.Common/0.7.6) | | | @@ -528,7 +528,7 @@ | Microsoft.Azure.Functions.Worker.Extensions.Kusto | NuGet [1.0.11-Preview](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Kusto/1.0.11-Preview) | | | | Microsoft.Azure.Functions.Worker.Extensions.OpenApi | NuGet [1.4.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/1.4.0)
NuGet [2.0.0-preview2](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/2.0.0-preview2) | | | | Microsoft.Azure.Functions.Worker.Extensions.RabbitMQ | NuGet [2.0.3](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.RabbitMQ/2.0.3) | | | -| Microsoft.Azure.Functions.Worker.Extensions.Rpc | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Rpc/1.0.0) | | | +| Microsoft.Azure.Functions.Worker.Extensions.Rpc | NuGet [1.0.1](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Rpc/1.0.1) | | | | Microsoft.Azure.Functions.Worker.Extensions.SendGrid | NuGet [3.0.3](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.SendGrid/3.0.3) | | | | Microsoft.Azure.Functions.Worker.Extensions.ServiceBus | NuGet [5.22.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.ServiceBus/5.22.0) | | | | Microsoft.Azure.Functions.Worker.Extensions.SignalRService | NuGet [1.15.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.SignalRService/1.15.0) | | | diff --git a/docs/azure/includes/dotnet-new.md b/docs/azure/includes/dotnet-new.md index f020b512b922e..fbef85aa48429 100644 --- a/docs/azure/includes/dotnet-new.md +++ b/docs/azure/includes/dotnet-new.md @@ -1,9 +1,9 @@ | Name | Package | Docs | Source | | ---- | ------- | ---- | ------ | -| AI Model Inference | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.AI.Inference/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/AI.Inference-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Inference_1.0.0-beta.1/sdk/ai/Azure.AI.Inference/) | +| AI Model Inference | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.AI.Inference/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/AI.Inference-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.Inference_1.0.0-beta.2/sdk/ai/Azure.AI.Inference/) | | Anomaly Detector | NuGet [3.0.0-preview.7](https://www.nuget.org/packages/Azure.AI.AnomalyDetector/3.0.0-preview.7) | [docs](/dotnet/api/overview/azure/AI.AnomalyDetector-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [3.0.0-preview.7](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.AnomalyDetector_3.0.0-preview.7/sdk/anomalydetector/Azure.AI.AnomalyDetector/) | | App Configuration | NuGet [1.5.0](https://www.nuget.org/packages/Azure.Data.AppConfiguration/1.5.0) | [docs](/dotnet/api/overview/azure/Data.AppConfiguration-readme) | GitHub [1.5.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.AppConfiguration_1.5.0/sdk/appconfiguration/Azure.Data.AppConfiguration/) | -| App Configuration Provider | NuGet [8.0.0](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.AzureAppConfiguration/8.0.0) | | GitHub [8.0.0](https://github.com/Azure/AppConfiguration-DotnetProvider) | +| App Configuration Provider | NuGet [8.0.0](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.AzureAppConfiguration/8.0.0)
NuGet [8.1.0-preview](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.AzureAppConfiguration/8.1.0-preview) | | GitHub [8.0.0](https://github.com/Azure/AppConfiguration-DotnetProvider) | | Attestation | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Security.Attestation/1.0.0) | [docs](/dotnet/api/overview/azure/Security.Attestation-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.Attestation_1.0.0/sdk/attestation/Azure.Security.Attestation/) | | Azure AI Search | NuGet [11.6.0](https://www.nuget.org/packages/Azure.Search.Documents/11.6.0)
NuGet [11.7.0-beta.1](https://www.nuget.org/packages/Azure.Search.Documents/11.7.0-beta.1) | [docs](/dotnet/api/overview/azure/Search.Documents-readme) | GitHub [11.6.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Search.Documents_11.6.0/sdk/search/Azure.Search.Documents/)
GitHub [11.7.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Search.Documents_11.7.0-beta.1/sdk/search/Azure.Search.Documents/) | | Azure Object Anchors Conversion | NuGet [0.3.0-beta.6](https://www.nuget.org/packages/Azure.MixedReality.ObjectAnchors.Conversion/0.3.0-beta.6) | [docs](/dotnet/api/overview/azure/MixedReality.ObjectAnchors.Conversion-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [0.3.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.ObjectAnchors.Conversion_0.3.0-beta.6/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/) | @@ -52,9 +52,9 @@ | Health Insights Cancer Profiling | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Health.Insights.CancerProfiling/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Health.Insights.CancerProfiling-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Health.Insights.CancerProfiling_1.0.0-beta.1/sdk/healthinsights/Azure.Health.Insights.CancerProfiling/) | | Health Insights Clinical Matching | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Health.Insights.ClinicalMatching/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Health.Insights.ClinicalMatching-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Health.Insights.ClinicalMatching_1.0.0-beta.1/sdk/healthinsights/Azure.Health.Insights.ClinicalMatching/) | | Health Insights Radiology Insights | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Health.Insights.RadiologyInsights/1.0.0) | [docs](/dotnet/api/overview/azure/Health.Insights.RadiologyInsights-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Health.Insights.RadiologyInsights_1.0.0/sdk/healthinsights/Azure.Health.Insights.RadiologyInsights/) | -| Identity | NuGet [1.13.0](https://www.nuget.org/packages/Azure.Identity/1.13.0) | [docs](/dotnet/api/overview/azure/Identity-readme) | GitHub [1.13.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity_1.13.0/sdk/identity/Azure.Identity/) | +| Identity | NuGet [1.13.1](https://www.nuget.org/packages/Azure.Identity/1.13.1) | [docs](/dotnet/api/overview/azure/Identity-readme) | GitHub [1.13.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity_1.13.1/sdk/identity/Azure.Identity/) | | Identity Broker | NuGet [1.1.0](https://www.nuget.org/packages/Azure.Identity.Broker/1.1.0)
NuGet [1.2.0-beta.1](https://www.nuget.org/packages/Azure.Identity.Broker/1.2.0-beta.1) | [docs](/dotnet/api/overview/azure/Identity.Broker-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity.Broker_1.1.0/sdk/identity/Azure.Identity.Broker/)
GitHub [1.2.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity.Broker_1.2.0-beta.1/sdk/identity/Azure.Identity.Broker/) | -| Image Analysis | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.AI.Vision.ImageAnalysis/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.Vision.ImageAnalysis-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Vision.ImageAnalysis_1.0.0-beta.3/sdk/vision/Azure.AI.Vision.ImageAnalysis/) | +| Image Analysis | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.Vision.ImageAnalysis/1.0.0) | [docs](/dotnet/api/overview/azure/AI.Vision.ImageAnalysis-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Vision.ImageAnalysis_1.0.0/sdk/vision/Azure.AI.Vision.ImageAnalysis/) | | Key Vault - Administration | NuGet [4.5.0](https://www.nuget.org/packages/Azure.Security.KeyVault.Administration/4.5.0) | [docs](/dotnet/api/overview/azure/Security.KeyVault.Administration-readme) | GitHub [4.5.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.KeyVault.Administration_4.5.0/sdk/keyvault/Azure.Security.KeyVault.Administration/) | | Key Vault - Certificates | NuGet [4.7.0](https://www.nuget.org/packages/Azure.Security.KeyVault.Certificates/4.7.0) | [docs](/dotnet/api/overview/azure/Security.KeyVault.Certificates-readme) | GitHub [4.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.KeyVault.Certificates_4.7.0/sdk/keyvault/Azure.Security.KeyVault.Certificates/) | | Key Vault - Keys | NuGet [4.7.0](https://www.nuget.org/packages/Azure.Security.KeyVault.Keys/4.7.0) | [docs](/dotnet/api/overview/azure/Security.KeyVault.Keys-readme) | GitHub [4.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.KeyVault.Keys_4.7.0/sdk/keyvault/Azure.Security.KeyVault.Keys/) | diff --git a/docs/core/docker/build-container.md b/docs/core/docker/build-container.md index ef1132cb4f1ef..6c4bf79611d2d 100644 --- a/docs/core/docker/build-container.md +++ b/docs/core/docker/build-container.md @@ -126,7 +126,7 @@ If you pass a number on the command line to the app, it will only count up to th ## Publish .NET app -In order for the app to be suitable for an image creation it has to be built. The `dotnet publish` command is most apt for this, as it builds and publishes the app. For an in-depth reference, see [dotnet build](/dotnet/core/tools/dotnet-build) and [dotnet publish](/dotnet/core/tools/dotnet-publish) commands documentation. +In order for the app to be suitable for an image creation it has to be built. The `dotnet publish` command is most apt for this, as it builds and publishes the app. For an in-depth reference, see [dotnet build](../tools/dotnet-build.md) and [dotnet publish](../tools/dotnet-publish.md) commands documentation. ```dotnetcli dotnet publish -c Release diff --git a/docs/core/extensions/configuration-generator.md b/docs/core/extensions/configuration-generator.md index 971bf50660906..ef4afb953b114 100644 --- a/docs/core/extensions/configuration-generator.md +++ b/docs/core/extensions/configuration-generator.md @@ -10,7 +10,7 @@ ms.date: 10/09/2024 Starting with .NET 8, a configuration binding source generator was introduced that intercepts specific call sites and generates their functionality. This feature provides a [Native ahead-of-time (AOT)](../deploying/native-aot/index.md) and [trim-friendly](../deploying/trimming/trim-self-contained.md) way to use the [configuration binder](configuration.md#binding), without the use of the reflection-based implementation. Reflection requires dynamic code generation, which isn't supported in AOT scenarios. -This feature is possible with the advent of [C# interceptors](/dotnet/csharp/whats-new/csharp-12#interceptors) that were introduced in C# 12. Interceptors allow the compiler to generate source code that intercepts specific calls and substitutes them with generated code. +This feature is possible with the advent of [C# interceptors](../../csharp/whats-new/csharp-12.md#interceptors) that were introduced in C# 12. Interceptors allow the compiler to generate source code that intercepts specific calls and substitutes them with generated code. ## Enable the configuration source generator @@ -52,7 +52,7 @@ The preceding code: When the application is built, the configuration source generator intercepts the call to `GetValue` and generates the binding code. > [!IMPORTANT] -> When the `PublishAot` property is set to `true` (or any other AOT warnings are enabled) and the `EnabledConfigurationBindingGenerator` property is set to `false`, warning `IL2026` is raised. This warning indicates that members are attributed with [RequiresUnreferencedCode](xref:System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute) may break when trimming. For more information, see [IL2026](/dotnet/core/deploying/trimming/trim-warnings/il2026). +> When the `PublishAot` property is set to `true` (or any other AOT warnings are enabled) and the `EnabledConfigurationBindingGenerator` property is set to `false`, warning `IL2026` is raised. This warning indicates that members are attributed with [RequiresUnreferencedCode](xref:System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute) may break when trimming. For more information, see [IL2026](../deploying/trimming/trim-warnings/il2026.md). ### Explore the source generated code diff --git a/docs/core/testing/unit-testing-platform-architecture-extensions.md b/docs/core/testing/unit-testing-platform-architecture-extensions.md index c4b44a94307ce..59f3bba4b8014 100644 --- a/docs/core/testing/unit-testing-platform-architecture-extensions.md +++ b/docs/core/testing/unit-testing-platform-architecture-extensions.md @@ -854,7 +854,7 @@ Let's examine the apis and their mean: * `OneOrMore`: Represents an argument arity of one or more. * `ExactlyOne`: Represents an argument arity of exactly one. -For examples, refer to the [System.CommandLine arity table](/dotnet/standard/commandline/syntax#argument-arity). +For examples, refer to the [System.CommandLine arity table](../../standard/commandline/syntax.md#argument-arity). `bool isHidden`: This property signifies that the option is available for use but will not be displayed in the description when `--help` is invoked. diff --git a/docs/core/tools/sdk-errors/netsdk1045.md b/docs/core/tools/sdk-errors/netsdk1045.md index e3b940f7f982a..2a707ad80d2fb 100644 --- a/docs/core/tools/sdk-errors/netsdk1045.md +++ b/docs/core/tools/sdk-errors/netsdk1045.md @@ -58,7 +58,7 @@ Check the MSBuildSDKPath environment variable. This optional environment variabl ## global.json file -Check for a *global.json* file in the root folder in your project and up the directory chain to the root of the volume, since it can be anywhere in the folder structure. If it contains an SDK version, delete the `sdk` node and all its children, or update it to the desired newer .NET Core version. +Check for a *global.json* file in the root folder in your project and in your solution, and up the directory chain to the root of the volume, since it can be anywhere in the folder structure. If it contains an SDK version, delete the `sdk` node and all its children, or update it to the desired newer .NET Core version. ```json { diff --git a/docs/core/whats-new/dotnet-6.md b/docs/core/whats-new/dotnet-6.md index 1b703499158a7..7abc477c45ee4 100644 --- a/docs/core/whats-new/dotnet-6.md +++ b/docs/core/whats-new/dotnet-6.md @@ -94,7 +94,7 @@ Many improvements have been made in . Source generation works with and can be configured in multiple ways. It can improve performance, reduce memory usage, and facilitate assembly trimming. For more information, see [How to choose reflection or source generation in System.Text.Json](../../standard/serialization/system-text-json/source-generation-modes.md) and [How to use source generation in System.Text.Json](../../standard/serialization/system-text-json/source-generation.md). +.NET 6 adds a new [source generator](../../csharp/roslyn-sdk/index.md#source-generators) for . Source generation works with and can be configured in multiple ways. It can improve performance, reduce memory usage, and facilitate assembly trimming. For more information, see [How to choose reflection or source generation in System.Text.Json](../../standard/serialization/system-text-json/source-generation-modes.md) and [How to use source generation in System.Text.Json](../../standard/serialization/system-text-json/source-generation.md). ### Writeable DOM diff --git a/docs/csharp/advanced-topics/interop/walkthrough-office-programming.md b/docs/csharp/advanced-topics/interop/walkthrough-office-programming.md index 218348b68060a..f24beeb243e6d 100644 --- a/docs/csharp/advanced-topics/interop/walkthrough-office-programming.md +++ b/docs/csharp/advanced-topics/interop/walkthrough-office-programming.md @@ -49,7 +49,7 @@ In **Solution Explorer**, right-click the **ThisAddIn.cs** file and then select ## Create a list of bank accounts -In **Solution Explorer**, right-click your project's name, select **Add**, and then select **Class**. Name the class Account.cs. Select **Add**. Replace the definition of the `Account` class with the following code. The class definitions use *auto-implemented properties*. +In **Solution Explorer**, right-click your project's name, select **Add**, and then select **Class**. Name the class Account.cs. Select **Add**. Replace the definition of the `Account` class with the following code. The class definitions use *automatically implemented properties*. :::code language="csharp" source="./snippets/OfficeWalkthrough/account.cs" id="AccountClass"::: @@ -122,13 +122,13 @@ In Visual Studio, select **Clean Solution** on the **Build** menu. Otherwise, th ## See also -- [Auto-Implemented Properties (C#)](../../programming-guide/classes-and-structs/auto-implemented-properties.md) -- [Object and Collection Initializers](../../programming-guide/classes-and-structs/object-and-collection-initializers.md) +- [Automatically implemented properties (C#)](../../programming-guide/classes-and-structs/auto-implemented-properties.md) +- [Object and collection initializers](../../programming-guide/classes-and-structs/object-and-collection-initializers.md) - [Visual Studio Tools for Office (VSTO)](/visualstudio/vsto/visual-studio-tools-for-office-runtime-overview) -- [Named and Optional Arguments](../../programming-guide/classes-and-structs/named-and-optional-arguments.md) +- [Named and optional arguments](../../programming-guide/classes-and-structs/named-and-optional-arguments.md) - [dynamic](../../language-reference/builtin-types/reference-types.md) -- [Using Type dynamic](using-type-dynamic.md) -- [Lambda Expressions (C#)](../../language-reference/operators/lambda-expressions.md) -- [Walkthrough: Embedding Type Information from Microsoft Office Assemblies in Visual Studio](/previous-versions/visualstudio/visual-studio-2013/ee317478(v=vs.120)) -- [Walkthrough: Embedding Types from Managed Assemblies](../../../standard/assembly/embed-types-visual-studio.md) -- [Walkthrough: Creating Your First VSTO Add-in for Excel](/visualstudio/vsto/walkthrough-creating-your-first-vsto-add-in-for-excel) +- [Using type dynamic](using-type-dynamic.md) +- [Lambda expressions (C#)](../../language-reference/operators/lambda-expressions.md) +- [Walkthrough: Embedding type information from Microsoft Office assemblies in Visual Studio](/previous-versions/visualstudio/visual-studio-2013/ee317478(v=vs.120)) +- [Walkthrough: Embedding types from managed assemblies](../../../standard/assembly/embed-types-visual-studio.md) +- [Walkthrough: Creating your first VSTO add-in for Excel](/visualstudio/vsto/walkthrough-creating-your-first-vsto-add-in-for-excel) diff --git a/docs/csharp/advanced-topics/reflection-and-attributes/index.md b/docs/csharp/advanced-topics/reflection-and-attributes/index.md index 3a4a137ca125e..f022192286501 100644 --- a/docs/csharp/advanced-topics/reflection-and-attributes/index.md +++ b/docs/csharp/advanced-topics/reflection-and-attributes/index.md @@ -95,7 +95,7 @@ The list of possible `target` values is shown in the following table. | `return` | Return value of a method, property indexer, or `get` property accessor | | `type` | Struct, class, interface, enum, or delegate | -You would specify the `field` target value to apply an attribute to the backing field created for an [auto-implemented property](../../programming-guide/classes-and-structs/properties.md). +You would specify the `field` target value to apply an attribute to the backing field created for an [automatically implemented property](../../programming-guide/classes-and-structs/properties.md). The following example shows how to apply attributes to assemblies and modules. For more information, see [Common Attributes (C#)](../../language-reference/attributes/global.md). diff --git a/docs/csharp/fundamentals/types/interfaces.md b/docs/csharp/fundamentals/types/interfaces.md index 64a6d423717f3..9d8984031bd81 100644 --- a/docs/csharp/fundamentals/types/interfaces.md +++ b/docs/csharp/fundamentals/types/interfaces.md @@ -8,7 +8,7 @@ helpviewer_keywords: --- # Interfaces - define behavior for multiple types -An interface contains definitions for a group of related functionalities that a non-abstract [`class`](../../language-reference/keywords/class.md) or a [`struct`](../../language-reference/builtin-types/struct.md) must implement. An interface may define `static` methods, which must have an implementation. An interface may define a default implementation for members. An interface may not declare instance data such as fields, auto-implemented properties, or property-like events. +An interface contains definitions for a group of related functionalities that a non-abstract [`class`](../../language-reference/keywords/class.md) or a [`struct`](../../language-reference/builtin-types/struct.md) must implement. An interface may define `static` methods, which must have an implementation. An interface may define a default implementation for members. An interface may not declare instance data such as fields, automatically implemented properties, or property-like events. By using interfaces, you can, for example, include behavior from multiple sources in a class. That capability is important in C# because the language doesn't support multiple inheritance of classes. In addition, you must use an interface if you want to simulate inheritance for structs, because they can't actually inherit from another struct or class. diff --git a/docs/csharp/how-to/index.md b/docs/csharp/how-to/index.md index 702042420c230..6149fe9c82588 100644 --- a/docs/csharp/how-to/index.md +++ b/docs/csharp/how-to/index.md @@ -22,7 +22,7 @@ There are several tips and tricks that are common C# developer practices: You create classes, records, and structs to implement your program. These techniques are commonly used when writing classes, records, or structs. -- [Declare auto implemented properties](../programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md). +- [Declare automatically implemented properties](../programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md). - [Declare and use read/write properties](../programming-guide/classes-and-structs/how-to-declare-and-use-read-write-properties.md). - [Define constants](../programming-guide/classes-and-structs/how-to-define-constants.md). - [Override the `ToString` method to provide string output](../programming-guide/classes-and-structs/how-to-override-the-tostring-method.md). diff --git a/docs/csharp/language-reference/attributes/general.md b/docs/csharp/language-reference/attributes/general.md index 1f5e9902e8819..00855cba57adb 100644 --- a/docs/csharp/language-reference/attributes/general.md +++ b/docs/csharp/language-reference/attributes/general.md @@ -120,7 +120,7 @@ If is `false`, then derived clas In this case, `NonInheritedAttribute` isn't applied to `DClass` via inheritance. -You can also use these keywords to specify where an attribute should be applied. For example, you can use the `field:` specifier to add an attribute to the backing field of an [autoimplemented property](../../programming-guide/classes-and-structs/properties.md#auto-implemented-properties). Or you can use the `field:`, `property:` or `param:` specifier to apply an attribute to any of the elements generated from a positional record. For an example, see [Positional syntax for property definition](../builtin-types/record.md#positional-syntax-for-property-definition). +You can also use these keywords to specify where an attribute should be applied. For example, you can use the `field:` specifier to add an attribute to the backing field of an [automatically implemented property](../../programming-guide/classes-and-structs/properties.md#automatically-implemented-properties). Or you can use the `field:`, `property:` or `param:` specifier to apply an attribute to any of the elements generated from a positional record. For an example, see [Positional syntax for property definition](../builtin-types/record.md#positional-syntax-for-property-definition). ## `AsyncMethodBuilder` attribute diff --git a/docs/csharp/language-reference/builtin-types/struct.md b/docs/csharp/language-reference/builtin-types/struct.md index 97183470d1457..5fecf3081b714 100644 --- a/docs/csharp/language-reference/builtin-types/struct.md +++ b/docs/csharp/language-reference/builtin-types/struct.md @@ -28,7 +28,7 @@ Because structure types have value semantics, we recommend you define *immutable You use the `readonly` modifier to declare that a structure type is immutable. All data members of a `readonly` struct must be read-only as follows: - Any field declaration must have the [`readonly` modifier](../keywords/readonly.md) -- Any property, including auto-implemented ones, must be read-only or [`init` only](../keywords/init.md). Note that init-only setters are only available from [C# version 9 onwards](../../whats-new/csharp-version-history.md). +- Any property, including automatically implemented ones, must be read-only or [`init` only](../keywords/init.md). Note that init-only setters are only available from [C# version 9 onwards](../../whats-new/csharp-version-history.md). That guarantees that no member of a `readonly` struct modifies the state of the struct. That means that other instance members except constructors are implicitly [`readonly`](#readonly-instance-members). @@ -62,7 +62,7 @@ Typically, you apply the `readonly` modifier to the following kinds of instance If you need to apply the `readonly` modifier to both accessors of a property or indexer, apply it in the declaration of the property or indexer. > [!NOTE] - > The compiler declares a `get` accessor of an [auto-implemented property](../../programming-guide/classes-and-structs/auto-implemented-properties.md) as `readonly`, regardless of presence of the `readonly` modifier in a property declaration. + > The compiler declares a `get` accessor of an [automatically implemented property](../../programming-guide/classes-and-structs/auto-implemented-properties.md) as `readonly`, regardless of presence of the `readonly` modifier in a property declaration. You may apply the `readonly` modifier to a property or indexer with an `init` accessor: diff --git a/docs/csharp/language-reference/compiler-messages/cs0840.md b/docs/csharp/language-reference/compiler-messages/cs0840.md index cf364a1742a9c..f8bbbacbc3e79 100644 --- a/docs/csharp/language-reference/compiler-messages/cs0840.md +++ b/docs/csharp/language-reference/compiler-messages/cs0840.md @@ -12,7 +12,7 @@ ms.assetid: f307083f-8d86-4142-a9fd-b735910687b2 'Property name' must declare a body because it is not marked abstract or extern. Automatically implemented properties must define both get and set accessors. - Unless a regular property is marked as `abstract` or `extern`, or is a member of a `partial` type, it must supply a body. Auto-implemented properties do not provide accessor bodies, but they must specify both accessors. To create a read-only auto-implemented property, make the set accessor `private`. + Unless a regular property is marked as `abstract` or `extern`, or is a member of a `partial` type, it must supply a body. Automatically implemented properties do not provide accessor bodies, but they must specify both accessors. To create a read-only automatically implemented property, make the set accessor `private`. ## To correct this error @@ -39,4 +39,4 @@ class Test ## See also -- [Auto-Implemented Properties](../../programming-guide/classes-and-structs/auto-implemented-properties.md) +- [Automatically implemented properties](../../programming-guide/classes-and-structs/auto-implemented-properties.md) diff --git a/docs/csharp/language-reference/compiler-messages/cs8145.md b/docs/csharp/language-reference/compiler-messages/cs8145.md index ae5929599d91e..bb66a26c75b32 100644 --- a/docs/csharp/language-reference/compiler-messages/cs8145.md +++ b/docs/csharp/language-reference/compiler-messages/cs8145.md @@ -11,7 +11,7 @@ helpviewer_keywords: Auto-implemented properties cannot return by reference -Auto-implemented properties are not guaranteed to have a member or variable that can be referenced and thus do not support return by reference. +Automatically implemented properties are not guaranteed to have a member or variable that can be referenced and thus do not support return by reference. ## Example diff --git a/docs/csharp/language-reference/compiler-messages/partial-declarations.md b/docs/csharp/language-reference/compiler-messages/partial-declarations.md index fcdd1d52f6bed..2677cf331725a 100644 --- a/docs/csharp/language-reference/compiler-messages/partial-declarations.md +++ b/docs/csharp/language-reference/compiler-messages/partial-declarations.md @@ -229,4 +229,4 @@ The following warning indicates a signature difference in the declaring and impl - **CS9256**: *Partial property declarations have signature differences.* -A partial property or indexer must have both a *declaring declaration* and an *implementing declaration*. The signatures for both declarations must match. Because the *declaring declaration* uses the same syntax as an auto-implemented property, the *implementing declaration* can't be an auto-implemented property. The accessors must have bodies. +A partial property or indexer must have both a *declaring declaration* and an *implementing declaration*. The signatures for both declarations must match. Because the *declaring declaration* uses the same syntax as an automatically implemented property, the *implementing declaration* can't be an automatically implemented property. The accessors must have bodies. diff --git a/docs/csharp/language-reference/compiler-messages/ref-struct-errors.md b/docs/csharp/language-reference/compiler-messages/ref-struct-errors.md index 9df47c00225eb..991b4777132e4 100644 --- a/docs/csharp/language-reference/compiler-messages/ref-struct-errors.md +++ b/docs/csharp/language-reference/compiler-messages/ref-struct-errors.md @@ -56,7 +56,7 @@ ms.date: 07/30/2024 A [`ref struct`](../builtin-types/ref-struct.md) type can include `ref` fields. Other types aren't allowed `ref` fields. The compiler enforces restrictions on the declarations and use of `ref struct` types to enforce ref safety rules on instances of any `ref struct` type: -- Only `ref struct` types can contain auto-implemented `ref` properties. +- Only `ref struct` types can contain automatically implemented `ref` properties. - Only `ref struct` types or `ref` variables can have the `scoped` modifier. - A `ref` field can be declared only in a `ref struct` type. - A `ref` field can't refer to a `ref struct` type/ diff --git a/docs/csharp/language-reference/keywords/get.md b/docs/csharp/language-reference/keywords/get.md index 90303ee39d64e..ef716ca5df4ab 100644 --- a/docs/csharp/language-reference/keywords/get.md +++ b/docs/csharp/language-reference/keywords/get.md @@ -10,7 +10,7 @@ helpviewer_keywords: --- # get (C# Reference) -The `get` keyword defines an *accessor* method in a property or indexer that returns the property value or the indexer element. For more information, see [Properties](../../programming-guide/classes-and-structs/properties.md), [Auto-Implemented Properties](../../programming-guide/classes-and-structs/auto-implemented-properties.md), and [Indexers](../../programming-guide/indexers/index.md). +The `get` keyword defines an *accessor* method in a property or indexer that returns the property value or the indexer element. For more information, see [Properties](../../programming-guide/classes-and-structs/properties.md), [Automatically implemented Properties](../../programming-guide/classes-and-structs/automatically implemented-properties.md), and [Indexers](../../programming-guide/indexers/index.md). The following example defines both a `get` and a `set` accessor for a property named `Seconds`. It uses a private field named `_seconds` to back the property value. @@ -20,12 +20,12 @@ Often, the `get` accessor consists of a single statement that returns a value, a :::code language="csharp" source="./snippets/PropertyAccessors.cs" id="GetSetExpressions"::: -For simple cases in which a property's `get` and `set` accessors perform no other operation than setting or retrieving a value in a private backing field, you can take advantage of the C# compiler's support for auto-implemented properties. The following example implements `Hours` as an auto-implemented property. +For simple cases in which a property's `get` and `set` accessors perform no other operation than setting or retrieving a value in a private backing field, you can take advantage of the C# compiler's support for automatically implemented properties. The following example implements `Hours` as an automatically implemented property. :::code language="csharp" source="./snippets/PropertyAccessors.cs" id="AutoImplementedProperties"::: > [!IMPORTANT] -> Auto-implemented properties aren't allowed for [interface property declarations](../../programming-guide/classes-and-structs/interface-properties.md) or [partial property declarations](./partial-member.md). In both cases, the compiler interprets syntax matching an auto-implemented property as the declaring declaration, not an implementing declaration. +> Automatically implemented properties aren't allowed for [interface property declarations](../../programming-guide/classes-and-structs/interface-properties.md) or the implementing declaration for a [partial property](./partial-member.md). The compiler interprets syntax matching an automatically implemented property as the declaring declaration, not an implementing declaration. ## C# Language Specification diff --git a/docs/csharp/language-reference/keywords/group-clause.md b/docs/csharp/language-reference/keywords/group-clause.md index fb543a472a8a6..7bdaee3f3d25c 100644 --- a/docs/csharp/language-reference/keywords/group-clause.md +++ b/docs/csharp/language-reference/keywords/group-clause.md @@ -60,7 +60,7 @@ Use a composite key when you want to group elements according to more than one k group person by new {name = person.surname, city = person.city}; ``` -Use a named type if you must pass the query variable to another method. Create a special class using auto-implemented properties for the keys, and then override the and methods. You can also use a struct, in which case you do not strictly have to override those methods. For more information see [How to implement a lightweight class with auto-implemented properties](../../programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md) and [How to query for duplicate files in a directory tree](../../linq/how-to-query-files-and-directories.md). The latter article has a code example that demonstrates how to use a composite key with a named type. +Use a named type if you must pass the query variable to another method. Create a special class using automatically implemented properties for the keys, and then override the and methods. You can also use a struct, in which case you do not strictly have to override those methods. For more information see [How to implement a lightweight class with automatically implemented properties](../../programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md) and [How to query for duplicate files in a directory tree](../../linq/how-to-query-files-and-directories.md). The latter article has a code example that demonstrates how to use a composite key with a named type. ## Example 1 diff --git a/docs/csharp/language-reference/keywords/init.md b/docs/csharp/language-reference/keywords/init.md index bffbc345e2b45..d77303ed2f801 100644 --- a/docs/csharp/language-reference/keywords/init.md +++ b/docs/csharp/language-reference/keywords/init.md @@ -11,7 +11,7 @@ helpviewer_keywords: # init (C# Reference) The `init` keyword defines an *accessor* method in a property or indexer. An init-only setter assigns a value to the property or the indexer element **only** during object construction. An `init` enforces immutability, so that once the object is initialized, it can't be changed. An `init` accessor enables calling code to use an [object initializer](../../programming-guide/classes-and-structs/how-to-initialize-objects-by-using-an-object-initializer.md) to set the initial value. As a contrast, an - [auto-implemented property](../../programming-guide/classes-and-structs/auto-implemented-properties.md) with only a `get` setter must be initialized by calling a constructor. A property with a `private set` accessor can be modified after construction, but only in the class. + [automatically implemented property](../../programming-guide/classes-and-structs/auto-implemented-properties.md) with only a `get` setter must be initialized by calling a constructor. A property with a `private set` accessor can be modified after construction, but only in the class. The following example defines both a `get` and an `init` accessor for a property named `YearOfBirth`. It uses a private field named `_yearOfBirth` to back the property value. diff --git a/docs/csharp/language-reference/keywords/interface.md b/docs/csharp/language-reference/keywords/interface.md index 0bc2811b0dcd7..14a33f2e925d7 100644 --- a/docs/csharp/language-reference/keywords/interface.md +++ b/docs/csharp/language-reference/keywords/interface.md @@ -58,7 +58,7 @@ You can try this feature by working with the tutorial on [static abstract member ## Interface inheritance -Interfaces may not contain instance state. While static fields are now permitted, instance fields aren't permitted in interfaces. [Instance auto-properties](../../programming-guide/classes-and-structs/auto-implemented-properties.md) aren't supported in interfaces, as they would implicitly declare a hidden field. This rule has a subtle effect on property declarations. In an interface declaration, the following code doesn't declare an auto-implemented property as it does in a `class` or `struct`. Instead, it declares a property that doesn't have a default implementation but must be implemented in any type that implements the interface: +Interfaces may not contain instance state. While static fields are now permitted, instance fields aren't permitted in interfaces. [Instance auto-properties](../../programming-guide/classes-and-structs/auto-implemented-properties.md) aren't supported in interfaces, as they would implicitly declare a hidden field. This rule has a subtle effect on property declarations. In an interface declaration, the following code doesn't declare an automatically implemented property as it does in a `class` or `struct`. Instead, it declares a property that doesn't have a default implementation but must be implemented in any type that implements the interface: ```csharp public interface INamed diff --git a/docs/csharp/language-reference/keywords/method-parameters.md b/docs/csharp/language-reference/keywords/method-parameters.md index 1113bcf204512..30626dbea4cde 100644 --- a/docs/csharp/language-reference/keywords/method-parameters.md +++ b/docs/csharp/language-reference/keywords/method-parameters.md @@ -58,9 +58,9 @@ Informally, you can think of these scopes as the mechanism to ensure your code n You apply one of the following modifiers to a parameter declaration to pass arguments by reference instead of by value: -- [`ref`](#ref-readonly-modifier): The argument must be initialized before calling the method. The method can assign a new value to the parameter, but isn't required to do so. +- [`ref`](#ref-parameter-modifier): The argument must be initialized before calling the method. The method can assign a new value to the parameter, but isn't required to do so. - [`out`](#out-parameter-modifier): The calling method isn't required to initialize the argument before calling the method. The method must assign a value to the parameter. -- [`readonly ref`](#ref-parameter-modifier): The argument must be initialized before calling the method. The method can't assign a new value to the parameter. +- [`readonly ref`](#ref-readonly-modifier): The argument must be initialized before calling the method. The method can't assign a new value to the parameter. - [`in`](#in-parameter-modifier): The argument must be initialized before calling the method. The method can't assign a new value to the parameter. The compiler might create a temporary variable to hold a copy of the argument to `in` parameters. Members of a class can't have signatures that differ only by `ref`, `ref readonly`, `in`, or `out`. A compiler error occurs if the only difference between two members of a type is that one of them has a `ref` parameter and the other has an `out`, `ref readonly`, or `in` parameter. However, methods can be overloaded when one method has a `ref`, `ref readonly`, `in`, or `out` parameter and the other has a parameter that is passed by value, as shown in the following example. In other situations that require signature matching, such as hiding or overriding, `in`, `ref`, `ref readonly`, and `out` are part of the signature and don't match each other. diff --git a/docs/csharp/language-reference/keywords/set.md b/docs/csharp/language-reference/keywords/set.md index 0a9a43d1d6a78..ff8b641d1c666 100644 --- a/docs/csharp/language-reference/keywords/set.md +++ b/docs/csharp/language-reference/keywords/set.md @@ -10,7 +10,7 @@ helpviewer_keywords: --- # set (C# Reference) -The `set` keyword defines an *accessor* method in a property or indexer that assigns a value to the property or the indexer element. For more information and examples, see [Properties](../../programming-guide/classes-and-structs/properties.md), [Auto-Implemented Properties](../../programming-guide/classes-and-structs/auto-implemented-properties.md), and [Indexers](../../programming-guide/indexers/index.md). +The `set` keyword defines an *accessor* method in a property or indexer that assigns a value to the property or the indexer element. For more information and examples, see [Properties](../../programming-guide/classes-and-structs/properties.md), [Automatically implemented properties](../../programming-guide/classes-and-structs/auto-implemented-properties.md), and [Indexers](../../programming-guide/indexers/index.md). The following example defines both a `get` and a `set` accessor for a property named `Seconds`. It uses a private field named `_seconds` to back the property value. @@ -20,12 +20,12 @@ Often, the `set` accessor consists of a single statement that assigns a value, a :::code language="csharp" source="./snippets/PropertyAccessors.cs" id="GetSetExpressions"::: -For simple cases in which a property's `get` and `set` accessors perform no other operation than setting or retrieving a value in a private backing field, you can take advantage of the C# compiler's support for auto-implemented properties. The following example implements `Hours` as an auto-implemented property. +For simple cases in which a property's `get` and `set` accessors perform no other operation than setting or retrieving a value in a private backing field, you can take advantage of the C# compiler's support for automatically implemented properties. The following example implements `Hours` as an automatically implemented property. :::code language="csharp" source="./snippets/PropertyAccessors.cs" id="AutoImplementedProperties"::: > [!IMPORTANT] -> Auto-implemented properties aren't allowed for [interface property declarations](../../programming-guide/classes-and-structs/interface-properties.md) or [partial property declarations](./partial-member.md). In both cases, the compiler interprets syntax matching an auto-implemented property as the declaring declaration, not an implementing declaration. +> Automatically implemented properties aren't allowed for [interface property declarations](../../programming-guide/classes-and-structs/interface-properties.md) or the implementing declaration for a [partial property](./partial-member.md). The compiler interprets syntax matching an automatically implemented property as the declaring declaration, not an implementing declaration. ## C# language specification diff --git a/docs/csharp/language-reference/operators/equality-operators.md b/docs/csharp/language-reference/operators/equality-operators.md index c9e00b64c6d3b..c31e9ee511353 100644 --- a/docs/csharp/language-reference/operators/equality-operators.md +++ b/docs/csharp/language-reference/operators/equality-operators.md @@ -49,7 +49,7 @@ As the example shows, user-defined reference types support the `==` operator by ### Record types equality -[Record types](../builtin-types/record.md) support the `==` and `!=` operators that by default provide value equality semantics. That is, two record operands are equal when both of them are `null` or corresponding values of all fields and auto-implemented properties are equal. +[Record types](../builtin-types/record.md) support the `==` and `!=` operators that by default provide value equality semantics. That is, two record operands are equal when both of them are `null` or corresponding values of all fields and automatically implemented properties are equal. :::code language="csharp" source="snippets/shared/EqualityOperators.cs" id="RecordTypesEquality"::: diff --git a/docs/csharp/misc/cs0200.md b/docs/csharp/misc/cs0200.md index c0ad9a85d3ae2..0ee9bbe3db2c8 100644 --- a/docs/csharp/misc/cs0200.md +++ b/docs/csharp/misc/cs0200.md @@ -46,7 +46,7 @@ public class Example } ``` -The following sample uses [auto-implemented properties](../programming-guide/classes-and-structs/auto-implemented-properties.md) and [object initializers](../programming-guide/classes-and-structs/object-and-collection-initializers.md) and still generates CS0200: +The following sample uses [automatically implemented properties](../programming-guide/classes-and-structs/auto-implemented-properties.md) and [object initializers](../programming-guide/classes-and-structs/object-and-collection-initializers.md) and still generates CS0200: ```csharp // CS0200.cs diff --git a/docs/csharp/misc/cs0842.md b/docs/csharp/misc/cs0842.md index 124ff0213dccc..2f1d36dcefcbb 100644 --- a/docs/csharp/misc/cs0842.md +++ b/docs/csharp/misc/cs0842.md @@ -12,7 +12,7 @@ ms.assetid: 93a8b333-efc4-40c7-ae53-5264f721a74f Automatically implemented properties cannot be used inside a type marked with StructLayout(LayoutKind.Explicit). - Auto-implemented properties have their backing fields provided by the compiler and the field is not accessible to source code. Therefore, they are not compatible with . + Automatically implemented properties have their backing fields provided by the compiler and the field is not accessible to source code. Therefore, they are not compatible with . ## To correct this error diff --git a/docs/csharp/programming-guide/classes-and-structs/auto-implemented-properties.md b/docs/csharp/programming-guide/classes-and-structs/auto-implemented-properties.md index 7ab9bd56ba7be..9ce8885985c27 100644 --- a/docs/csharp/programming-guide/classes-and-structs/auto-implemented-properties.md +++ b/docs/csharp/programming-guide/classes-and-structs/auto-implemented-properties.md @@ -1,6 +1,6 @@ --- -title: "Auto-Implemented Properties" -description: For an auto-implemented property in C#, the compiler creates a private, anonymous backing field accessed only through get and set accessors of the property. +title: "Automatically Implemented Properties" +description: For an automatically implemented property in C#, the compiler creates a private, anonymous backing field accessed only through get and set accessors of the property. ms.date: 08/20/2024 f1_keywords: - "propertyInitializer_CSharpKeyword" @@ -8,19 +8,19 @@ helpviewer_keywords: - "auto-implemented properties [C#]" - "properties [C#], auto-implemented" --- -# Auto-Implemented Properties (C# Programming Guide) +# Automatically implemented properties -Auto-implemented properties make property-declaration more concise when no other logic is required in the property accessors. They also enable client code to create objects. When you declare a property as shown in the following example, the compiler creates a private, anonymous backing field that can only be accessed through the property's `get` and `set` accessors. `init` accessors can also be declared as auto-implemented properties. +Automatically implemented properties make property-declaration more concise when no other logic is required in the property accessors. They also enable client code to create objects. When you declare a property as shown in the following example, the compiler creates a private, anonymous backing field that can only be accessed through the property's `get` and `set` accessors. `init` accessors can also be declared as automatically implemented properties. ## Example -The following example shows a simple class that has some auto-implemented properties: +The following example shows a simple class that has some automatically implemented properties: :::code language="csharp" source="./snippets/properties/AutoImplemented.cs" id="Snippet28"::: -You can't declare auto-implemented properties in interfaces. Auto-implemented properties declare a private instance backing field, and interfaces can't declare instance fields. Declaring a property in an interface without defining a body declares a property with accessors that must be implemented by each type that implements that interface. +You can't declare automatically implemented properties in interfaces. Automatically implemented properties declare a private instance backing field, and interfaces can't declare instance fields. Declaring a property in an interface without defining a body declares a property with accessors that must be implemented by each type that implements that interface. -You can initialize auto-implemented properties similarly to fields: +You can initialize automatically implemented properties similarly to fields: ```csharp public string FirstName { get; set; } = "Jane"; @@ -32,7 +32,7 @@ The class that is shown in the previous example is mutable. Client code can chan * Declare a `get` accessor and an `init` accessor (immutable everywhere except during object construction). * Declare the `set` accessor as [private](../../language-reference/keywords/private.md) (immutable to consumers). -For more information, see [How to implement a lightweight class with auto-implemented properties](./how-to-implement-a-lightweight-class-with-auto-implemented-properties.md). +For more information, see [How to implement a lightweight class with automatically implemented properties](./how-to-implement-a-lightweight-class-with-auto-implemented-properties.md). ## See also diff --git a/docs/csharp/programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md b/docs/csharp/programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md index 5d6a6d2de46fd..86e8af07f053c 100644 --- a/docs/csharp/programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md +++ b/docs/csharp/programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md @@ -1,15 +1,15 @@ --- -title: "How to implement a lightweight class with auto-implemented properties" -description: Learn how to create an immutable lightweight class in C# that encapsulates auto-implemented properties. There are two implementation approaches. +title: "How to implement a lightweight class with automatically implemented properties" +description: Learn how to create an immutable lightweight class in C# that encapsulates automatically implemented properties. There are two implementation approaches. ms.date: 07/29/2022 helpviewer_keywords: - "auto-implemented properties [C#]" - "properties [C#], auto-implemented" ms.topic: how-to --- -# How to implement a lightweight class with auto-implemented properties (C# Programming Guide) +# How to implement a lightweight class with automatically implemented properties -This example shows how to create an immutable lightweight class that serves only to encapsulate a set of auto-implemented properties. Use this kind of construct instead of a struct when you must use reference type semantics. +This example shows how to create an immutable lightweight class that serves only to encapsulate a set of automatically implemented properties. Use this kind of construct instead of a struct when you must use reference type semantics. You can make an immutable property in the following ways: @@ -44,7 +44,7 @@ class Contact ## Example -The following example shows two ways to implement an immutable class that has auto-implemented properties. Each way declares one of the properties with a private `set` and one of the properties with a `get` only. The first class uses a constructor only to initialize the properties, and the second class uses a static factory method that calls a constructor. +The following example shows two ways to implement an immutable class that has automatically implemented properties. Each way declares one of the properties with a private `set` and one of the properties with a `get` only. The first class uses a constructor only to initialize the properties, and the second class uses a static factory method that calls a constructor. ```csharp // This class is immutable. After an object is created, @@ -135,7 +135,7 @@ public class Program */ ``` -The compiler creates backing fields for each auto-implemented property. The fields aren't accessible directly from source code. +The compiler creates backing fields for each automatically implemented property. The fields aren't accessible directly from source code. ## See also diff --git a/docs/csharp/programming-guide/classes-and-structs/interface-properties.md b/docs/csharp/programming-guide/classes-and-structs/interface-properties.md index 154a6e4ce55ba..6b3c47c67f803 100644 --- a/docs/csharp/programming-guide/classes-and-structs/interface-properties.md +++ b/docs/csharp/programming-guide/classes-and-structs/interface-properties.md @@ -12,7 +12,7 @@ Properties can be declared on an [interface](../../language-reference/keywords/i :::code language="csharp" source="./snippets/properties/interfaces.cs" id="SnippetDeclareInterfaceProperties"::: -Interface properties typically don't have a body. The accessors indicate whether the property is read-write, read-only, or write-only. Unlike in classes and structs, declaring the accessors without a body doesn't declare an [auto-implemented property](auto-implemented-properties.md). An interface can define a default implementation for members, including properties. Defining a default implementation for a property in an interface is rare because interfaces can't define instance data fields. +Interface properties typically don't have a body. The accessors indicate whether the property is read-write, read-only, or write-only. Unlike in classes and structs, declaring the accessors without a body doesn't declare an [automatically implemented property](auto-implemented-properties.md). An interface can define a default implementation for members, including properties. Defining a default implementation for a property in an interface is rare because interfaces can't define instance data fields. ## Example diff --git a/docs/csharp/programming-guide/classes-and-structs/object-and-collection-initializers.md b/docs/csharp/programming-guide/classes-and-structs/object-and-collection-initializers.md index ecdd250285c5f..23aa132ff0ed6 100644 --- a/docs/csharp/programming-guide/classes-and-structs/object-and-collection-initializers.md +++ b/docs/csharp/programming-guide/classes-and-structs/object-and-collection-initializers.md @@ -12,7 +12,7 @@ C# lets you instantiate an object or collection and perform member assignments i ## Object initializers -Object initializers let you assign values to any accessible fields or properties of an object at creation time without having to invoke a constructor followed by lines of assignment statements. The object initializer syntax enables you to specify arguments for a constructor or omit the arguments (and parentheses syntax). The following example shows how to use an object initializer with a named type, `Cat` and how to invoke the parameterless constructor. Note the use of autoimplemented properties in the `Cat` class. For more information, see [Auto-Implemented Properties](auto-implemented-properties.md). +Object initializers let you assign values to any accessible fields or properties of an object at creation time without having to invoke a constructor followed by lines of assignment statements. The object initializer syntax enables you to specify arguments for a constructor or omit the arguments (and parentheses syntax). The following example shows how to use an object initializer with a named type, `Cat` and how to invoke the parameterless constructor. Note the use of autoimplemented properties in the `Cat` class. For more information, see [Automatically implemented properties](auto-implemented-properties.md). :::code language="csharp" source="./snippets/object-collection-initializers/BasicObjectInitializers.cs" id="CatDeclaration"::: :::code language="csharp" source="./snippets/object-collection-initializers/BasicObjectInitializers.cs" id="ObjectPropertyInitialization"::: diff --git a/docs/csharp/programming-guide/classes-and-structs/partial-classes-and-methods.md b/docs/csharp/programming-guide/classes-and-structs/partial-classes-and-methods.md index 79a1ef83fd4a4..d56e16e8aeb3d 100644 --- a/docs/csharp/programming-guide/classes-and-structs/partial-classes-and-methods.md +++ b/docs/csharp/programming-guide/classes-and-structs/partial-classes-and-methods.md @@ -17,7 +17,7 @@ There are several situations when splitting a class definition is desirable: - Declaring a class over separate files enables multiple programmers to work on it at the same time. - You can add code to the class without having to recreate the source file that includes automatically generated source. Visual Studio uses this approach when it creates Windows Forms, Web service wrapper code, and so on. You can create code that uses these classes without having to modify the file created by Visual Studio. -- [Source generators](../../roslyn-sdk/source-generators-overview.md) can generate extra functionality in a class. +- [Source generators](../../roslyn-sdk/index.md#source-generators) can generate extra functionality in a class. To split a class definition, use the [partial](../../language-reference/keywords/partial-type.md) keyword modifier, as shown here: @@ -112,7 +112,7 @@ An implementation isn't required for a partial method when the signature obeys t The method and all calls to the method are removed at compile time when there's no implementation. -Any method that doesn't conform to all those restrictions, including properties and indexers, must provide an implementation. That implementation might be supplied by a *source generator*. [Partial properties](../../language-reference/keywords/partial-member.md) can't be implemented using auto-implemented properties. The compiler can't distinguish between an auto-implemented property, and the declaring declaration of a partial property. +Any method that doesn't conform to all those restrictions, including properties and indexers, must provide an implementation. That implementation might be supplied by a *source generator*. [Partial properties](../../language-reference/keywords/partial-member.md) can't be implemented using automatically implemented properties. The compiler can't distinguish between an automatically implemented property, and the declaring declaration of a partial property. Partial methods enable the implementer of one part of a class to declare a member. The implementer of another part of the class can define that member. There are two scenarios where this separation is useful: templates that generate boilerplate code, and source generators. diff --git a/docs/csharp/programming-guide/classes-and-structs/properties.md b/docs/csharp/programming-guide/classes-and-structs/properties.md index a05aae227a524..a6a9a2b98764b 100644 --- a/docs/csharp/programming-guide/classes-and-structs/properties.md +++ b/docs/csharp/programming-guide/classes-and-structs/properties.md @@ -14,13 +14,13 @@ A *property* is a member that provides a flexible mechanism to read, write, or c :::code language="csharp" source="./snippets/properties/Person.cs" id="Field"::: -## Auto-implemented properties +## Automatically implemented properties A property definition contains declarations for a `get` and `set` accessor that retrieves and assigns the value of that property: :::code language="csharp" source="./snippets/properties/Person.cs" id="AutoImplemented"::: -The preceding example shows an *auto-implemented property*. The compiler generates a hidden backing field for the property. The compiler also implements the body of the `get` and `set` accessors. Any attributes are applied to the auto-implemented property. You can apply the attribute to the compiler-generated backing field by specifying the `field:` tag on the attribute. +The preceding example shows an *automatically implemented property*. The compiler generates a hidden backing field for the property. The compiler also implements the body of the `get` and `set` accessors. Any attributes are applied to the automatically implemented property. You can apply the attribute to the compiler-generated backing field by specifying the `field:` tag on the attribute. You can initialize a property to a value other than the default by setting a value after the closing brace for the property. You might prefer the initial value for the `FirstName` property to be the empty string rather than `null`. You would specify that as shown in the following code: @@ -39,7 +39,7 @@ You can add any restrictive access modifier to either the set or get accessors. There are two special access modifiers for `set` accessors: - A `set` accessor can have `init` as its access modifier. That `set` accessor can be called only from an object initializer or the type's constructors. It's more restrictive than `private` on the `set` accessor. -- An auto-implemented property can declare a `get` accessor without a `set` accessor. In that case, the compiler allows the `set` accessor to be called only from the type's constructors. It's more restrictive than the `init` accessor on the `set` accessor. +- An automatically implemented property can declare a `get` accessor without a `set` accessor. In that case, the compiler allows the `set` accessor to be called only from the type's constructors. It's more restrictive than the `init` accessor on the `set` accessor. Modify the `Person` class so as follows: @@ -86,13 +86,13 @@ This implementation works because the `FirstName` and `LastName` properties are This final version evaluates the `FullName` property only when needed. The previously calculated version is used if valid. Otherwise, the calculation updates the cached value. Developers using this class don't need to know the details of the implementation. None of these internal changes affect the use of the Person object. -Beginning with C# 13, you can create [`partial` properties](../../language-reference/keywords/partial-member.md) in `partial` classes. The implementing declaration for a `partial` property can't be an auto-implemented property. An auto-implemented property uses the same syntax as a declaring partial property declaration. +Beginning with C# 13, you can create [`partial` properties](../../language-reference/keywords/partial-member.md) in `partial` classes. The implementing declaration for a `partial` property can't be an automatically implemented property. An automatically implemented property uses the same syntax as a declaring partial property declaration. ## Properties Properties are a form of smart fields in a class or object. From outside the object, they appear like fields in the object. However, properties can be implemented using the full palette of C# functionality. You can provide validation, different accessibility, lazy evaluation, or any requirements your scenarios need. -- Simple properties that require no custom accessor code can be implemented either as expression body definitions or as [auto-implemented properties](./auto-implemented-properties.md). +- Simple properties that require no custom accessor code can be implemented either as expression body definitions or as [automatically implemented properties](./auto-implemented-properties.md). - Properties enable a class to expose a public way of getting and setting values, while hiding implementation or verification code. - A [get](../../language-reference/keywords/get.md) property accessor is used to return the property value, and a [set](../../language-reference/keywords/set.md) property accessor is used to assign a new value. An [init](../../language-reference/keywords/init.md) property accessor is used to assign a new value only during object construction. These accessors can have different access levels. For more information, see [Restricting Accessor Accessibility](./restricting-accessor-accessibility.md). - The [value](../../language-reference/keywords/value.md) keyword is used to define the value the `set` or `init` accessor is assigning. diff --git a/docs/csharp/programming-guide/classes-and-structs/restricting-accessor-accessibility.md b/docs/csharp/programming-guide/classes-and-structs/restricting-accessor-accessibility.md index 5cb902b128f56..ef533d738fe03 100644 --- a/docs/csharp/programming-guide/classes-and-structs/restricting-accessor-accessibility.md +++ b/docs/csharp/programming-guide/classes-and-structs/restricting-accessor-accessibility.md @@ -20,7 +20,7 @@ The [get](../../language-reference/keywords/get.md) and [set](../../language-ref In this example, a property called `Name` defines a `get` and `set` accessor. The `get` accessor receives the accessibility level of the property itself, `public` in this case, while the `set` accessor is explicitly restricted by applying the [protected](../../language-reference/keywords/protected.md) access modifier to the accessor itself. > [!NOTE] -> The examples in this article don't use [auto-implemented properties](./properties.md#auto-implemented-properties). *Auto-implemented properties* provide a concise syntax for declaring properties when a custom backing field isn't required. +> The examples in this article don't use [automatically implemented properties](./properties.md#automatically-implemented-properties). *Automatically implemented properties* provide a concise syntax for declaring properties when a custom backing field isn't required. ## Restrictions on Access Modifiers on Accessors diff --git a/docs/csharp/programming-guide/classes-and-structs/snippets/object-collection-initializers/BasicObjectInitializers.cs b/docs/csharp/programming-guide/classes-and-structs/snippets/object-collection-initializers/BasicObjectInitializers.cs index 56087f7ca8e64..cabbd0000b732 100644 --- a/docs/csharp/programming-guide/classes-and-structs/snippets/object-collection-initializers/BasicObjectInitializers.cs +++ b/docs/csharp/programming-guide/classes-and-structs/snippets/object-collection-initializers/BasicObjectInitializers.cs @@ -6,7 +6,7 @@ public class BasicObjectInitializers // public class Cat { - // Auto-implemented properties. + // Automatically implemented properties. public int Age { get; set; } public string? Name { get; set; } @@ -151,7 +151,7 @@ public class InitializationSample { public class Cat { - // Auto-implemented properties. + // Automatically implemented properties. public int Age { get; set; } public string? Name { get; set; } diff --git a/docs/csharp/programming-guide/classes-and-structs/using-properties.md b/docs/csharp/programming-guide/classes-and-structs/using-properties.md index cc3547af48848..340333b00667e 100644 --- a/docs/csharp/programming-guide/classes-and-structs/using-properties.md +++ b/docs/csharp/programming-guide/classes-and-structs/using-properties.md @@ -23,11 +23,11 @@ Properties are declared in the class block by specifying the access level of the :::code language="csharp" source="./snippets/properties/TimePeriod.cs" id="UsingExample"::: -In this example, `Month` is declared as a property so that the `set` accessor can make sure that the `Month` value is set between 1 and 12. The `Month` property uses a private field to track the actual value. The real location of a property's data is often referred to as the property's "backing store." It's common for properties to use private fields as a backing store. The field is marked private in order to make sure that it can only be changed by calling the property. For more information about public and private access restrictions, see [Access Modifiers](./access-modifiers.md). Auto-implemented properties provide simplified syntax for simple property declarations. For more information, see [Auto-Implemented Properties](auto-implemented-properties.md). +In this example, `Month` is declared as a property so that the `set` accessor can make sure that the `Month` value is set between 1 and 12. The `Month` property uses a private field to track the actual value. The real location of a property's data is often referred to as the property's "backing store." It's common for properties to use private fields as a backing store. The field is marked private in order to make sure that it can only be changed by calling the property. For more information about public and private access restrictions, see [Access Modifiers](./access-modifiers.md). Automatically implemented properties provide simplified syntax for simple property declarations. For more information, see [Automatically implemented properties](auto-implemented-properties.md). ## The get accessor -The body of the `get` accessor resembles that of a method. It must return a value of the property type. The C# compiler and Just-in-time (JIT) compiler detect common patterns for implementing the `get` accessor, and optimizes those patterns. For example, a `get` accessor that returns a field without performing any computation is likely optimized to a memory read of that field. Auto-implemented properties follow this pattern and benefit from these optimizations. However, a virtual `get` accessor method can't be inlined because the compiler doesn't know at compile time which method might actually be called at run time. The following example shows a `get` accessor that returns the value of a private field `_name`: +The body of the `get` accessor resembles that of a method. It must return a value of the property type. The C# compiler and Just-in-time (JIT) compiler detect common patterns for implementing the `get` accessor, and optimizes those patterns. For example, a `get` accessor that returns a field without performing any computation is likely optimized to a memory read of that field. Automatically mplemented properties follow this pattern and benefit from these optimizations. However, a virtual `get` accessor method can't be inlined because the compiler doesn't know at compile time which method might actually be called at run time. The following example shows a `get` accessor that returns the value of a private field `_name`: :::code language="csharp" source="./snippets/properties/Person.cs" id="UsingEmployeeExample"::: @@ -106,5 +106,5 @@ In this example, two classes, `Cube` and `Square`, implement an abstract class, - [Properties](properties.md) - [Interface properties](interface-properties.md) -- [Auto-implemented properties](auto-implemented-properties.md) +- [Automatically implemented properties](auto-implemented-properties.md) - [Partial properties](../../language-reference/keywords/partial-member.md) diff --git a/docs/csharp/programming-guide/indexers/comparison-between-properties-and-indexers.md b/docs/csharp/programming-guide/indexers/comparison-between-properties-and-indexers.md index f0cb88ca3652c..18e596e67afa8 100644 --- a/docs/csharp/programming-guide/indexers/comparison-between-properties-and-indexers.md +++ b/docs/csharp/programming-guide/indexers/comparison-between-properties-and-indexers.md @@ -18,7 +18,7 @@ Indexers are like properties. Except for the differences shown in the following |Can be a static or an instance member.|Must be an instance member.| |A [get](../../language-reference/keywords/get.md) accessor of a property has no parameters.|A `get` accessor of an indexer has the same formal parameter list as the indexer.| |A [set](../../language-reference/keywords/set.md) accessor of a property contains the implicit `value` parameter.|A `set` accessor of an indexer has the same formal parameter list as the indexer, and also to the [value](../../language-reference/keywords/value.md) parameter.| -|Supports shortened syntax with [Auto-Implemented Properties](../classes-and-structs/auto-implemented-properties.md).|Supports expression bodied members for get only indexers.| +|Supports shortened syntax with [Automatically implemented properties](../classes-and-structs/auto-implemented-properties.md).|Supports expression bodied members for get only indexers.| ## See also diff --git a/docs/csharp/programming-guide/indexers/index.md b/docs/csharp/programming-guide/indexers/index.md index 91b9b4bbb46d5..c663e77b2c0ee 100644 --- a/docs/csharp/programming-guide/indexers/index.md +++ b/docs/csharp/programming-guide/indexers/index.md @@ -33,7 +33,7 @@ Indexers enable *indexed* properties: properties referenced using one or more ar - Indexers can have one or more formal parameters, for example, when accessing a two-dimensional array. - You can declare [`partial` indexers](../../language-reference/keywords/partial-member.md) in [`partial` types](../../language-reference/keywords/partial-type.md). -You can apply almost everything you learned from working with properties to indexers. The only exception to that rule is *auto implemented properties*. The compiler can't always generate the correct storage for an indexer. You can define multiple indexers on a type, as long as the argument lists for each indexer is unique. +You can apply almost everything you learned from working with properties to indexers. The only exception to that rule is *automatically implemented properties*. The compiler can't always generate the correct storage for an indexer. You can define multiple indexers on a type, as long as the argument lists for each indexer is unique. ## Uses of indexers diff --git a/docs/csharp/roslyn-sdk/index.md b/docs/csharp/roslyn-sdk/index.md index 60f376bb252f2..ce52af2d1b1ea 100644 --- a/docs/csharp/roslyn-sdk/index.md +++ b/docs/csharp/roslyn-sdk/index.md @@ -1,10 +1,9 @@ --- title: The .NET Compiler Platform SDK (Roslyn APIs) description: Learn to use the .NET Compiler Platform SDK (also called the Roslyn APIs) to understand .NET code, spot errors, and fix those errors. -ms.date: 10/10/2017 +ms.date: 10/25/2024 ms.custom: mvc --- - # The .NET Compiler Platform SDK Compilers build a detailed model of application code as they validate the @@ -119,6 +118,14 @@ learn accepted practices quickly and become productive earlier in their .NET journey. As these become more widely used, the community adopts these practices. +## Source generators + +Source generators aim to enable *compile time metaprogramming*, that is, code that can be created +at compile time and added to the compilation. Source generators are able to read the contents of +the compilation before running, as well as access any *additional files*. This ability enables them to +introspect both user C# code and generator-specific files. You can learn how to build incremental +source generators using the [source generator cookbook](https://github.com/dotnet/roslyn/blob/main/docs/features/incremental-generators.cookbook.md). + ## Next steps The .NET Compiler Platform SDK includes the latest language object models diff --git a/docs/csharp/roslyn-sdk/media/source-generators/solution-explorer-program.png b/docs/csharp/roslyn-sdk/media/source-generators/solution-explorer-program.png deleted file mode 100644 index c9cd75b1a719f..0000000000000 Binary files a/docs/csharp/roslyn-sdk/media/source-generators/solution-explorer-program.png and /dev/null differ diff --git a/docs/csharp/roslyn-sdk/media/source-generators/source-generated-program.png b/docs/csharp/roslyn-sdk/media/source-generators/source-generated-program.png deleted file mode 100644 index c47a815dda395..0000000000000 Binary files a/docs/csharp/roslyn-sdk/media/source-generators/source-generated-program.png and /dev/null differ diff --git a/docs/csharp/roslyn-sdk/media/source-generators/source-generator-visualization.png b/docs/csharp/roslyn-sdk/media/source-generators/source-generator-visualization.png deleted file mode 100644 index 8e658d8e373f5..0000000000000 Binary files a/docs/csharp/roslyn-sdk/media/source-generators/source-generator-visualization.png and /dev/null differ diff --git a/docs/csharp/roslyn-sdk/snippets/source-generators/ConsoleApp/ConsoleApp.csproj b/docs/csharp/roslyn-sdk/snippets/source-generators/ConsoleApp/ConsoleApp.csproj deleted file mode 100644 index f31e94b628d5b..0000000000000 --- a/docs/csharp/roslyn-sdk/snippets/source-generators/ConsoleApp/ConsoleApp.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - - - - - diff --git a/docs/csharp/roslyn-sdk/snippets/source-generators/ConsoleApp/Program.cs b/docs/csharp/roslyn-sdk/snippets/source-generators/ConsoleApp/Program.cs deleted file mode 100644 index d63f6f117d3b6..0000000000000 --- a/docs/csharp/roslyn-sdk/snippets/source-generators/ConsoleApp/Program.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace ConsoleApp; - -partial class Program -{ - static void Main(string[] args) - { - HelloFrom("Generated Code"); - } - - static partial void HelloFrom(string name); -} diff --git a/docs/csharp/roslyn-sdk/snippets/source-generators/SourceGenerator/HelloSourceGenerator.cs b/docs/csharp/roslyn-sdk/snippets/source-generators/SourceGenerator/HelloSourceGenerator.cs deleted file mode 100644 index fc0f44ade0e1a..0000000000000 --- a/docs/csharp/roslyn-sdk/snippets/source-generators/SourceGenerator/HelloSourceGenerator.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.CodeAnalysis; - -namespace SourceGenerator -{ - [Generator] - public class HelloSourceGenerator : ISourceGenerator - { - public void Execute(GeneratorExecutionContext context) - { - // Find the main method - var mainMethod = context.Compilation.GetEntryPoint(context.CancellationToken); - - // Build up the source code - string source = $@"// -using System; - -namespace {mainMethod.ContainingNamespace.ToDisplayString()} -{{ - public static partial class {mainMethod.ContainingType.Name} - {{ - static partial void HelloFrom(string name) => - Console.WriteLine($""Generator says: Hi from '{{name}}'""); - }} -}} -"; - var typeName = mainMethod.ContainingType.Name; - - // Add the source code to the compilation - context.AddSource($"{typeName}.g.cs", source); - } - - public void Initialize(GeneratorInitializationContext context) - { - // No initialization required for this one - } - } -} diff --git a/docs/csharp/roslyn-sdk/snippets/source-generators/SourceGenerator/SourceGenerator.csproj b/docs/csharp/roslyn-sdk/snippets/source-generators/SourceGenerator/SourceGenerator.csproj deleted file mode 100644 index d80e9be5f89a3..0000000000000 --- a/docs/csharp/roslyn-sdk/snippets/source-generators/SourceGenerator/SourceGenerator.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - netstandard2.0 - - - - - - - - diff --git a/docs/csharp/roslyn-sdk/snippets/source-generators/source-generators.sln b/docs/csharp/roslyn-sdk/snippets/source-generators/source-generators.sln deleted file mode 100644 index 684eca4f107d0..0000000000000 --- a/docs/csharp/roslyn-sdk/snippets/source-generators/source-generators.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.32002.185 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp", "ConsoleApp\ConsoleApp.csproj", "{B0A361D0-D9D7-4E39-AFC1-189121AAC9CE}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceGenerator", "SourceGenerator\SourceGenerator.csproj", "{7CB852F5-F320-41AF-B1AC-4CDBD61FEB17}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B0A361D0-D9D7-4E39-AFC1-189121AAC9CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B0A361D0-D9D7-4E39-AFC1-189121AAC9CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B0A361D0-D9D7-4E39-AFC1-189121AAC9CE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B0A361D0-D9D7-4E39-AFC1-189121AAC9CE}.Release|Any CPU.Build.0 = Release|Any CPU - {7CB852F5-F320-41AF-B1AC-4CDBD61FEB17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7CB852F5-F320-41AF-B1AC-4CDBD61FEB17}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7CB852F5-F320-41AF-B1AC-4CDBD61FEB17}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7CB852F5-F320-41AF-B1AC-4CDBD61FEB17}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {8483CBEE-3CD5-4416-96BF-D457893183B6} - EndGlobalSection -EndGlobal diff --git a/docs/csharp/roslyn-sdk/source-generators-overview.md b/docs/csharp/roslyn-sdk/source-generators-overview.md deleted file mode 100644 index e1478e014002e..0000000000000 --- a/docs/csharp/roslyn-sdk/source-generators-overview.md +++ /dev/null @@ -1,149 +0,0 @@ ---- -title: Source Generators -description: Source Generators is a C# compiler feature that lets C# developers inspect user code as it is being compiled. Source generators create new C# source files on the fly that are added to the user's compilation. -ms.date: 03/02/2022 -ms.topic: tutorial -ms.custom: mvc, vs-dotnet, source-generators ---- - -# Source Generators - -This article provides an overview of Source Generators that ships as part of the .NET Compiler Platform ("Roslyn") SDK. Source Generators let C# developers inspect user code as it is being compiled. The generator can create new C# source files on the fly that are added to the user's compilation. In this way, you have code that runs during compilation. It inspects your program to produce additional source files that are compiled together with the rest of your code. - -A Source Generator is a new kind of component that C# developers can write that lets you do two major things: - -1. Retrieve a *compilation object* that represents all user code that is being compiled. This object can be inspected, and you can write code that works with the syntax and semantic models for the code being compiled, just like with analyzers today. - -1. Generate C# source files that can be added to a compilation object during compilation. In other words, you can provide additional source code as input to a compilation while the code is being compiled. - -When combined, these two things are what make Source Generators so useful. You can inspect user code with all of the rich metadata that the compiler builds up during compilation. Your generator then emits C# code back into the same compilation that is based on the data you've analyzed. If you're familiar with Roslyn Analyzers, you can think of Source Generators as analyzers that can emit C# source code. - -Source generators run as a phase of compilation visualized below: - -:::image type="content" source="media/source-generators/source-generator-visualization.png" lightbox="media/source-generators/source-generator-visualization.png" alt-text="Graphic describing the different parts of source generation"::: - -A Source Generator is a .NET Standard 2.0 assembly that is loaded by the compiler along with any analyzers. It's usable in environments where .NET Standard components can be loaded and run. - -> [!IMPORTANT] -> Currently only .NET Standard 2.0 assemblies can be used as Source Generators. - -## Common scenarios - -There are three general approaches to inspecting user code and generating information or code based on that analysis used by technologies today: - -- Runtime reflection. -- Juggling MSBuild tasks. -- Intermediate Language (IL) weaving (not discussed in this article). - -Source Generators can be an improvement over each approach. - -### Runtime reflection - -Runtime reflection is a powerful technology that was added to .NET a long time ago. There are countless scenarios for using it. A common scenario is to perform some analysis of user code when an app starts up and use that data to generate things. - -For example, ASP.NET Core uses reflection when your web service first runs to discover constructs you've defined so that it can "wire up" things like controllers and razor pages. Although this enables you to write straightforward code with powerful abstractions, it comes with a performance penalty at run time: when your web service or app first starts up, it can’t accept any requests until all the runtime reflection code that discovers information about your code is finished running. Although this performance penalty isn't enormous, it's somewhat of a fixed cost that you can’t improve yourself in your own app. - -With a Source Generator, the controller discovery phase of startup could instead happen at compile time. A generator can analyze your source code and emit the code it needs to "wire up" your app. Using source generators could result in some faster startup times, since an action happening at run time today could get pushed into compile time. - -### Juggling MSBuild tasks - -Source Generators can improve performance in ways that aren't limited to reflection at run time to discover types as well. Some scenarios involve calling the MSBuild C# task (called CSC) multiple times so they can inspect data from a compilation. As you might imagine, calling the compiler more than once affects the total time it takes to build your app. We're investigating how Source Generators can be used to obviate the need for juggling MSBuild tasks like this, since Source generators don't just offer some performance benefits, but also allows tools to operate at the right level of abstraction. - -Another capability Source Generators can offer is obviating the use of some "strongly typed" APIs, such as how ASP.NET Core routing between controllers and razor pages work. With a Source Generator, routing can be strongly typed with the necessary strings being generated as a compile-time detail. This would reduce the number of times a mistyped string literal leads to a request not hitting the correct controller. - -## Get started with source generators - -In this guide, you'll explore the creation of a source generator using the API. - -1. Create a .NET console application. This example uses .NET 6. - -1. Replace the `Program` class with the following code. The following code doesn't use top level statements. The classic form is required because this first source generator writes a partial method in that `Program` class: - - :::code source="snippets/source-generators/ConsoleApp/Program.cs"::: - - > [!NOTE] - > You can run this sample as-is, but nothing will happen yet. - -1. Next, we'll create a source generator project that will implement the `partial void HelloFrom` method counterpart. - -1. Create a .NET standard library project that targets the `netstandard2.0` target framework moniker (TFM). Add the NuGet packages *Microsoft.CodeAnalysis.Analyzers* and *Microsoft.CodeAnalysis.CSharp*: - - :::code language="xml" source="snippets/source-generators/SourceGenerator/SourceGenerator.csproj"::: - - > [!TIP] - > The source generator project should typically target the `netstandard2.0` TFM, as to support their consumption within .NET Framework environments including the Visual Studio IDE and MSBuild CLI. - -1. Create a new C# file named _HelloSourceGenerator.cs_ that specifies your own Source Generator like so: - - ```csharp - using Microsoft.CodeAnalysis; - - namespace SourceGenerator - { - [Generator] - public class HelloSourceGenerator : ISourceGenerator - { - public void Execute(GeneratorExecutionContext context) - { - // Code generation goes here - } - - public void Initialize(GeneratorInitializationContext context) - { - // No initialization required for this one - } - } - } - ``` - - A source generator needs to both implement the interface, and have the . Not all source generators require initialization, and that is the case with this example implementation—where is empty. - -1. Replace the contents of the method, with the following implementation: - - :::code source="snippets/source-generators/SourceGenerator/HelloSourceGenerator.cs"::: - - From the `context` object we can access the compilations' entry point, or `Main` method. The `mainMethod` instance is an , and it represents a method or method-like symbol (including constructor, destructor, operator, or property/event accessor). The method returns the for the program's entry point. Other methods enable you to find any method symbol in a project. From this object, we can reason about the containing namespace (if one is present) and the type. The `source` in this example is an interpolated string that templates the source code to be generated, where the interpolated holes are filled with the containing namespace and type information. The `source` is added to the `context` with a hint name. For this example, the generator creates a new generated source file that contains an implementation of the `partial` method in the console application. You can write source generators to add any source you'd like. - - > [!TIP] - > The `hintName` parameter from the method can be any unique name. It's common to provide an explicit C# file extension such as `".g.cs"` or `".generated.cs"` for the name. The file name helps identify the file as being source generated. - -1. We now have a functioning generator, but need to connect it to our console application. Edit the original console application project and add the following, replacing the project path with the one from the .NET Standard project you created above: - - ```xml - - - - - ``` - - This new reference isn't a traditional project reference, and has to be manually edited to include the `OutputItemType` and `ReferenceOutputAssembly` attributes. For more information on the `OutputItemType` and `ReferenceOutputAssembly` attributes of `ProjectReference`, see [Common MSBuild project items: ProjectReference](/visualstudio/msbuild/common-msbuild-project-items#projectreference). - -1. Now, when you run the console application, you should see that the generated code gets run and prints to the screen. The console application itself doesn't implement the `HelloFrom` method, instead it's source generated during compilation from the Source Generator project. The following text is an example output from the application: - - ```console - Generator says: Hi from 'Generated Code' - ``` - - > [!NOTE] - > You might need to restart Visual Studio to see IntelliSense and get rid of errors as the tooling experience is actively being improved. - -1. If you're using Visual Studio, you can see the source generated files. From the **Solution Explorer** window, expand the **Dependencies** > **Analyzers** > **SourceGenerator** > **SourceGenerator.HelloSourceGenerator**, and double-click the _Program.g.cs_ file. - - :::image type="content" source="media/source-generators/solution-explorer-program.png" lightbox="media/source-generators/solution-explorer-program.png" alt-text="Visual Studio: Solution Explorer source generated files."::: - - When you open this generated file, Visual Studio will indicate that the file is auto-generated and that it can't be edited. - - :::image type="content" source="media/source-generators/source-generated-program.png" lightbox="media/source-generators/source-generated-program.png" alt-text="Visual Studio: Auto-generated Program.g.cs file."::: - -1. You can also set build properties to save the generated file and control where the generated files are stored. In the console application's project file, add the `` element to a ``, and set its value to `true`. Build your project again. Now, the generated files are created under *obj/Debug/net6.0/generated/SourceGenerator/SourceGenerator.HelloSourceGenerator*. The components of the path map to the build configuration, target framework, source generator project name, and fully qualified type name of the generator. You can choose a more convenient output folder by adding the `` element to the application's project file. - -## Next steps - -The [Source Generators Cookbook](https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md) goes over some of these examples with some recommended approaches to solving them. Additionally, we have a [set of samples available on GitHub](https://github.com/dotnet/roslyn-sdk/tree/main/samples/CSharp/SourceGenerators) that you can try on your own. - -You can learn more about Source Generators in these articles: - -- [Source Generators design document](https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.md) -- [Source Generators cookbook](https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md) diff --git a/docs/csharp/toc.yml b/docs/csharp/toc.yml index 7ac5077f9d48e..f5bfd4d674be0 100644 --- a/docs/csharp/toc.yml +++ b/docs/csharp/toc.yml @@ -418,8 +418,6 @@ items: href: roslyn-sdk/work-with-workspace.md - name: Explore code with the syntax visualizer href: roslyn-sdk/syntax-visualizer.md - - name: Source Generators - href: roslyn-sdk/source-generators-overview.md - name: Choose diagnostic IDs href: roslyn-sdk/choosing-diagnostic-ids.md - name: Quick starts @@ -547,9 +545,9 @@ items: href: programming-guide/classes-and-structs/restricting-accessor-accessibility.md - name: "How to declare and use read write properties" href: programming-guide/classes-and-structs/how-to-declare-and-use-read-write-properties.md - - name: Auto-Implemented Properties + - name: Automatically implemented properties href: programming-guide/classes-and-structs/auto-implemented-properties.md - - name: "How to implement a lightweight class with auto-implemented properties" + - name: "How to implement a lightweight class with automatically implemented properties" href: programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md - name: Methods items: diff --git a/docs/csharp/whats-new/csharp-version-history.md b/docs/csharp/whats-new/csharp-version-history.md index e9b77d444bc41..862053352cd95 100644 --- a/docs/csharp/whats-new/csharp-version-history.md +++ b/docs/csharp/whats-new/csharp-version-history.md @@ -220,7 +220,7 @@ The following enhancements were made to existing features: - You can test `==` and `!=` with tuple types. - You can use expression variables in more locations. -- You can attach attributes to the backing field of auto-implemented properties. +- You can attach attributes to the backing field of automatically implemented properties. - Method resolution when arguments differ by `in` was improved. - Overload resolution now has fewer ambiguous cases. diff --git a/docs/fsharp/language-reference/members/explicit-fields-the-val-keyword.md b/docs/fsharp/language-reference/members/explicit-fields-the-val-keyword.md index a9fe5c7666982..52c2c9f1944ac 100644 --- a/docs/fsharp/language-reference/members/explicit-fields-the-val-keyword.md +++ b/docs/fsharp/language-reference/members/explicit-fields-the-val-keyword.md @@ -5,7 +5,7 @@ ms.date: 08/15/2020 --- # Explicit Fields: The val Keyword -The `val` keyword is used to declare a location to store a value in a class or structure type, without initializing it. Storage locations declared in this manner are called *explicit fields*. Another use of the `val` keyword is in conjunction with the `member` keyword to declare an auto-implemented property. For more information on auto-implemented properties, see [Properties](properties.md). +The `val` keyword is used to declare a location to store a value in a class or structure type, without initializing it. Storage locations declared in this manner are called *explicit fields*. Another use of the `val` keyword is in conjunction with the `member` keyword to declare an automatically implemented property. For more information on automatically implemented properties, see [Properties](properties.md). ## Syntax diff --git a/docs/fundamentals/code-analysis/style-rules/ide0032.md b/docs/fundamentals/code-analysis/style-rules/ide0032.md index 9d468917b3fcc..2a9ee2bad42d4 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0032.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0032.md @@ -28,7 +28,7 @@ dev_langs: ## Overview -This style rule concerns the use of [auto-implemented properties](../../../csharp/programming-guide/classes-and-structs/auto-implemented-properties.md) versus properties with private backing fields. +This style rule concerns the use of [automatically implemented properties](../../../csharp/programming-guide/classes-and-structs/auto-implemented-properties.md) versus properties with private backing fields. ## Options @@ -39,7 +39,7 @@ Options specify the behavior that you want the rule to enforce. For information | Property | Value | Description | |--------------------------|-------------------------------------|-----------------------------------------------| | **Option name** | dotnet_style_prefer_auto_properties | | -| **Option values** | `true` | Prefer auto-implemented properties | +| **Option values** | `true` | Prefer automatically implemented properties | | | `false` | Prefer properties with private backing fields | | **Default option value** | `true` | | diff --git a/docs/standard/base-types/regular-expression-source-generators.md b/docs/standard/base-types/regular-expression-source-generators.md index 227df9c676878..4a2ee61dbf1c7 100644 --- a/docs/standard/base-types/regular-expression-source-generators.md +++ b/docs/standard/base-types/regular-expression-source-generators.md @@ -687,5 +687,5 @@ When used with an option like `RegexOptions.NonBacktracking` for which the sourc - [.NET regular expressions](regular-expressions.md) - [Backtracking in regular expressions](backtracking-in-regular-expressions.md) - [Compilation and reuse in regular expressions](compilation-and-reuse-in-regular-expressions.md) -- [Source generators](../../csharp/roslyn-sdk/source-generators-overview.md) +- [Source generators](../../csharp/roslyn-sdk/index.md#source-generators) - [.NET Blog: Regular Expression improvements in .NET 7](https://devblogs.microsoft.com/dotnet/regular-expression-improvements-in-dotnet-7) diff --git a/docs/standard/native-interop/pinvoke-source-generation.md b/docs/standard/native-interop/pinvoke-source-generation.md index 23e10740775ed..35c051e5d2596 100644 --- a/docs/standard/native-interop/pinvoke-source-generation.md +++ b/docs/standard/native-interop/pinvoke-source-generation.md @@ -6,7 +6,7 @@ ms.date: 07/25/2022 # Source generation for platform invokes -.NET 7 introduces a [source generator](../../csharp/roslyn-sdk/source-generators-overview.md) for P/Invokes that recognizes the in C# code. +.NET 7 introduces a [source generator](../../csharp/roslyn-sdk/index.md#source-generators) for P/Invokes that recognizes the in C# code. When it's not using source generation, the built-in interop system in the .NET runtime generates an IL stub—a stream of IL instructions that is JIT-ed—at run time to facilitate the transition from managed to unmanaged. The following code shows defining and then calling a P/Invoke that uses this mechanism: diff --git a/docs/standard/serialization/binaryformatter-migration-guide/functionality-reference.md b/docs/standard/serialization/binaryformatter-migration-guide/functionality-reference.md index 817cb923b350e..25a4e5374997a 100644 --- a/docs/standard/serialization/binaryformatter-migration-guide/functionality-reference.md +++ b/docs/standard/serialization/binaryformatter-migration-guide/functionality-reference.md @@ -24,7 +24,7 @@ In most common scenario, the type is annotated with `[Serializable]` and the ser ### C# auto properties -For C# [auto-implemented properties](../../../csharp/programming-guide/classes-and-structs/auto-implemented-properties.md) (`{ get; set; }`), BinaryFormatter will serialize the backing fields that are generated by the C# compiler, not the properties. The names of those serialized backing fields contain illegal C# characters and cannot be controlled. A C# decompiler (such as [https://sharplab.io/](https://sharplab.io/) or [ILSpy](https://github.com/icsharpcode/ILSpy)) can demonstrate how C# auto properties are presented to the runtime. +For C# [automatically implemented properties](../../../csharp/programming-guide/classes-and-structs/auto-implemented-properties.md) (`{ get; set; }`), BinaryFormatter will serialize the backing fields that are generated by the C# compiler, not the properties. The names of those serialized backing fields contain illegal C# characters and cannot be controlled. A C# decompiler (such as [https://sharplab.io/](https://sharplab.io/) or [ILSpy](https://github.com/icsharpcode/ILSpy)) can demonstrate how C# auto properties are presented to the runtime. ```csharp [Serializable] diff --git a/docs/standard/serialization/system-text-json/overview.md b/docs/standard/serialization/system-text-json/overview.md index 6066a7f74e4ad..b4b28779ed549 100644 --- a/docs/standard/serialization/system-text-json/overview.md +++ b/docs/standard/serialization/system-text-json/overview.md @@ -61,7 +61,7 @@ There are also extension methods for System.Text.Json on [HttpContent](xref:Syst ## Reflection vs. source generation -By default, `System.Text.Json` gathers the metadata it needs to access properties of objects for serialization and deserialization *at run time* using [reflection](/dotnet/csharp/advanced-topics/reflection-and-attributes/). As an alternative, `System.Text.Json` can use the C# [source generation](../../../csharp/roslyn-sdk/source-generators-overview.md) feature to improve performance, reduce private memory usage, and facilitate [assembly trimming](../../../core/deploying/trimming/trim-self-contained.md), which reduces app size. +By default, `System.Text.Json` gathers the metadata it needs to access properties of objects for serialization and deserialization *at run time* using [reflection](/dotnet/csharp/advanced-topics/reflection-and-attributes/). As an alternative, `System.Text.Json` can use the C# [source generation](../../../csharp/roslyn-sdk/index.md#source-generators) feature to improve performance, reduce private memory usage, and facilitate [assembly trimming](../../../core/deploying/trimming/trim-self-contained.md), which reduces app size. For more information, see [Reflection versus source generation](reflection-vs-source-generation.md). diff --git a/docs/standard/serialization/system-text-json/reflection-vs-source-generation.md b/docs/standard/serialization/system-text-json/reflection-vs-source-generation.md index e7fa03c998aa1..bcd9dc3f3f10f 100644 --- a/docs/standard/serialization/system-text-json/reflection-vs-source-generation.md +++ b/docs/standard/serialization/system-text-json/reflection-vs-source-generation.md @@ -27,7 +27,7 @@ By default, collects metadata at run time ## Source generation -As an alternative, `System.Text.Json` can use the C# [source generation](../../../csharp/roslyn-sdk/source-generators-overview.md) feature to improve performance, reduce private memory usage, and facilitate [assembly trimming](../../../core/deploying/trimming/trim-self-contained.md), which reduces app size. In addition, certain reflection APIs can't be used in [Native AOT applications](../../../core/deploying/native-aot/index.md), so you must use source generation for those apps. +As an alternative, `System.Text.Json` can use the C# [source generation](../../../csharp/roslyn-sdk/index.md#source-generators) feature to improve performance, reduce private memory usage, and facilitate [assembly trimming](../../../core/deploying/trimming/trim-self-contained.md), which reduces app size. In addition, certain reflection APIs can't be used in [Native AOT applications](../../../core/deploying/native-aot/index.md), so you must use source generation for those apps. Source generation can be used in two modes: diff --git a/docs/visual-basic/language-reference/statements/property-statement.md b/docs/visual-basic/language-reference/statements/property-statement.md index 834e2002cd343..43fb00a482822 100644 --- a/docs/visual-basic/language-reference/statements/property-statement.md +++ b/docs/visual-basic/language-reference/statements/property-statement.md @@ -135,7 +135,7 @@ Property name ( [ parameterlist ] ) [ As returntype ] [ Implements implementslis - `Get` - Optional. Required if the property is marked `ReadOnly`. Starts a `Get` property procedure that is used to return the value of the property. The `Get` statement is not used with [auto-implemented properties](../../programming-guide/language-features/procedures/auto-implemented-properties.md). + Optional. Required if the property is marked `ReadOnly`. Starts a `Get` property procedure that is used to return the value of the property. The `Get` statement is not used with [automatically implemented properties](../../programming-guide/language-features/procedures/auto-implemented-properties.md). - `statements` @@ -147,7 +147,7 @@ Property name ( [ parameterlist ] ) [ As returntype ] [ Implements implementslis - `Set` - Optional. Required if the property is marked `WriteOnly`. Starts a `Set` property procedure that is used to store the value of the property. The `Set` statement is not used with [auto-implemented properties](../../programming-guide/language-features/procedures/auto-implemented-properties.md). + Optional. Required if the property is marked `WriteOnly`. Starts a `Set` property procedure that is used to store the value of the property. The `Set` statement is not used with [automatically implemented properties](../../programming-guide/language-features/procedures/auto-implemented-properties.md). - `End Set` @@ -159,7 +159,7 @@ Property name ( [ parameterlist ] ) [ As returntype ] [ Implements implementslis ## Remarks -The `Property` statement introduces the declaration of a property. A property can have a `Get` procedure (read only), a `Set` procedure (write only), or both (read-write). You can omit the `Get` and `Set` procedure when using an auto-implemented property. For more information, see [Auto-Implemented Properties](../../programming-guide/language-features/procedures/auto-implemented-properties.md). +The `Property` statement introduces the declaration of a property. A property can have a `Get` procedure (read only), a `Set` procedure (write only), or both (read-write). You can omit the `Get` and `Set` procedure when using an automatically implemented property. For more information, see [Automatically implemented properties](../../programming-guide/language-features/procedures/auto-implemented-properties.md). You can use `Property` only at class level. This means the *declaration context* for a property must be a class, structure, module, or interface, and cannot be a source file, namespace, procedure, or block. For more information, see [Declaration Contexts and Default Access Levels](declaration-contexts-and-default-access-levels.md). @@ -207,7 +207,7 @@ The following example declares a property in a class. ## See also -- [Auto-Implemented Properties](../../programming-guide/language-features/procedures/auto-implemented-properties.md) +- [Automatically implemented properties](../../programming-guide/language-features/procedures/auto-implemented-properties.md) - [Objects and Classes](../../programming-guide/language-features/objects-and-classes/index.md) - [Get Statement](get-statement.md) - [Set Statement](set-statement.md) diff --git a/docs/visual-basic/misc/bc36714.md b/docs/visual-basic/misc/bc36714.md index 4767eb884d561..bf161ba082d86 100644 --- a/docs/visual-basic/misc/bc36714.md +++ b/docs/visual-basic/misc/bc36714.md @@ -17,22 +17,22 @@ An auto-implemented property can be initialized as part of its declaration, but ## To correct this error -- Either use an auto-implemented property or remove the initialization from the property declaration. +- Either use an automatically implemented property or remove the initialization from the property declaration. ## Example - The following examples show both auto-implemented and expanded properties. Auto-implemented properties can be initialized by using assignment or a `New` clause, but expanded properties cannot be. + The following examples show both automatically implemented and expanded properties. Automatically implemented properties can be initialized by using assignment or a `New` clause, but expanded properties cannot be. ```vb Class AutoImplementedExample - ' An auto-implemented property can be assigned an initial value. + ' An automatically implemented property can be assigned an initial value. Property IDNum As Integer = 33542 - ' An auto-implemented property can be initialized with New. + ' An automatically implemented property can be initialized with New. Property Name As New String("Don Hall") End Class Class ExpandedExample - ' Attempting to expand an initialized auto-implemented property + ' Attempting to expand an initialized automatically implemented property ' causes this error. 'Property IDNum As Integer = 33542 ' Get @@ -54,6 +54,6 @@ End Class ## See also -- [Auto-Implemented Properties](../programming-guide/language-features/procedures/auto-implemented-properties.md) +- [Automatically implemented properties](../programming-guide/language-features/procedures/auto-implemented-properties.md) - [How to: Create a Property](../programming-guide/language-features/procedures/how-to-create-a-property.md) - [Property Procedures](../programming-guide/language-features/procedures/property-procedures.md) diff --git a/docs/visual-basic/programming-guide/com-interop/walkthrough-office-programming.md b/docs/visual-basic/programming-guide/com-interop/walkthrough-office-programming.md index 124f891ee5944..80e02902ffb3c 100644 --- a/docs/visual-basic/programming-guide/com-interop/walkthrough-office-programming.md +++ b/docs/visual-basic/programming-guide/com-interop/walkthrough-office-programming.md @@ -10,7 +10,7 @@ helpviewer_keywords: --- # Walkthrough: Office Programming in Visual Basic -Visual Studio offers features in Visual Basic that improve Microsoft Office programming. Features in Visual Basic include auto-implemented properties, statements in lambda expressions, and collection initializers. You can embed type information, which allows deployment of assemblies that interact with COM components without deploying primary interop assemblies (PIAs) to the user's computer. For more information, see [Walkthrough: Embedding Types from Managed Assemblies](../../../standard/assembly/embed-types-visual-studio.md). +Visual Studio offers features in Visual Basic that improve Microsoft Office programming. Features in Visual Basic include automatically implemented properties, statements in lambda expressions, and collection initializers. You can embed type information, which allows deployment of assemblies that interact with COM components without deploying primary interop assemblies (PIAs) to the user's computer. For more information, see [Walkthrough: Embedding Types from Managed Assemblies](../../../standard/assembly/embed-types-visual-studio.md). This walkthrough demonstrates these features in the context of Office programming, but many of these features are also useful in general programming. In the walkthrough, you use an Excel Add-in application to create an Excel workbook. Next, you create a Word document that contains a link to the workbook. Finally, you see how to enable and disable the PIA dependency. @@ -58,7 +58,7 @@ You must have Microsoft Office Excel and Microsoft Office Word installed on your 1. In **Solution Explorer**, right-click your project's name, click **Add**, and then click **Class**. Name the class Account.vb. Click **Add**. -2. Replace the definition of the `Account` class with the following code. The class definitions use *auto-implemented properties*. For more information, see [Auto-Implemented Properties](../../../visual-basic/programming-guide/language-features/procedures/auto-implemented-properties.md). +2. Replace the definition of the `Account` class with the following code. The class definitions use *automatically implemented properties*. For more information, see [Automatically implemented properties](../../../visual-basic/programming-guide/language-features/procedures/auto-implemented-properties.md). [!code-vb[csOfficeWalkthrough#2](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/csofficewalkthrough/vb/account.vb#2)] @@ -139,7 +139,7 @@ You must have Microsoft Office Excel and Microsoft Office Word installed on your ## See also -- [Auto-Implemented Properties (Visual Basic)](../language-features/procedures/auto-implemented-properties.md) +- [Automatically implemented properties (Visual Basic)](../language-features/procedures/auto-implemented-properties.md) - [Collection Initializers](../language-features/collection-initializers/index.md) - [Optional Parameters](../language-features/procedures/optional-parameters.md) - [Passing Arguments by Position and by Name](../language-features/procedures/passing-arguments-by-position-and-by-name.md) diff --git a/docs/visual-basic/programming-guide/concepts/object-oriented-programming.md b/docs/visual-basic/programming-guide/concepts/object-oriented-programming.md index cef4a2354a229..8d86088a2f8cc 100644 --- a/docs/visual-basic/programming-guide/concepts/object-oriented-programming.md +++ b/docs/visual-basic/programming-guide/concepts/object-oriented-programming.md @@ -77,9 +77,9 @@ End Class Properties have get and set procedures, which provide more control on how values are set or returned. -Visual Basic allows you either to create a private field for storing the property value or use so-called auto-implemented properties that create this field automatically behind the scenes and provide the basic logic for the property procedures. +Visual Basic allows you either to create a private field for storing the property value or use so-called automatically implemented properties that create this field automatically behind the scenes and provide the basic logic for the property procedures. -To define an auto-implemented property: +To define an automatically implemented property: ```vb Class SampleClass @@ -105,7 +105,7 @@ Class SampleClass End Class ``` -Most properties have methods or procedures to both set and get the property value. However, you can create read-only or write-only properties to restrict them from being modified or read. In Visual Basic you can use `ReadOnly` and `WriteOnly` keywords. However, auto-implemented properties cannot be read-only or write-only. +Most properties have methods or procedures to both set and get the property value. However, you can create read-only or write-only properties to restrict them from being modified or read. In Visual Basic you can use `ReadOnly` and `WriteOnly` keywords. However, automatically implemented properties cannot be read-only or write-only. For more information, see: diff --git a/docs/visual-basic/programming-guide/language-features/collection-initializers/index.md b/docs/visual-basic/programming-guide/language-features/collection-initializers/index.md index 4ed132b036377..b67aaf76ca3e0 100644 --- a/docs/visual-basic/programming-guide/language-features/collection-initializers/index.md +++ b/docs/visual-basic/programming-guide/language-features/collection-initializers/index.md @@ -82,7 +82,7 @@ Only nested value lists from the first level of nesting are sent to the `Add` me - [Arrays](../arrays/index.md) - [Object Initializers: Named and Anonymous Types](../objects-and-classes/object-initializers-named-and-anonymous-types.md) - [New Operator](../../../language-reference/operators/new-operator.md) -- [Auto-Implemented Properties](../procedures/auto-implemented-properties.md) +- [Automatically implemented properties](../procedures/auto-implemented-properties.md) - [How to: Initialize an Array Variable in Visual Basic](../arrays/how-to-initialize-an-array-variable.md) - [Local Type Inference](../variables/local-type-inference.md) - [Anonymous Types](../objects-and-classes/anonymous-types.md) diff --git a/docs/visual-basic/programming-guide/language-features/procedures/auto-implemented-properties.md b/docs/visual-basic/programming-guide/language-features/procedures/auto-implemented-properties.md index b8a27269f9200..28e0a67dd0289 100644 --- a/docs/visual-basic/programming-guide/language-features/procedures/auto-implemented-properties.md +++ b/docs/visual-basic/programming-guide/language-features/procedures/auto-implemented-properties.md @@ -1,6 +1,6 @@ --- -description: "Learn more about: Auto-Implemented Properties (Visual Basic)" -title: "Auto-Implemented Properties" +description: "Learn more about: Automatically implemented properties (Visual Basic)" +title: "Automatically implemented properties" ms.date: 07/20/2015 f1_keywords: - "vb.AutoProperty" @@ -10,19 +10,19 @@ helpviewer_keywords: - "auto-implemented properties [Visual Basic]" ms.assetid: 5c669f0b-cf95-4b4e-ae84-9cc55212ca87 --- -# Auto-Implemented Properties (Visual Basic) +# Automatically implemented properties (Visual Basic) -*Auto-implemented properties* enable you to quickly specify a property of a class without having to write code to `Get` and `Set` the property. When you write code for an auto-implemented property, the Visual Basic compiler automatically creates a private field to store the property variable in addition to creating the associated `Get` and `Set` procedures. +*Automatically implemented properties* enable you to quickly specify a property of a class without having to write code to `Get` and `Set` the property. When you write code for an automatically implemented property, the Visual Basic compiler automatically creates a private field to store the property variable in addition to creating the associated `Get` and `Set` procedures. - With auto-implemented properties, a property, including a default value, can be declared in a single line. The following example shows three property declarations. + With automatically implemented properties, a property, including a default value, can be declared in a single line. The following example shows three property declarations. [!code-vb[VbVbalrAutoImplementedProperties#1](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/vbvbalrautoimplementedproperties/vb/module1.vb#1)] - An auto-implemented property is equivalent to a property for which the property value is stored in a private field. The following code example shows an auto-implemented property. + An automatically implemented property is equivalent to a property for which the property value is stored in a private field. The following code example shows an automatically implemented property. [!code-vb[VbVbalrAutoImplementedProperties#5](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/vbvbalrautoimplementedproperties/vb/module1.vb#5)] - The following code example shows the equivalent code for the previous auto-implemented property example. + The following code example shows the equivalent code for the previous automatically implemented property example. [!code-vb[VbVbalrAutoImplementedProperties#2](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/vbvbalrautoimplementedproperties/vb/module1.vb#2)] @@ -44,7 +44,7 @@ End Class ## Backing Field - When you declare an auto-implemented property, Visual Basic automatically creates a hidden private field called the *backing field* to contain the property value. The backing field name is the auto-implemented property name preceded by an underscore (_). For example, if you declare an auto-implemented property named `ID`, the backing field is named `_ID`. If you include a member of your class that is also named `_ID`, you produce a naming conflict and Visual Basic reports a compiler error. + When you declare an automatically implemented property, Visual Basic automatically creates a hidden private field called the *backing field* to contain the property value. The backing field name is the automatically implemented property name preceded by an underscore (_). For example, if you declare an automatically implemented property named `ID`, the backing field is named `_ID`. If you include a member of your class that is also named `_ID`, you produce a naming conflict and Visual Basic reports a compiler error. The backing field also has the following characteristics: @@ -56,23 +56,23 @@ End Class - The backing field can be accessed from code within the class and from debugging tools such as the Watch window. However, the backing field does not show in an IntelliSense word completion list. -## Initializing an Auto-Implemented Property +## Initializing an automatically implemented property - Any expression that can be used to initialize a field is valid for initializing an auto-implemented property. When you initialize an auto-implemented property, the expression is evaluated and passed to the `Set` procedure for the property. The following code examples show some auto-implemented properties that include initial values. + Any expression that can be used to initialize a field is valid for initializing an automatically implemented property. When you initialize an automatically implemented property, the expression is evaluated and passed to the `Set` procedure for the property. The following code examples show some automatically implemented properties that include initial values. [!code-vb[VbVbalrAutoImplementedProperties#3](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/vbvbalrautoimplementedproperties/vb/module1.vb#3)] - You cannot initialize an auto-implemented property that is a member of an `Interface`, or one that is marked `MustOverride`. + You cannot initialize an automatically implemented property that is a member of an `Interface`, or one that is marked `MustOverride`. - When you declare an auto-implemented property as a member of a `Structure`, you can only initialize the auto-implemented property if it is marked as `Shared`. + When you declare an automatically implemented property as a member of a `Structure`, you can only initialize the automatically implemented property if it is marked as `Shared`. - When you declare an auto-implemented property as an array, you cannot specify explicit array bounds. However, you can supply a value by using an array initializer, as shown in the following examples. + When you declare an automatically implemented property as an array, you cannot specify explicit array bounds. However, you can supply a value by using an array initializer, as shown in the following examples. [!code-vb[VbVbalrAutoImplementedProperties#4](~/samples/snippets/visualbasic/VS_Snippets_VBCSharp/vbvbalrautoimplementedproperties/vb/module1.vb#4)] ## Property Definitions That Require Standard Syntax - Auto-implemented properties are convenient and support many programming scenarios. However, there are situations in which you cannot use an auto-implemented property and must instead use standard, or *expanded*, property syntax. + Automatically implemented properties are convenient and support many programming scenarios. However, there are situations in which you cannot use an automatically implemented property and must instead use standard, or *expanded*, property syntax. You have to use expanded property-definition syntax if you want to do any one of the following: @@ -88,9 +88,9 @@ End Class - Provide XML comments for the backing field. -## Expanding an Auto-Implemented Property +## Expanding an automatically implemented property - If you have to convert an auto-implemented property to an expanded property that contains a `Get` or `Set` procedure, the Visual Basic Code Editor can automatically generate the `Get` and `Set` procedures and `End Property` statement for the property. The code is generated if you put the cursor on a blank line following the `Property` statement, type a `G` (for `Get`) or an `S` (for `Set`) and press ENTER. The Visual Basic Code Editor automatically generates the `Get` or `Set` procedure for read-only and write-only properties when you press ENTER at the end of a `Property` statement. + If you have to convert an automatically implemented property to an expanded property that contains a `Get` or `Set` procedure, the Visual Basic Code Editor can automatically generate the `Get` and `Set` procedures and `End Property` statement for the property. The code is generated if you put the cursor on a blank line following the `Property` statement, type a `G` (for `Get`) or an `S` (for `Set`) and press ENTER. The Visual Basic Code Editor automatically generates the `Get` or `Set` procedure for read-only and write-only properties when you press ENTER at the end of a `Property` statement. ## See also diff --git a/docs/visual-basic/programming-guide/language-features/procedures/property-procedures.md b/docs/visual-basic/programming-guide/language-features/procedures/property-procedures.md index d49683be1f6aa..aa7280813f6c7 100644 --- a/docs/visual-basic/programming-guide/language-features/procedures/property-procedures.md +++ b/docs/visual-basic/programming-guide/language-features/procedures/property-procedures.md @@ -26,7 +26,7 @@ Visual Basic provides for the following property procedures: You usually define property procedures in pairs, using the `Get` and `Set` statements, but you can define either procedure alone if the property is read-only ([Get Statement](../../../language-reference/statements/get-statement.md)) or write-only ([Set Statement](../../../language-reference/statements/set-statement.md)). -You can omit the `Get` and `Set` procedure when using an auto-implemented property. For more information, see [Auto-Implemented Properties](./auto-implemented-properties.md). +You can omit the `Get` and `Set` procedure when using an automatially implemented property. For more information, see [Automatically implemented properties](./auto-implemented-properties.md). You can define properties in classes, structures, and modules. Properties are `Public` by default, which means you can call them from anywhere in your application that can access the property's container. diff --git a/docs/visual-basic/programming-guide/language-features/procedures/toc.yml b/docs/visual-basic/programming-guide/language-features/procedures/toc.yml index 664f37a45b893..fa05a91b1c43b 100644 --- a/docs/visual-basic/programming-guide/language-features/procedures/toc.yml +++ b/docs/visual-basic/programming-guide/language-features/procedures/toc.yml @@ -22,7 +22,7 @@ - name: Property Procedures href: property-procedures.md items: - - name: Auto-Implemented Properties + - name: Automatically implemented properties href: auto-implemented-properties.md - name: Differences Between Properties and Variables href: differences-between-properties-and-variables.md diff --git a/docs/visual-basic/whats-new/index.md b/docs/visual-basic/whats-new/index.md index 718be0723b742..3125f56dc7a97 100644 --- a/docs/visual-basic/whats-new/index.md +++ b/docs/visual-basic/whats-new/index.md @@ -46,7 +46,7 @@ Visual Basic / Visual Studio 2012\ `Async` and `await` keywords, iterators, caller info attributes Visual Basic, Visual Studio 2010\ -Auto-implemented properties, collection initializers, implicit line continuation, dynamic, generic co/contra variance, global namespace access +Automatically implemented properties, collection initializers, implicit line continuation, dynamic, generic co/contra variance, global namespace access Visual Basic / Visual Studio 2008\ Language Integrated Query (LINQ), XML literals, local type inference, object initializers, anonymous types, extension methods, local `var` type inference, lambda expressions, `if` operator, partial methods, nullable value types diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideLINQ/CS/csRef30LangFeatures_2.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideLINQ/CS/csRef30LangFeatures_2.cs index f9846780024f8..a8647352ae8da 100644 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideLINQ/CS/csRef30LangFeatures_2.cs +++ b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideLINQ/CS/csRef30LangFeatures_2.cs @@ -309,7 +309,7 @@ class ObjInitializers // class Cat { - // Auto-implemented properties. + // Automatically implemented properties. public int Age { get; set; } public string Name { get; set; } } diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideStatements/CS/Statements.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideStatements/CS/Statements.cs index f9b4bace15b96..923b8397ceef6 100644 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideStatements/CS/Statements.cs +++ b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideStatements/CS/Statements.cs @@ -124,7 +124,7 @@ namespace ValueEquality using System; class TwoDPoint : IEquatable { - // Readonly auto-implemented properties. + // Readonly automatically implemented properties. public int X { get; private set; } public int Y { get; private set; } @@ -394,7 +394,7 @@ namespace ValueEqualityValueTypes using System; struct TwoDPoint : IEquatable { - // Read/write auto-implemented properties. + // Read/write automatically implemented properties. public int X { get; private set; } public int Y { get; private set; } diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csrefKeywordsModifiers/CS/csrefKeywordsModifiers.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csrefKeywordsModifiers/CS/csrefKeywordsModifiers.cs index 9e30e9cf65654..8b80452c63b19 100644 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csrefKeywordsModifiers/CS/csrefKeywordsModifiers.cs +++ b/samples/snippets/csharp/VS_Snippets_VBCSharp/csrefKeywordsModifiers/CS/csrefKeywordsModifiers.cs @@ -759,7 +759,7 @@ static void Main() // class MyBaseClass { - // virtual auto-implemented property. Overrides can only + // virtual automatically implemented property. Overrides can only // provide specialized behavior if they implement get and set accessors. public virtual string Name { get; set; } @@ -776,7 +776,7 @@ class MyDerivedClass : MyBaseClass { private string _name; - // Override auto-implemented property with ordinary property + // Override automatically implemented property with ordinary property // to provide specialized accessor behavior. public override string Name {