diff --git a/docfx.json b/docfx.json index 768b931909bda..03d7c34d95d1b 100644 --- a/docfx.json +++ b/docfx.json @@ -52,12 +52,7 @@ "csharp-10.0/*.md", "csharp-11.0/*.md", "csharp-12.0/*.md", - "lock-object.md", - "method-group-natural-type-improvements.md", - "overload-resolution-priority.md", - "params-collections.md", - "ref-struct-interfaces.md", - "ref-unsafe-in-iterators-async.md" + "csharp-13.0/*.md" ], "src": "_csharplang/proposals", "dest": "csharp/language-reference/proposals", @@ -661,13 +656,15 @@ "_csharplang/proposals/csharp-12.0/collection-expressions.md": "Collection expressions", "_csharplang/proposals/csharp-12.0/experimental-attribute.md": "Experimental attribute", "_csharplang/proposals/csharp-12.0/ref-readonly-parameters.md": "Ref readonly parameters", - "_csharplang/proposals/lock-object.md": "Obey lock object semantics for lock statements", - "_csharplang/proposals/method-group-natural-type-improvements.md": "Method group natural type improvements", - "_csharplang/proposals/params-collections.md": "Params collections", - "_csharplang/proposals/ref-unsafe-in-iterators-async.md": "Allow ref and unsafe in iterators and async methods", - "_csharplang/proposals/ref-struct-interfaces.md": "Allow ref struct types to implement some interfaces", - "_csharplang/proposals/partial-properties.md": "All partial properties and indexers", - "_csharplang/proposals/overload-resolution-priority.md": "Overload resolution priority tiebreaker attribute", + "_csharplang/proposals/csharp-13.0/collection-expressions-better-conversion.md": "Better conversion from collection expression", + "_csharplang/proposals/csharp-13.0/esc-escape-sequence.md": "String/Character escape sequence '\\e'", + "_csharplang/proposals/csharp-13.0/lock-object.md": "Obey lock object semantics for lock statements", + "_csharplang/proposals/csharp-13.0/method-group-natural-type-improvements.md": "Method group natural type improvements", + "_csharplang/proposals/csharp-13.0/params-collections.md": "Params collections", + "_csharplang/proposals/csharp-13.0/ref-unsafe-in-iterators-async.md": "Allow ref and unsafe in iterators and async methods", + "_csharplang/proposals/csharp-13.0/ref-struct-interfaces.md": "Allow ref struct types to implement some interfaces", + "_csharplang/proposals/csharp-13.0/partial-properties.md": "All partial properties and indexers", + "_csharplang/proposals/csharp-13.0/overload-resolution-priority.md": "Overload resolution priority tiebreaker attribute", "_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md": "C# compiler breaking changes since C# 10", "_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 8.md": "C# compiler breaking changes since C# 11", "_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md": "C# compiler breaking changes since C# 12", @@ -781,13 +778,15 @@ "_csharplang/proposals/csharp-12.0/collection-expressions.md": "Collection expressions provide a concise syntax to initialize collections by defining elements or embedded collections as the source of the new collection's elements.", "_csharplang/proposals/csharp-12.0/experimental-attribute.md": "Use the ExperimentalAttribute attribute to indicate APIs that aren't stable.", "_csharplang/proposals/csharp-12.0/ref-readonly-parameters.md": "Ref readonly parameters enforce that arguments are passed by references, where `in` parameters allow the compiler some flexibiility.", - "_csharplang/proposals/lock-object.md": "Special-case how `System.Threading.Lock` interacts with the `lock` keyword by calling its `EnterScope` method. Add static analysis warnings to prevent accidental misuse of the type where possible.", - "_csharplang/proposals/method-group-natural-type-improvements.md": "This proposal refines the determination of the natural type of a method group by considering candidates scope-by-scope and pruning at each scope.", - "_csharplang/proposals/params-collections.md": "Allow the `params` modifier on collection types beyond arrays, including `IEnumerable` types.", - "_csharplang/proposals/ref-unsafe-in-iterators-async.md": "This proposal modifies restrictions to enable ref local variables and unsafe blocks in iterators and async methods", - "_csharplang/proposals/ref-struct-interfaces.md": "This proposal provides features that enable interface authors to allow `ref struct` types to implement a particular interface", - "_csharplang/proposals/partial-properties.md": "This proposal provides for partial properties and indexers, allowing the definition of a property or indexer to be split across multiple parts.", - "_csharplang/proposals/overload-resolution-priority.md": "This proposal introduces a new attribute, `OverloadResolutionPriorityAttribute`, that can be applied to methods to influence overload resolution.", + "_csharplang/proposals/csharp-13.0/collection-expressions-better-conversion.md": "Conversions from collection expressions match the element type before matching the collection type.", + "_csharplang/proposals/csharp-13.0/esc-escape-sequence.md" : "The sequence '\\e' is now interpreted as the 'ESC' character, character point '0x1b'", + "_csharplang/proposals/csharp-13.0/lock-object.md": "Special-case how `System.Threading.Lock` interacts with the `lock` keyword by calling its `EnterScope` method. Add static analysis warnings to prevent accidental misuse of the type where possible.", + "_csharplang/proposals/csharp-13.0/method-group-natural-type-improvements.md": "This proposal refines the determination of the natural type of a method group by considering candidates scope-by-scope and pruning at each scope.", + "_csharplang/proposals/csharp-13.0/params-collections.md": "Allow the `params` modifier on collection types beyond arrays, including `IEnumerable` types.", + "_csharplang/proposals/csharp-13.0/ref-unsafe-in-iterators-async.md": "This proposal modifies restrictions to enable ref local variables and unsafe blocks in iterators and async methods", + "_csharplang/proposals/csharp-13.0/ref-struct-interfaces.md": "This proposal provides features that enable interface authors to allow `ref struct` types to implement a particular interface", + "_csharplang/proposals/csharp-13.0/partial-properties.md": "This proposal provides for partial properties and indexers, allowing the definition of a property or indexer to be split across multiple parts.", + "_csharplang/proposals/csharp-13.0/overload-resolution-priority.md": "This proposal introduces a new attribute, `OverloadResolutionPriorityAttribute`, that can be applied to methods to influence overload resolution.", "_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md": "Learn about any breaking changes since the initial release of C# 10", "_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 8.md": "Learn about any breaking changes since the initial release of C# 11", "_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md": "Learn about any breaking changes since the initial release of C# 12", diff --git a/docs/azure/includes/dotnet-all.md b/docs/azure/includes/dotnet-all.md index 853c2ca5d285f..db045cbb95d6f 100644 --- a/docs/azure/includes/dotnet-all.md +++ b/docs/azure/includes/dotnet-all.md @@ -166,7 +166,7 @@ | Resource Management - Azure AI Search | NuGet [1.2.3](https://www.nuget.org/packages/Azure.ResourceManager.Search/1.2.3)
NuGet [1.3.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.Search/1.3.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.Search-readme) | GitHub [1.2.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Search_1.2.3/sdk/search/Azure.ResourceManager.Search/)
GitHub [1.3.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Search_1.3.0-beta.3/sdk/search/Azure.ResourceManager.Search/) | | Resource Management - Azure Stack HCI | NuGet [1.2.0](https://www.nuget.org/packages/Azure.ResourceManager.Hci/1.2.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Hci-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Hci_1.2.0/sdk/azurestackhci/Azure.ResourceManager.Hci/) | | Resource Management - Azure VMware Solution | NuGet [1.3.0](https://www.nuget.org/packages/Azure.ResourceManager.Avs/1.3.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Avs-readme) | GitHub [1.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Avs_1.3.0/sdk/avs/Azure.ResourceManager.Avs/) | -| Resource Management - Batch | NuGet [1.4.0](https://www.nuget.org/packages/Azure.ResourceManager.Batch/1.4.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Batch-readme) | GitHub [1.4.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Batch_1.4.0/sdk/batch/Azure.ResourceManager.Batch/) | +| Resource Management - Batch | NuGet [1.5.0](https://www.nuget.org/packages/Azure.ResourceManager.Batch/1.5.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Batch-readme) | GitHub [1.5.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Batch_1.5.0/sdk/batch/Azure.ResourceManager.Batch/) | | Resource Management - Billing | NuGet [1.2.0](https://www.nuget.org/packages/Azure.ResourceManager.Billing/1.2.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Billing-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Billing_1.2.0/sdk/billing/Azure.ResourceManager.Billing/) | | Resource Management - Billing Benefits | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.BillingBenefits/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.BillingBenefits-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.BillingBenefits_1.0.0-beta.3/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/) | | Resource Management - Blueprint | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.Blueprint/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.Blueprint-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.Blueprint_1.0.0-beta.4/sdk/blueprint/Azure.ResourceManager.Blueprint/) | @@ -251,7 +251,7 @@ | Resource Management - Load Testing | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.LoadTesting/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.LoadTesting-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.LoadTesting_1.1.0/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/) | | Resource Management - Log Analytics | NuGet [1.2.2](https://www.nuget.org/packages/Azure.ResourceManager.OperationalInsights/1.2.2) | [docs](/dotnet/api/overview/azure/ResourceManager.OperationalInsights-readme) | GitHub [1.2.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.OperationalInsights_1.2.2/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/) | | Resource Management - Logic Apps | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.Logic/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Logic-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Logic_1.1.0/sdk/logic/Azure.ResourceManager.Logic/) | -| Resource Management - Machine Learning | NuGet [1.2.0](https://www.nuget.org/packages/Azure.ResourceManager.MachineLearning/1.2.0) | [docs](/dotnet/api/overview/azure/ResourceManager.MachineLearning-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.MachineLearning_1.2.0/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/) | +| Resource Management - Machine Learning | NuGet [1.2.1](https://www.nuget.org/packages/Azure.ResourceManager.MachineLearning/1.2.1) | [docs](/dotnet/api/overview/azure/ResourceManager.MachineLearning-readme) | GitHub [1.2.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.MachineLearning_1.2.1/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/) | | Resource Management - Machine Learning Compute | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.MachineLearningCompute/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.MachineLearningCompute-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.MachineLearningCompute_1.0.0-beta.4/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/) | | Resource Management - Maintenance | NuGet [1.1.2](https://www.nuget.org/packages/Azure.ResourceManager.Maintenance/1.1.2)
NuGet [1.2.0-beta.8](https://www.nuget.org/packages/Azure.ResourceManager.Maintenance/1.2.0-beta.8) | [docs](/dotnet/api/overview/azure/ResourceManager.Maintenance-readme) | GitHub [1.1.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Maintenance_1.1.2/sdk/maintenance/Azure.ResourceManager.Maintenance/)
GitHub [1.2.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Maintenance_1.2.0-beta.8/sdk/maintenance/Azure.ResourceManager.Maintenance/) | | Resource Management - Managed Grafana | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.Grafana/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Grafana-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Grafana_1.1.0/sdk/grafana/Azure.ResourceManager.Grafana/) | @@ -350,8 +350,8 @@ | Microsoft.Azure.DataFactoryTestingFramework.Expressions | NuGet [0.2.7](https://www.nuget.org/packages/Microsoft.Azure.DataFactoryTestingFramework.Expressions/0.2.7) | | | | Microsoft.Azure.Functions.Worker.OpenTelemetry | NuGet [1.0.0-preview1](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.OpenTelemetry/1.0.0-preview1) | | | | System Net Client Model | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/System.Net.ClientModel/1.0.0-beta.1) | | | -| Unknown Display Name | NuGet [0.0.3-dev-20240910-1](https://www.nuget.org/packages/Azure.AI.ContentSafety.Extension.Embedded.Image/0.0.3-dev-20240910-1) | | | -| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.ContentSafety.Extension.Embedded.Text/1.0.0)
NuGet [0.0.3-dev-20240910-1](https://www.nuget.org/packages/Azure.AI.ContentSafety.Extension.Embedded.Text/0.0.3-dev-20240910-1) | | | +| Unknown Display Name | NuGet [1.0.1-beta.1](https://www.nuget.org/packages/Azure.AI.ContentSafety.Extension.Embedded.Image/1.0.1-beta.1) | | | +| Unknown Display Name | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.ContentSafety.Extension.Embedded.Text/1.0.0)
NuGet [1.0.1-beta.1](https://www.nuget.org/packages/Azure.AI.ContentSafety.Extension.Embedded.Text/1.0.1-beta.1) | | | | Anomaly Detector | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.AnomalyDetector/1.0.0) | | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.CognitiveServices.AnomalyDetector_1.0.0-preview.1/sdk/cognitiveservices/AnomalyDetector) | | App Service | NuGet [0.2.2-alpha](https://www.nuget.org/packages/Microsoft.Azure.AppService/0.2.2-alpha) | | | | Application Insights | NuGet [0.9.0-preview](https://www.nuget.org/packages/Microsoft.Azure.ApplicationInsights/0.9.0-preview) | | | diff --git a/docs/azure/includes/dotnet-new.md b/docs/azure/includes/dotnet-new.md index 83525946b02a1..d8ce2bbefea01 100644 --- a/docs/azure/includes/dotnet-new.md +++ b/docs/azure/includes/dotnet-new.md @@ -171,7 +171,7 @@ | Resource Management - Azure AI Search | NuGet [1.2.3](https://www.nuget.org/packages/Azure.ResourceManager.Search/1.2.3)
NuGet [1.3.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.Search/1.3.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.Search-readme) | GitHub [1.2.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Search_1.2.3/sdk/search/Azure.ResourceManager.Search/)
GitHub [1.3.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Search_1.3.0-beta.3/sdk/search/Azure.ResourceManager.Search/) | | Resource Management - Azure Stack HCI | NuGet [1.2.0](https://www.nuget.org/packages/Azure.ResourceManager.Hci/1.2.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Hci-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Hci_1.2.0/sdk/azurestackhci/Azure.ResourceManager.Hci/) | | Resource Management - Azure VMware Solution | NuGet [1.3.0](https://www.nuget.org/packages/Azure.ResourceManager.Avs/1.3.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Avs-readme) | GitHub [1.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Avs_1.3.0/sdk/avs/Azure.ResourceManager.Avs/) | -| Resource Management - Batch | NuGet [1.4.0](https://www.nuget.org/packages/Azure.ResourceManager.Batch/1.4.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Batch-readme) | GitHub [1.4.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Batch_1.4.0/sdk/batch/Azure.ResourceManager.Batch/) | +| Resource Management - Batch | NuGet [1.5.0](https://www.nuget.org/packages/Azure.ResourceManager.Batch/1.5.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Batch-readme) | GitHub [1.5.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Batch_1.5.0/sdk/batch/Azure.ResourceManager.Batch/) | | Resource Management - Billing | NuGet [1.2.0](https://www.nuget.org/packages/Azure.ResourceManager.Billing/1.2.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Billing-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Billing_1.2.0/sdk/billing/Azure.ResourceManager.Billing/) | | Resource Management - Billing Benefits | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.BillingBenefits/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.BillingBenefits-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.BillingBenefits_1.0.0-beta.3/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/) | | Resource Management - Blueprint | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.Blueprint/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.Blueprint-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.Blueprint_1.0.0-beta.4/sdk/blueprint/Azure.ResourceManager.Blueprint/) | @@ -257,7 +257,7 @@ | Resource Management - Load Testing | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.LoadTesting/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.LoadTesting-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.LoadTesting_1.1.0/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/) | | Resource Management - Log Analytics | NuGet [1.2.2](https://www.nuget.org/packages/Azure.ResourceManager.OperationalInsights/1.2.2) | [docs](/dotnet/api/overview/azure/ResourceManager.OperationalInsights-readme) | GitHub [1.2.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.OperationalInsights_1.2.2/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/) | | Resource Management - Logic Apps | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.Logic/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Logic-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Logic_1.1.0/sdk/logic/Azure.ResourceManager.Logic/) | -| Resource Management - Machine Learning | NuGet [1.2.0](https://www.nuget.org/packages/Azure.ResourceManager.MachineLearning/1.2.0) | [docs](/dotnet/api/overview/azure/ResourceManager.MachineLearning-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.MachineLearning_1.2.0/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/) | +| Resource Management - Machine Learning | NuGet [1.2.1](https://www.nuget.org/packages/Azure.ResourceManager.MachineLearning/1.2.1) | [docs](/dotnet/api/overview/azure/ResourceManager.MachineLearning-readme) | GitHub [1.2.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.MachineLearning_1.2.1/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/) | | Resource Management - Machine Learning Compute | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.MachineLearningCompute/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.MachineLearningCompute-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.MachineLearningCompute_1.0.0-beta.4/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/) | | Resource Management - Maintenance | NuGet [1.1.2](https://www.nuget.org/packages/Azure.ResourceManager.Maintenance/1.1.2)
NuGet [1.2.0-beta.8](https://www.nuget.org/packages/Azure.ResourceManager.Maintenance/1.2.0-beta.8) | [docs](/dotnet/api/overview/azure/ResourceManager.Maintenance-readme) | GitHub [1.1.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Maintenance_1.1.2/sdk/maintenance/Azure.ResourceManager.Maintenance/)
GitHub [1.2.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Maintenance_1.2.0-beta.8/sdk/maintenance/Azure.ResourceManager.Maintenance/) | | Resource Management - Managed Grafana | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.Grafana/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Grafana-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Grafana_1.1.0/sdk/grafana/Azure.ResourceManager.Grafana/) | diff --git a/docs/core/tools/dotnet-test.md b/docs/core/tools/dotnet-test.md index 78ee291b2b5b7..054b4f0f1976c 100644 --- a/docs/core/tools/dotnet-test.md +++ b/docs/core/tools/dotnet-test.md @@ -51,7 +51,10 @@ dotnet test -h|--help ## Description -The `dotnet test` command is used to execute unit tests in a given solution. The `dotnet test` command builds the solution and runs a test host application for each test project in the solution. The test host executes tests in the given project using a test framework, for example: MSTest, NUnit, or xUnit, and reports the success or failure of each test. If all tests are successful, the test runner returns 0 as an exit code; otherwise if any test fails, it returns 1. +The `dotnet test` command is used to execute unit tests in a given solution. The `dotnet test` command builds the solution and runs a test host application for each test project in the solution using `VSTest`. The test host executes tests in the given project using a test framework, for example: MSTest, NUnit, or xUnit, and reports the success or failure of each test. If all tests are successful, the test runner returns 0 as an exit code; otherwise if any test fails, it returns 1. + +> [!NOTE] +> `dotnet test` was originally designed to support only `VSTest`-based test projects. Recent versions of the test frameworks are adding support for [Microsoft.Testing.Platform](../testing/unit-testing-platform-intro.md). This alternative test platform is more lightweight and faster than `VSTest` and supports `dotnet test` with different command line options. For more information, see [Microsoft.Testing.Platform](../testing/unit-testing-platform-intro.md). For multi-targeted projects, tests are run for each targeted framework. The test host and the unit test framework are packaged as NuGet packages and are restored as ordinary dependencies for the project. Starting with the .NET 9 SDK, these tests are run in parallel by default. To disable parallel execution, set the `TestTfmsInParallel` MSBuild property to `false`. For more information, see [Run tests in parallel](../whats-new/dotnet-9/sdk.md#run-tests-in-parallel) and the [example command line later in this article](#testtfmsinparallel). @@ -87,6 +90,9 @@ Where `Microsoft.NET.Test.Sdk` is the test host, `xunit` is the test framework. > - Starting in .NET 7: switch `-a` to alias `--arch` instead of `--test-adapter-path` > - Starting in .NET 7: switch `-r` to alias `--runtime` instead of `--results-directory` +> [!WARNING] +> When using `Microsoft.Testing.Platform`, please refer to [dotnet test integration](../testing/unit-testing-platform-integration-dotnet-test.md) for the supported options. As a rule of thumbs, every option non-related to testing is supported while every testing-related option is not supported as-is. + - **`--test-adapter-path `** Path to a directory to be searched for additional test adapters. Only *.dll* files with suffix `.TestAdapter.dll` are inspected. If not specified, the directory of the test *.dll* is searched. diff --git a/docs/core/tutorials/debugging-with-visual-studio-code.md b/docs/core/tutorials/debugging-with-visual-studio-code.md index 04d8a494b906d..11fe0c94e4357 100644 --- a/docs/core/tutorials/debugging-with-visual-studio-code.md +++ b/docs/core/tutorials/debugging-with-visual-studio-code.md @@ -1,7 +1,7 @@ --- title: Debug a .NET console application using Visual Studio Code description: Learn how to debug a .NET console app using Visual Studio Code. -ms.date: 08/30/2023 +ms.date: 09/12/2024 zone_pivot_groups: dotnet-version --- # Tutorial: Debug a .NET console application using Visual Studio Code @@ -38,35 +38,23 @@ A *breakpoint* temporarily interrupts the execution of the application before th :::image type="content" source="media/debugging-with-visual-studio-code/breakpoint-set-net6.png" alt-text="Breakpoint set"::: -## Set up for terminal input - -The breakpoint is located after a `Console.ReadLine` method call. The **Debug Console** doesn't accept terminal input for a running program. To handle terminal input while debugging, you can use the integrated terminal (one of the Visual Studio Code windows) or an external terminal. For this tutorial, you use the integrated terminal. - -1. The project folder contains a *.vscode* folder. Open the *launch.json* file that's in the *.vscode* folder. - -1. In *launch.json*, change the `console` setting from `internalConsole` to `integratedTerminal`: - - ```json - "console": "integratedTerminal", - ``` - -1. Save your changes. - ## Start debugging 1. Open the Debug view by selecting the Debugging icon on the left side menu. :::image type="content" source="media/debugging-with-visual-studio-code/select-debug-pane-net6.png" alt-text="Open the Debug tab in Visual Studio Code"::: -1. Select the green arrow at the top of the pane, next to **.NET Core Launch (console)**. Other ways to start the program in debugging mode are by pressing F5 or choosing **Run** > **Start Debugging** from the menu. +1. Select **Run and Debug**. If asked, select **C#** and then select **C#: Launch startup project**. Other ways to start the program in debugging mode are by pressing F5 or choosing **Run** > **Start Debugging** from the menu. :::image type="content" source="media/debugging-with-visual-studio-code/start-debugging.png" alt-text="Start debugging"::: -1. Select the **Terminal** tab to see the "What is your name?" prompt that the program displays before waiting for a response. +1. If asked to **Select Launch Configuration**, select **C#: HelloWorld HelloWorld**. - :::image type="content" source="media/debugging-with-visual-studio-code/select-terminal-net6.png" alt-text="Select the Terminal tab"::: +1. Select the **Debug Console** tab to see the "What is your name?" prompt that the program displays before waiting for a response. -1. Enter a string in the **Terminal** window in response to the prompt for a name, and then press Enter. + :::image type="content" source="media/debugging-with-visual-studio-code/select-debug-console.png" alt-text="Select the Debug Console tab"::: + +1. Enter a string in the **Debug Console** window in response to the prompt for a name, and then press Enter. Program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method runs. The **Locals** section of the **Variables** window displays the values of variables that are defined in the currently running method. @@ -78,11 +66,11 @@ The **Debug Console** window lets you interact with the application you're debug 1. Select the **Debug Console** tab. -1. Enter `name = "Gracie"` at the prompt at the bottom of the **Debug Console** window and press the Enter key. +1. Enter `name = "Gracie"` at the prompt at the bottom of the **Debug Console** window and press Enter. :::image type="content" source="media/debugging-with-visual-studio-code/change-variable-values-net6.png" alt-text="Change variable values"::: -1. Enter `currentDate = DateTime.Parse("2019-11-16T17:25:00Z").ToUniversalTime()` at the bottom of the **Debug Console** window and press the Enter key. +1. Enter `currentDate = DateTime.Parse("2019-11-16T17:25:00Z").ToUniversalTime()` at the bottom of the **Debug Console** window and press Enter. The **Variables** window displays the new values of the `name` and `currentDate` variables. @@ -90,13 +78,11 @@ The **Debug Console** window lets you interact with the application you're debug :::image type="content" source="media/debugging-with-visual-studio-code/continue-debugging.png" alt-text="Continue debugging"::: -1. Select the **Terminal** tab again. - The values displayed in the console window correspond to the changes you made in the **Debug Console**. :::image type="content" source="media/debugging-with-visual-studio-code/changed-variable-values.png" alt-text="Terminal showing the entered values"::: -1. Press any key to exit the application and stop debugging. +1. Press Enter to exit the application and stop debugging. ## Set a conditional breakpoint @@ -120,7 +106,7 @@ The program displays the string that the user enters. What happens if the user d 1. Start the program with debugging by pressing F5. -1. In the **Terminal** tab, press the Enter key when prompted to enter your name. +1. In the **Debug Console** tab, press Enter when prompted to enter your name. Because the condition you specified (`name` is either `null` or ) has been satisfied, program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method runs. @@ -134,7 +120,7 @@ The program displays the string that the user enters. What happens if the user d 1. Select the **Continue** button on the toolbar to continue program execution. -1. Select the **Terminal** tab, and press any key to exit the program and stop debugging. +1. Press Enter to exit the program and stop debugging. 1. Clear the breakpoint by clicking on the dot in the left margin of the code window. Other ways to clear a breakpoint are by pressing F9 or choosing **Run > Toggle Breakpoint** from the menu while the line of code is selected. @@ -168,7 +154,7 @@ Visual Studio Code also allows you to step line by line through a program and mo 1. Respond to the prompt by entering a string in the Terminal tab and pressing Enter. - The **Terminal** tab might not display the string you enter while you're entering it, but the method will capture your input. + The **Debug Console** tab might not display the string you enter while you're entering it, but the method will capture your input. 1. Select **Run** > **Step Into** or press F11. @@ -186,8 +172,6 @@ Visual Studio Code also allows you to step line by line through a program and mo :::image type="content" source="media/debugging-with-visual-studio-code/step-out.png" alt-text="Step-Out button"::: -1. Select the **Terminal** tab. - The terminal displays "Press any key to exit..." 1. Press any key to exit the program. @@ -247,20 +231,6 @@ A *breakpoint* temporarily interrupts the execution of the application before th :::image type="content" source="media/debugging-with-visual-studio-code/breakpoint-set-net6.png" alt-text="Breakpoint set"::: -## Set up for terminal input - -The breakpoint is located after a `Console.ReadLine` method call. The **Debug Console** doesn't accept terminal input for a running program. To handle terminal input while debugging, you can use the integrated terminal (one of the Visual Studio Code windows) or an external terminal. For this tutorial, you use the integrated terminal. - -1. The project folder contains a *.vscode* folder. Open the *launch.json* file that's in the *.vscode* folder. - -1. In *launch.json*, change the `console` setting from `internalConsole` to `integratedTerminal`: - - ```json - "console": "integratedTerminal", - ``` - -1. Save your changes. - ## Start debugging 1. Open the Debug view by selecting the Debugging icon on the left side menu. @@ -271,11 +241,11 @@ The breakpoint is located after a `Console.ReadLine` method call. The **Debug Co :::image type="content" source="media/debugging-with-visual-studio-code/start-debugging.png" alt-text="Start debugging"::: -1. Select the **Terminal** tab to see the "What is your name?" prompt that the program displays before waiting for a response. +1. Select the **Debug Conosle** tab to see the "What is your name?" prompt that the program displays before waiting for a response. :::image type="content" source="media/debugging-with-visual-studio-code/select-terminal-net6.png" alt-text="Select the Terminal tab"::: -1. Enter a string in the **Terminal** window in response to the prompt for a name, and then press Enter. +1. Enter a string in the **Debug Console** window in response to the prompt for a name, and then press Enter. Program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method runs. The **Locals** section of the **Variables** window displays the values of variables that are defined in the currently running method. @@ -299,8 +269,6 @@ The **Debug Console** window lets you interact with the application you're debug :::image type="content" source="media/debugging-with-visual-studio-code/continue-debugging.png" alt-text="Continue debugging"::: -1. Select the **Terminal** tab again. - The values displayed in the console window correspond to the changes you made in the **Debug Console**. :::image type="content" source="media/debugging-with-visual-studio-code/changed-variable-values.png" alt-text="Terminal showing the entered values"::: @@ -329,7 +297,7 @@ The program displays the string that the user enters. What happens if the user d 1. Start the program with debugging by pressing F5. -1. In the **Terminal** tab, press the Enter key when prompted to enter your name. +1. In the **Debug Console** tab, press the Enter key when prompted to enter your name. Because the condition you specified (`name` is either `null` or ) has been satisfied, program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method runs. @@ -343,7 +311,7 @@ The program displays the string that the user enters. What happens if the user d 1. Select the **Continue** button on the toolbar to continue program execution. -1. Select the **Terminal** tab, and press any key to exit the program and stop debugging. +1. Press any key to exit the program and stop debugging. 1. Clear the breakpoint by clicking on the dot in the left margin of the code window. Other ways to clear a breakpoint are by pressing F9 or choosing **Run > Toggle Breakpoint** from the menu while the line of code is selected. @@ -377,7 +345,7 @@ Visual Studio Code also allows you to step line by line through a program and mo 1. Respond to the prompt by entering a string in the Terminal tab and pressing Enter. - The **Terminal** tab might not display the string you enter while you're entering it, but the method will capture your input. + The **Debug Console** tab might not display the string you enter while you're entering it, but the method will capture your input. 1. Select **Run** > **Step Into** or press F11. @@ -456,20 +424,6 @@ A *breakpoint* temporarily interrupts the execution of the application before th :::image type="content" source="media/debugging-with-visual-studio-code/breakpoint-set-net6.png" alt-text="Breakpoint set"::: -## Set up for terminal input - -The breakpoint is located after a `Console.ReadLine` method call. The **Debug Console** doesn't accept terminal input for a running program. To handle terminal input while debugging, you can use the integrated terminal (one of the Visual Studio Code windows) or an external terminal. For this tutorial, you use the integrated terminal. - -1. Open *.vscode/launch.json*. - -1. Change the `console` setting from `internalConsole` to `integratedTerminal`: - - ```json - "console": "integratedTerminal", - ``` - -1. Save your changes. - ## Start debugging 1. Open the Debug view by selecting the Debugging icon on the left side menu. @@ -480,11 +434,11 @@ The breakpoint is located after a `Console.ReadLine` method call. The **Debug Co :::image type="content" source="media/debugging-with-visual-studio-code/start-debugging.png" alt-text="Start debugging"::: -1. Select the **Terminal** tab to see the "What is your name?" prompt that the program displays before waiting for a response. +1. Select the **Debug Console** tab to see the "What is your name?" prompt that the program displays before waiting for a response. :::image type="content" source="media/debugging-with-visual-studio-code/select-terminal-net6.png" alt-text="Select the Terminal tab"::: -1. Enter a string in the **Terminal** window in response to the prompt for a name, and then press Enter. +1. Enter a string in the **Debug Console** window in response to the prompt for a name, and then press Enter. Program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method runs. The **Locals** section of the **Variables** window displays the values of variables that are defined in the currently running method. @@ -508,8 +462,6 @@ The **Debug Console** window lets you interact with the application you're debug :::image type="content" source="media/debugging-with-visual-studio-code/continue-debugging.png" alt-text="Continue debugging"::: -1. Select the **Terminal** tab again. - The values displayed in the console window correspond to the changes you made in the **Debug Console**. :::image type="content" source="media/debugging-with-visual-studio-code/changed-variable-values.png" alt-text="Terminal showing the entered values"::: @@ -538,7 +490,7 @@ The program displays the string that the user enters. What happens if the user d 1. Start the program with debugging by pressing F5. -1. In the **Terminal** tab, press the Enter key when prompted to enter your name. +1. In the **Debug Console** tab, press the Enter key when prompted to enter your name. Because the condition you specified (`name` is either `null` or ) has been satisfied, program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method runs. @@ -552,7 +504,7 @@ The program displays the string that the user enters. What happens if the user d 1. Select the **Continue** button on the toolbar to continue program execution. -1. Select the **Terminal** tab, and press any key to exit the program and stop debugging. +1. Press any key to exit the program and stop debugging. 1. Clear the breakpoint by clicking on the dot in the left margin of the code window. Other ways to clear a breakpoint are by pressing F9 or choosing **Run > Toggle Breakpoint** from the menu while the line of code is selected. @@ -586,7 +538,7 @@ Visual Studio Code also allows you to step line by line through a program and mo 1. Respond to the prompt by entering a string in the Terminal tab and pressing Enter. - The **Terminal** tab might not display the string you enter while you're entering it, but the method will capture your input. + The **Debug Console** tab might not display the string you enter while you're entering it, but the method will capture your input. The **Variables** window shows the value returned by the call to the method. @@ -606,8 +558,6 @@ Visual Studio Code also allows you to step line by line through a program and mo :::image type="content" source="media/debugging-with-visual-studio-code/step-out.png" alt-text="Step-Out button"::: -1. Select the **Terminal** tab. - The terminal displays "Press any key to exit..." 1. Press any key to exit the program. diff --git a/docs/core/tutorials/library-with-visual-studio-code.md b/docs/core/tutorials/library-with-visual-studio-code.md index b3db62834635f..534d22d433d58 100644 --- a/docs/core/tutorials/library-with-visual-studio-code.md +++ b/docs/core/tutorials/library-with-visual-studio-code.md @@ -1,7 +1,7 @@ --- title: Create a .NET class library using Visual Studio Code description: Learn how to create a .NET class library using Visual Studio Code. -ms.date: 08/30/2023 +ms.date: 09/12/2024 zone_pivot_groups: dotnet-version --- # Tutorial: Create a .NET class library using Visual Studio Code @@ -16,74 +16,31 @@ When you create a class library, you can distribute it as a third-party componen ## Prerequisites -* [Visual Studio Code](https://code.visualstudio.com/) with the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) installed. - - If you have the [C# Dev Kit extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) installed, uninstall or disable it. It isn't used by this tutorial series. +* [Visual Studio Code](https://code.visualstudio.com/) with [C# Dev Kit extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) installed. For information about how to install extensions on Visual Studio Code, see [VS Code Extension Marketplace](https://code.visualstudio.com/docs/editor/extension-gallery). * The [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0). -## Create a solution - -Start by creating a blank solution to put the class library project in. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution. - -1. Start Visual Studio Code. - -1. Select **File** > **Open Folder** (**Open...** on macOS) from the main menu - -1. In the **Open Folder** dialog, create a *ClassLibraryProjects* folder and click **Select Folder** (**Open** on macOS). - -1. Open the **Terminal** in Visual Studio Code by selecting **View** > **Terminal** from the main menu. - - The **Terminal** opens with the command prompt in the *ClassLibraryProjects* folder. - -1. In the **Terminal**, enter the following command: - - ```dotnetcli - dotnet new sln - ``` - - The terminal output looks like the following example: - - ```output - The template "Solution File" was created successfully. - ``` - ## Create a class library project -Add a new .NET class library project named "StringLibrary" to the solution. - -1. In the terminal, run the following command to create the library project: +Start by creating a .NET class library project named "StringLibrary" and an associated solution. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution. - ```dotnetcli - dotnet new classlib -o StringLibrary - ``` +1. Start Visual Studio Code. - The `-o` or `--output` command specifies the location to place the generated output. +1. Go to the Explorer view and select **Create .NET Project**. Alternatively, you can bring up the Command Palette using Ctrl+Shift+P (Command+Shift+P on MacOS) and then type ".NET" and find and select the .NET: New Project command. - The terminal output looks like the following example: +1. After selecting the command, you'll need to choose the project template. Choose Class Library. - ```output - The template "Class library" was created successfully. - Processing post-creation actions... - Running 'dotnet restore' on StringLibrary\StringLibrary.csproj... - Determining projects to restore... - Restored C:\Projects\ClassLibraryProjects\StringLibrary\StringLibrary.csproj (in 328 ms). - Restore succeeded. - ``` +1. Then select the location where you would like the new project to be created. -1. Run the following command to add the library project to the solution: +1. Then select the location where you would like the new project to be created: Create a folder named `ClassLibraryProjects` and select it. - ```dotnetcli - dotnet sln add StringLibrary/StringLibrary.csproj - ``` +1. Name the project **StringLibrary**, select **Show all template options**, select **.NET 8** and select **Create Project**. - The terminal output looks like the following example: +1. Name the project **StringLibrary** and select **Create Project**. - ```output - Project `StringLibrary\StringLibrary.csproj` added to the solution. - ``` +1. Press Enter at the prompt **Project will be created in \**. 1. Check to make sure that the library targets .NET 8. In **Explorer**, open *StringLibrary/StringLibrary.csproj*. @@ -109,11 +66,9 @@ Add a new .NET class library project named "StringLibrary" to the solution. 1. Save the file. -1. Run the following command to build the solution and verify that the project compiles without error. +1. Expand **Solution Explorer** at the bottom of the **Explorer** view. - ```dotnetcli - dotnet build - ``` +1. Right click the solution in **Solution Explorer** and select **Build**, or open the Command Palette and select **.NET: Build** to build the solution and verify that the project compiles without error. The terminal output looks like the following example: @@ -133,34 +88,11 @@ Add a new .NET class library project named "StringLibrary" to the solution. Add a console application that uses the class library. The app will prompt the user to enter a string and report whether the string begins with an uppercase character. -1. In the terminal, run the following command to create the console app project: - - ```dotnetcli - dotnet new console -o ShowCase - ``` - - The terminal output looks like the following example: - - ```output - The template "Console Application" was created successfully. - Processing post-creation actions... - Running 'dotnet restore' on ShowCase\ShowCase.csproj... - Determining projects to restore... - Restored C:\Projects\ClassLibraryProjects\ShowCase\ShowCase.csproj (in 210 ms). - Restore succeeded. - ``` +1. Right-click the solution in **Solution Explorer** and select **New Project**, or in the Command Palette select **.NET: New Project**. -1. Run the following command to add the console app project to the solution: +1. Select Console app. - ```dotnetcli - dotnet sln add ShowCase/ShowCase.csproj - ``` - - The terminal output looks like the following example: - - ```output - Project `ShowCase\ShowCase.csproj` added to the solution. - ``` +1. Give it the name **ShowCase**, select the default location and select **Create Project**. 1. Open *ShowCase/Program.cs* and replace all of the code with the following code. @@ -176,25 +108,19 @@ Add a console application that uses the class library. The app will prompt the u Initially, the new console app project doesn't have access to the class library. To allow it to call methods in the class library, create a project reference to the class library project. -1. Run the following command: +1. In **Solution Explorer** right click on the **ShowCase** project and select **Add Project Reference**. - ```dotnetcli - dotnet add ShowCase/ShowCase.csproj reference StringLibrary/StringLibrary.csproj - ``` +1. Select StringLibrary. - The terminal output looks like the following example: +## Run the app - ```output - Reference `..\StringLibrary\StringLibrary.csproj` added to the project. - ``` +1. Select **Run** > **Run without debugging**. -## Run the app +1. Select **C#**. -1. Run the following command in the terminal: +1. Select **ShowCase**. - ```dotnetcli - dotnet run --project ShowCase/ShowCase.csproj - ``` + If you get an error that says no C# program is loaded, close the folder that you have open, and open the `ShowCase` folder. Then try running the app again. 1. Try out the program by entering strings and pressing Enter, then press Enter to exit. @@ -219,7 +145,7 @@ Initially, the new console app project doesn't have access to the class library. ## Next steps -In this tutorial, you created a solution, added a library project, and added a console app project that uses the library. In the next tutorial, you add a unit test project to the solution. +In this tutorial, you created a library project and added a console app project that uses the library. In the next tutorial, you add a unit test project to the solution. > [!div class="nextstepaction"] > [Test a .NET class library with .NET using Visual Studio Code](testing-library-with-visual-studio-code.md) @@ -236,69 +162,22 @@ When you create a class library, you can distribute it as a third-party componen ## Prerequisites -* [Visual Studio Code](https://code.visualstudio.com/) with the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) installed. For information about how to install extensions on Visual Studio Code, see [VS Code Extension Marketplace](https://code.visualstudio.com/docs/editor/extension-gallery). +* [Visual Studio Code](https://code.visualstudio.com/) with [C# Dev Kit extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) installed. For information about how to install extensions on Visual Studio Code, see [VS Code Extension Marketplace](https://code.visualstudio.com/docs/editor/extension-gallery). * The [.NET 7 SDK](https://dotnet.microsoft.com/download/dotnet/7.0). -## Create a solution +## Create a class library project and solution -Start by creating a blank solution to put the class library project in. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution. +Start by creating a .NET class library project named "StringLibrary" and an associated solution. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution. 1. Start Visual Studio Code. -1. Select **File** > **Open Folder** (**Open...** on macOS) from the main menu - -1. In the **Open Folder** dialog, create a *ClassLibraryProjects* folder and click **Select Folder** (**Open** on macOS). - -1. Open the **Terminal** in Visual Studio Code by selecting **View** > **Terminal** from the main menu. - - The **Terminal** opens with the command prompt in the *ClassLibraryProjects* folder. - -1. In the **Terminal**, enter the following command: +1. Go to the Explorer view and select **Create .NET Project**. Alternatively, you can bring up the Command Palette using Ctrl+Shift+P (Command+Shift+P on MacOS) and then type ".NET" and find and select the .NET: New Project command. - ```dotnetcli - dotnet new sln - ``` - - The terminal output looks like the following example: +1. After selecting the command, you'll need to choose the project template. Choose Class Library. - ```output - The template "Solution File" was created successfully. - ``` +1. Then select the location where you would like the new project to be created. -## Create a class library project - -Add a new .NET class library project named "StringLibrary" to the solution. - -1. In the terminal, run the following command to create the library project: - - ```dotnetcli - dotnet new classlib -o StringLibrary - ``` - - The `-o` or `--output` command specifies the location to place the generated output. - - The terminal output looks like the following example: - - ```output - The template "Class library" was created successfully. - Processing post-creation actions... - Running 'dotnet restore' on StringLibrary\StringLibrary.csproj... - Determining projects to restore... - Restored C:\Projects\ClassLibraryProjects\StringLibrary\StringLibrary.csproj (in 328 ms). - Restore succeeded. - ``` - -1. Run the following command to add the library project to the solution: - - ```dotnetcli - dotnet sln add StringLibrary/StringLibrary.csproj - ``` - - The terminal output looks like the following example: - - ```output - Project `StringLibrary\StringLibrary.csproj` added to the solution. - ``` +1. Give it the name **StringLibrary**, select **Show all template options**, select **.NET 7** and select **Create Project**. 1. Check to make sure that the library targets .NET 7. In **Explorer**, open *StringLibrary/StringLibrary.csproj*. @@ -324,11 +203,7 @@ Add a new .NET class library project named "StringLibrary" to the solution. 1. Save the file. -1. Run the following command to build the solution and verify that the project compiles without error. - - ```dotnetcli - dotnet build - ``` +1. Right click on the project in **Solution Explorer** and right-click **Build** or open the Command Palette and select **.NET: Build** to build the solution and verify that the project compiles without error. The terminal output looks like the following example: @@ -348,34 +223,11 @@ Add a new .NET class library project named "StringLibrary" to the solution. Add a console application that uses the class library. The app will prompt the user to enter a string and report whether the string begins with an uppercase character. -1. In the terminal, run the following command to create the console app project: - - ```dotnetcli - dotnet new console -o ShowCase - ``` - - The terminal output looks like the following example: - - ```output - The template "Console Application" was created successfully. - Processing post-creation actions... - Running 'dotnet restore' on ShowCase\ShowCase.csproj... - Determining projects to restore... - Restored C:\Projects\ClassLibraryProjects\ShowCase\ShowCase.csproj (in 210 ms). - Restore succeeded. - ``` - -1. Run the following command to add the console app project to the solution: +1. In the **Solution Explorer** select **New Project** or in the Command Palette select **.NET: New Project**. - ```dotnetcli - dotnet sln add ShowCase/ShowCase.csproj - ``` - - The terminal output looks like the following example: +1. Select Console app. - ```output - Project `ShowCase\ShowCase.csproj` added to the solution. - ``` +1. Give it the name **ShowCase**, select the default location and select **Create Project**. 1. Open *ShowCase/Program.cs* and replace all of the code with the following code. @@ -391,25 +243,17 @@ Add a console application that uses the class library. The app will prompt the u Initially, the new console app project doesn't have access to the class library. To allow it to call methods in the class library, create a project reference to the class library project. -1. Run the following command: - - ```dotnetcli - dotnet add ShowCase/ShowCase.csproj reference StringLibrary/StringLibrary.csproj - ``` - - The terminal output looks like the following example: +1. In **Solution Explorer** right click on the **ShowCase** project and select **Add Project Reference**. - ```output - Reference `..\StringLibrary\StringLibrary.csproj` added to the project. - ``` +1. Select StringLibrary. ## Run the app -1. Run the following command in the terminal: +1. Select Run>Run without debugging. - ```dotnetcli - dotnet run --project ShowCase/ShowCase.csproj - ``` +1. Select C#. + +1. Select ShowCase. 1. Try out the program by entering strings and pressing Enter, then press Enter to exit. @@ -451,71 +295,22 @@ When you create a class library, you can distribute it as a third-party componen ## Prerequisites -* [Visual Studio Code](https://code.visualstudio.com/) with the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) installed. For information about how to install extensions on Visual Studio Code, see [VS Code Extension Marketplace](https://code.visualstudio.com/docs/editor/extension-gallery). +* [Visual Studio Code](https://code.visualstudio.com/) with [C# Dev Kit extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) installed. For information about how to install extensions on Visual Studio Code, see [VS Code Extension Marketplace](https://code.visualstudio.com/docs/editor/extension-gallery). * The [.NET 6 SDK](https://dotnet.microsoft.com/download/dotnet/6.0). -## Create a solution +## Create a class library project and solution -Start by creating a blank solution to put the class library project in. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution. +Start by creating a .NET class library project named "StringLibrary" and an associated solution. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution. 1. Start Visual Studio Code. -1. Select **File** > **Open Folder** (**Open...** on macOS) from the main menu - -1. In the **Open Folder** dialog, create a *ClassLibraryProjects* folder and click **Select Folder** (**Open** on macOS). - -1. Open the **Terminal** in Visual Studio Code by selecting **View** > **Terminal** from the main menu. - - The **Terminal** opens with the command prompt in the *ClassLibraryProjects* folder. - -1. In the **Terminal**, enter the following command: - - ```dotnetcli - dotnet new sln - ``` - - The terminal output looks like the following example: - - ```output - The template "Solution File" was created successfully. - ``` - -## Create a class library project +1. Go to the Explorer view and select **Create .NET Project**. Alternatively, you can bring up the Command Palette using Ctrl+Shift+P (Command+Shift+P on MacOS) and then type ".NET" and find and select the .NET: New Project command. -Add a new .NET class library project named "StringLibrary" to the solution. +1. After selecting the command, you'll need to choose the project template. Choose Class Library. -1. In the terminal, run the following command to create the library project: - - ```dotnetcli - dotnet new classlib -f net6.0 -o StringLibrary - ``` +1. Then select the location where you would like the new project to be created. - The `-f` or `--framework` command changes the default target framework to `net6.0` version. - - The `-o` or `--output` command specifies the location to place the generated output. - - The terminal output looks like the following example: - - ```output - The template "Class library" was created successfully. - Processing post-creation actions... - Running 'dotnet restore' on StringLibrary\StringLibrary.csproj... - Determining projects to restore... - Restored C:\Projects\ClassLibraryProjects\StringLibrary\StringLibrary.csproj (in 328 ms). - Restore succeeded. - ``` - -1. Run the following command to add the library project to the solution: - - ```dotnetcli - dotnet sln add StringLibrary/StringLibrary.csproj - ``` - - The terminal output looks like the following example: - - ```output - Project `StringLibrary\StringLibrary.csproj` added to the solution. - ``` +1. Give it the name **StringLibrary**, select **Show all template options**, select **.NET 7** and select **Create Project**. 1. Check to make sure that the library targets .NET 6. In **Explorer**, open *StringLibrary/StringLibrary.csproj*. @@ -541,11 +336,7 @@ Add a new .NET class library project named "StringLibrary" to the solution. 1. Save the file. -1. Run the following command to build the solution and verify that the project compiles without error. - - ```dotnetcli - dotnet build - ``` +1. Right click on the project in **Solution Explorer** and right-click **Build** or open the Command Palette and select **.NET: Build** to build the solution and verify that the project compiles without error. The terminal output looks like the following example: @@ -565,34 +356,11 @@ Add a new .NET class library project named "StringLibrary" to the solution. Add a console application that uses the class library. The app will prompt the user to enter a string and report whether the string begins with an uppercase character. -1. In the terminal, run the following command to create the console app project: +1. In the **Solution Explorer** select **New Project** or in the Command Palette select **.NET: New Project**. - ```dotnetcli - dotnet new console -f net6.0 -o ShowCase - ``` +1. Select Console app. - The terminal output looks like the following example: - - ```output - The template "Console Application" was created successfully. - Processing post-creation actions... - Running 'dotnet restore' on ShowCase\ShowCase.csproj... - Determining projects to restore... - Restored C:\Projects\ClassLibraryProjects\ShowCase\ShowCase.csproj (in 210 ms). - Restore succeeded. - ``` - -1. Run the following command to add the console app project to the solution: - - ```dotnetcli - dotnet sln add ShowCase/ShowCase.csproj - ``` - - The terminal output looks like the following example: - - ```output - Project `ShowCase\ShowCase.csproj` added to the solution. - ``` +1. Give it the name **ShowCase**, select the default location and select **Create Project**. 1. Open *ShowCase/Program.cs* and replace all of the code with the following code. @@ -608,25 +376,17 @@ Add a console application that uses the class library. The app will prompt the u Initially, the new console app project doesn't have access to the class library. To allow it to call methods in the class library, create a project reference to the class library project. -1. Run the following command: +1. In **Solution Explorer** right click on the **ShowCase** project and select **Add Project Reference**. - ```dotnetcli - dotnet add ShowCase/ShowCase.csproj reference StringLibrary/StringLibrary.csproj - ``` - - The terminal output looks like the following example: - - ```output - Reference `..\StringLibrary\StringLibrary.csproj` added to the project. - ``` +1. Select StringLibrary. ## Run the app -1. Run the following command in the terminal: +1. Select Run>Run without debugging. - ```dotnetcli - dotnet run --project ShowCase/ShowCase.csproj - ``` +1. Select C#. + +1. Select ShowCase. 1. Try out the program by entering strings and pressing Enter, then press Enter to exit. diff --git a/docs/core/tutorials/media/debugging-with-visual-studio-code/select-debug-console.png b/docs/core/tutorials/media/debugging-with-visual-studio-code/select-debug-console.png new file mode 100644 index 0000000000000..0fbb26f2f429e Binary files /dev/null and b/docs/core/tutorials/media/debugging-with-visual-studio-code/select-debug-console.png differ diff --git a/docs/core/tutorials/media/debugging-with-visual-studio-code/start-debugging.png b/docs/core/tutorials/media/debugging-with-visual-studio-code/start-debugging.png index 29b693b3729bc..e7227949661b3 100644 Binary files a/docs/core/tutorials/media/debugging-with-visual-studio-code/start-debugging.png and b/docs/core/tutorials/media/debugging-with-visual-studio-code/start-debugging.png differ diff --git a/docs/core/tutorials/media/testing-library-with-visual-studio-code/FailedTest.png b/docs/core/tutorials/media/testing-library-with-visual-studio-code/FailedTest.png new file mode 100644 index 0000000000000..9d616e6e742a3 Binary files /dev/null and b/docs/core/tutorials/media/testing-library-with-visual-studio-code/FailedTest.png differ diff --git a/docs/core/tutorials/media/testing-library-with-visual-studio-code/TestingScreenshot.png b/docs/core/tutorials/media/testing-library-with-visual-studio-code/TestingScreenshot.png new file mode 100644 index 0000000000000..055af29c8acf7 Binary files /dev/null and b/docs/core/tutorials/media/testing-library-with-visual-studio-code/TestingScreenshot.png differ diff --git a/docs/core/tutorials/publishing-with-visual-studio-code.md b/docs/core/tutorials/publishing-with-visual-studio-code.md index 750ec8827b04b..5320ce97bcfc9 100644 --- a/docs/core/tutorials/publishing-with-visual-studio-code.md +++ b/docs/core/tutorials/publishing-with-visual-studio-code.md @@ -1,7 +1,7 @@ --- title: Publish a .NET console application using Visual Studio Code description: Learn how to use Visual Studio Code and the .NET CLI to create the set of files that are needed to run a .NET application. -ms.date: 08/30/2023 +ms.date: 09/12/2024 zone_pivot_groups: dotnet-version --- # Tutorial: Publish a .NET console application using Visual Studio Code @@ -91,13 +91,13 @@ In the following steps, you'll look at the files created by the publish process. 1. On Linux, enter `./HelloWorld` and press Enter. - 1. Enter a name in response to the prompt, and press any key to exit. + 1. Enter a name in response to the prompt, and press Enter to exit. 1. On any platform, run the app by using the [`dotnet`](../tools/dotnet.md) command: 1. Enter `dotnet HelloWorld.dll` and press Enter. - 1. Enter a name in response to the prompt, and press any key to exit. + 1. Enter a name in response to the prompt, and press Enter to exit. ## Additional resources diff --git a/docs/core/tutorials/snippets/with-visual-studio/csharp/Program-Read.cs b/docs/core/tutorials/snippets/with-visual-studio/csharp/Program-Read.cs new file mode 100644 index 0000000000000..199a6e9d1e18e --- /dev/null +++ b/docs/core/tutorials/snippets/with-visual-studio/csharp/Program-Read.cs @@ -0,0 +1,11 @@ +//Variant of Program.cs that reads input from the debug console instead of the terminal +#if READ +// +Console.WriteLine("What is your name?"); +var name = Console.ReadLine(); +var currentDate = DateTime.Now; +Console.WriteLine($"{Environment.NewLine}Hello, {name}, on {currentDate:d} at {currentDate:t}!"); +Console.Write($"{Environment.NewLine}Press Enter to exit..."); +Console.Read(); +// +#endif diff --git a/docs/core/tutorials/testing-library-with-visual-studio-code.md b/docs/core/tutorials/testing-library-with-visual-studio-code.md index b92ae6997d5a3..5c694e025b622 100644 --- a/docs/core/tutorials/testing-library-with-visual-studio-code.md +++ b/docs/core/tutorials/testing-library-with-visual-studio-code.md @@ -1,7 +1,7 @@ --- title: Test a .NET class library using Visual Studio Code -description: Learn how to use Visual Studio Code and the .NET CLI to create and run a unit test project for a .NET class library. -ms.date: 09/01/2023 +description: Learn how to use Visual Studio Code and run a unit test project for a .NET class library. +ms.date: 06/14/2024 zone_pivot_groups: dotnet-version --- # Tutorial: Test a .NET class library using Visual Studio Code @@ -22,11 +22,9 @@ Unit tests provide automated software testing during your development and publis 1. Open the `ClassLibraryProjects` solution you created in [Create a .NET class library using Visual Studio Code](library-with-visual-studio-code.md). -1. Create a unit test project named "StringLibraryTest". +1. From **Solution Explorer**, select **New Project**, or from the Command Palette select **.NET: New Project**. - ```dotnetcli - dotnet new mstest -o StringLibraryTest - ``` +1. Select **MSTest Test Project**, name it "StringLibraryTest", select the default directory, and select **Create Project**. The project template creates a *UnitTest1.cs* file with the following code: @@ -51,21 +49,13 @@ Unit tests provide automated software testing during your development and publis Each method tagged with [[TestMethod]](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute) in a test class tagged with [[TestClass]](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute) is run automatically when the unit test is invoked. -1. Add the test project to the solution. - - ```dotnetcli - dotnet sln add StringLibraryTest/StringLibraryTest.csproj - ``` - ## Add a project reference For the test project to work with the `StringLibrary` class, add a reference in the `StringLibraryTest` project to the `StringLibrary` project. -1. Run the following command: +1. From **Solution Explorer** right click on the 'StringLibraryTest' Project and select **Add Project Reference**. - ```dotnetcli - dotnet add StringLibraryTest/StringLibraryTest.csproj reference StringLibrary/StringLibrary.csproj - ``` +1. Select "StringLibrary". ## Add and run unit test methods @@ -98,20 +88,13 @@ To create the test methods: 1. Save your changes. -1. Run the tests: +## Build and Run your Tests - ```dotnetcli - dotnet test StringLibraryTest/StringLibraryTest.csproj - ``` +1. In **Solution Explorer**, right-click the solution and select **Build** or from the Command Palette, select **.NET: Build**. - The terminal output shows that all tests passed. +1. Select the **Testing** window, select **Run Tests** or from the Command Palette, select **Test: Run all Tests**. - ```output - Starting test execution, please wait... - A total of 1 test files matched the specified pattern. - - Passed! - Failed: 0, Passed: 3, Skipped: 0, Total: 3, Duration: 3 ms - StringLibraryTest.dll (net8.0) - ``` + :::image type="content" source="media/testing-library-with-visual-studio-code/testingScreenshot.png" alt-text="Visual Studio Code Test Explorer"::: ## Handle test failures @@ -124,27 +107,15 @@ If you're doing test-driven development (TDD), you write tests first and they fa "1234", ".", ";", " " }; ``` -1. Run the tests: +1. Run the tests by clicking on the green error next to the test in the editor. - ```dotnetcli - dotnet test StringLibraryTest/StringLibraryTest.csproj - ``` + The output shows that the test fails, and it provides an error message for the failed test: "Assert.IsFalse failed. Expected for 'Error': false; actual: True". Because of the failure, no strings in the array after "Error" were tested. - The terminal output shows that one test fails, and it provides an error message for the failed test: "Assert.IsFalse failed. Expected for 'Error': false; actual: True". Because of the failure, no strings in the array after "Error" were tested. + :::image type="content" source="media/testing-library-with-visual-studio-code/failedTest.png" alt-text="Visual Studio Code Failed Test"::: - ```output - Starting test execution, please wait... - A total of 1 test files matched the specified pattern. - Failed TestDoesNotStartWithUpper [28 ms] - Error Message: - Assert.IsFalse failed. Expected for 'Error': false; Actual: True - Stack Trace: - at StringLibraryTest.UnitTest1.TestDoesNotStartWithUpper() in C:\ClassLibraryProjects\StringLibraryTest\UnitTest1.cs:line 33 +1. Remove the string "Error" that you added in step. - Failed! - Failed: 1, Passed: 2, Skipped: 0, Total: 3, Duration: 31 ms - StringLibraryTest.dll (net5.0) - ``` - -1. Remove the string "Error" that you added in step 1. Rerun the test and the tests pass. +1. Rerun the test and the tests pass. ## Test the Release version of the library @@ -160,7 +131,7 @@ Now that the tests have all passed when running the Debug build of the library, ## Debug tests -If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Debug All Tests** between lines 7 and 8. If you're unable to find it, press Ctrl+Shift+P to open the command palette and enter **Reload Window**. +If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Debug Tests in current file** between lines 7 and 8. If you're unable to find it, press Ctrl+Shift+P to open the command palette and enter **Reload Window**. Visual Studio Code starts the test project with the debugger attached. Execution will stop at any breakpoint you've added to the test project or the underlying library code. @@ -208,11 +179,9 @@ Unit tests provide automated software testing during your development and publis 1. Open the `ClassLibraryProjects` solution you created in [Create a .NET class library using Visual Studio Code](library-with-visual-studio-code.md). -1. Create a unit test project named "StringLibraryTest". +1. From **Solution Explorer**, select **Add Project**, or from the Command Palette select **.NET: New Project**. - ```dotnetcli - dotnet new mstest -o StringLibraryTest - ``` +1. Select **MSTest Test Project**, name it "StringLibraryTest", select the default directory, and select **Create Project**. The project template creates a UnitTest1.cs file with the following code: @@ -240,21 +209,13 @@ Unit tests provide automated software testing during your development and publis Each method tagged with [[TestMethod]](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute) in a test class tagged with [[TestClass]](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute) is run automatically when the unit test is invoked. -1. Add the test project to the solution. - - ```dotnetcli - dotnet sln add StringLibraryTest/StringLibraryTest.csproj - ``` - ## Add a project reference For the test project to work with the `StringLibrary` class, add a reference in the `StringLibraryTest` project to the `StringLibrary` project. -1. Run the following command: +1. From **Solution Explorer** right click on the 'StringLibraryTest' Project and select **Add Project Reference**. - ```dotnetcli - dotnet add StringLibraryTest/StringLibraryTest.csproj reference StringLibrary/StringLibrary.csproj - ``` +1. Select "StringLibrary". ## Add and run unit test methods @@ -287,20 +248,13 @@ To create the test methods: 1. Save your changes. -1. Run the tests: +## Build and Run your Tests - ```dotnetcli - dotnet test StringLibraryTest/StringLibraryTest.csproj - ``` +1. In **Solution Explorer**, right-click and select **Build** or from the Command Palette, select **.NET: Build**. - The terminal output shows that all tests passed. +1. Select the **Testing** window, select **Run Tests** or from the Command Palette, select **Test: Run all Tests**. - ```output - Starting test execution, please wait... - A total of 1 test files matched the specified pattern. - - Passed! - Failed: 0, Passed: 3, Skipped: 0, Total: 3, Duration: 3 ms - StringLibraryTest.dll (net7.0) - ``` + :::image type="content" source="media/testing-library-with-visual-studio-code/testingScreenshot.png" alt-text="Visual Studio Code Test Explorer"::: ## Handle test failures @@ -313,25 +267,11 @@ If you're doing test-driven development (TDD), you write tests first and they fa "1234", ".", ";", " " }; ``` -1. Run the tests: +1. Run the tests by clicking on the green error next to the test in the editor. - ```dotnetcli - dotnet test StringLibraryTest/StringLibraryTest.csproj - ``` + The output shows that the test fails, and it provides an error message for the failed test: "Assert.IsFalse failed. Expected for 'Error': false; actual: True". Because of the failure, no strings in the array after "Error" were tested. - The terminal output shows that one test fails, and it provides an error message for the failed test: "Assert.IsFalse failed. Expected for 'Error': false; actual: True". Because of the failure, no strings in the array after "Error" were tested. - - ```output - Starting test execution, please wait... - A total of 1 test files matched the specified pattern. - Failed TestDoesNotStartWithUpper [28 ms] - Error Message: - Assert.IsFalse failed. Expected for 'Error': false; Actual: True - Stack Trace: - at StringLibraryTest.UnitTest1.TestDoesNotStartWithUpper() in C:\ClassLibraryProjects\StringLibraryTest\UnitTest1.cs:line 33 - - Failed! - Failed: 1, Passed: 2, Skipped: 0, Total: 3, Duration: 31 ms - StringLibraryTest.dll (net5.0) - ``` + :::image type="content" source="media/testing-library-with-visual-studio-code/failedTest.png" alt-text="Visual Studio Code Failed Test"::: 1. Remove the string "Error" that you added in step 1. Rerun the test and the tests pass. @@ -349,7 +289,7 @@ Now that the tests have all passed when running the Debug build of the library, ## Debug tests -If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Debug All Tests** between lines 7 and 8. If you're unable to find it, press Ctrl+Shift+P to open the command palette and enter **Reload Window**. +If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Debug Tests in current file** between lines 7 and 8. If you're unable to find it, press Ctrl+Shift+P to open the command palette and enter **Reload Window**. Visual Studio Code starts the test project with the debugger attached. Execution will stop at any breakpoint you've added to the test project or the underlying library code. @@ -392,15 +332,9 @@ Unit tests provide automated software testing during your development and publis 1. Open the `ClassLibraryProjects` solution you created in [Create a .NET class library using Visual Studio Code](library-with-visual-studio-code.md). -1. Create a unit test project named "StringLibraryTest". +1. From **Solution Explorer**, select **Add Project**, or from the Command Palette select **.NET: New Project**. - ```dotnetcli - dotnet new mstest -f net6.0 -o StringLibraryTest - ``` - - The `-f net6.0` command changes the default target framework to `net6.0` version. - - The `-o` or `--output` command specifies the location to place the generated output. +1. Select **MSTest Test Project**, name it "StringLibraryTest", select the default directory, and select **Create Project**. The project template creates a UnitTest1.cs file with the following code: @@ -428,21 +362,13 @@ Unit tests provide automated software testing during your development and publis Each method tagged with [[TestMethod]](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute) in a test class tagged with [[TestClass]](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute) is run automatically when the unit test is invoked. -1. Add the test project to the solution. - - ```dotnetcli - dotnet sln add StringLibraryTest/StringLibraryTest.csproj - ``` - ## Add a project reference For the test project to work with the `StringLibrary` class, add a reference in the `StringLibraryTest` project to the `StringLibrary` project. -1. Run the following command: +1. From **Solution Explorer** right click on the 'StringLibraryTest' Project and select **Add Project Reference**. - ```dotnetcli - dotnet add StringLibraryTest/StringLibraryTest.csproj reference StringLibrary/StringLibrary.csproj - ``` +1. Select "StringLibrary". ## Add and run unit test methods @@ -475,20 +401,13 @@ To create the test methods: 1. Save your changes. -1. Run the tests: +## Build and Run your Tests - ```dotnetcli - dotnet test StringLibraryTest/StringLibraryTest.csproj - ``` +1. In **Solution Explorer**, right-click and select **Build** or from the Command Palette, select **.NET: Build**. - The terminal output shows that all tests passed. +1. Select the **Testing** window, select **Run Tests** or from the Command Palette, select **Test: Run all Tests**. - ```output - Starting test execution, please wait... - A total of 1 test files matched the specified pattern. - - Passed! - Failed: 0, Passed: 3, Skipped: 0, Total: 3, Duration: 3 ms - StringLibraryTest.dll (net6.0) - ``` + :::image type="content" source="media/testing-library-with-visual-studio-code/testingScreenshot.png" alt-text="Visual Studio Code Test Explorer"::: ## Handle test failures @@ -501,25 +420,11 @@ If you're doing test-driven development (TDD), you write tests first and they fa "1234", ".", ";", " " }; ``` -1. Run the tests: - - ```dotnetcli - dotnet test StringLibraryTest/StringLibraryTest.csproj - ``` - - The terminal output shows that one test fails, and it provides an error message for the failed test: "Assert.IsFalse failed. Expected for 'Error': false; actual: True". Because of the failure, no strings in the array after "Error" were tested. +1. Run the tests by clicking on the green error next to the test in the editor. - ```output - Starting test execution, please wait... - A total of 1 test files matched the specified pattern. - Failed TestDoesNotStartWithUpper [28 ms] - Error Message: - Assert.IsFalse failed. Expected for 'Error': false; Actual: True - Stack Trace: - at StringLibraryTest.UnitTest1.TestDoesNotStartWithUpper() in C:\ClassLibraryProjects\StringLibraryTest\UnitTest1.cs:line 33 + The output shows that the test fails, and it provides an error message for the failed test: "Assert.IsFalse failed. Expected for 'Error': false; actual: True". Because of the failure, no strings in the array after "Error" were tested. - Failed! - Failed: 1, Passed: 2, Skipped: 0, Total: 3, Duration: 31 ms - StringLibraryTest.dll (net5.0) - ``` + :::image type="content" source="media/testing-library-with-visual-studio-code/failedTest.png" alt-text="Visual Studio Code Failed Test"::: 1. Remove the string "Error" that you added in step 1. Rerun the test and the tests pass. @@ -537,7 +442,7 @@ Now that the tests have all passed when running the Debug build of the library, ## Debug tests -If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Debug All Tests** between lines 7 and 8. If you're unable to find it, press Ctrl+Shift+P to open the command palette and enter **Reload Window**. +If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Debug Tests in current file** between lines 7 and 8. If you're unable to find it, press Ctrl+Shift+P to open the command palette and enter **Reload Window**. Visual Studio Code starts the test project with the debugger attached. Execution will stop at any breakpoint you've added to the test project or the underlying library code. diff --git a/docs/core/tutorials/with-visual-studio-code.md b/docs/core/tutorials/with-visual-studio-code.md index 7b15bc7190ecf..6aaa286aaeb8f 100644 --- a/docs/core/tutorials/with-visual-studio-code.md +++ b/docs/core/tutorials/with-visual-studio-code.md @@ -1,20 +1,18 @@ --- title: Create a .NET console application using Visual Studio Code -description: Learn how to create a .NET console application using Visual Studio Code and the .NET CLI. -ms.date: 09/21/2023 +description: Learn how to create a .NET console application using Visual Studio Code. +ms.date: 09/12/2024 zone_pivot_groups: dotnet-version --- # Tutorial: Create a .NET console application using Visual Studio Code ::: zone pivot="dotnet-8-0" -This tutorial shows how to create and run a .NET console application by using Visual Studio Code and the .NET CLI. Project tasks, such as creating, compiling, and running a project are done by using the .NET CLI. You can follow this tutorial with a different code editor and run commands in a terminal if you prefer. +This tutorial shows how to create and run a .NET console application by using Visual Studio Code. ## Prerequisites -* [Visual Studio Code](https://code.visualstudio.com/) with the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) installed. - - If you have the [C# Dev Kit extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) installed, uninstall or disable it. It isn't used by this tutorial series. +* [Visual Studio Code](https://code.visualstudio.com/) with [C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) installed. For information about how to install extensions on Visual Studio Code, see [VS Code Extension Marketplace](https://code.visualstudio.com/docs/editor/extension-gallery). @@ -26,25 +24,19 @@ Create a .NET console app project named "HelloWorld". 1. Start Visual Studio Code. -1. Select **File** > **Open Folder** (**File** > **Open...** on macOS) from the main menu. +1. Go to the Explorer view and select **Create .NET Project**. Alternatively, you can bring up the Command Palette using Ctrl+Shift+P (Command+Shift+P on MacOS) and then type ".NET" and find and select the .NET: New Project command. -1. In the **Open Folder** dialog, create a *HelloWorld* folder and select it. Then click **Select Folder** (**Open** on macOS). +1. After selecting the command, you need to choose the project template. Choose **Console App**. - The folder name becomes the project name and the namespace name by default. You'll add code later in the tutorial that assumes the project namespace is `HelloWorld`. +1. Select the location where you would like the new project to be created. -1. In the **Do you trust the authors of the files in this folder?** dialog, select **Yes, I trust the authors**. You can trust the authors because this folder only has files generated by .NET and added or modified by you. - -1. Open the **Terminal** in Visual Studio Code by selecting **View** > **Terminal** from the main menu. +1. Give your new project a name, "HelloWorld". - The **Terminal** opens with the command prompt in the *HelloWorld* folder. +1. Select to **Show all template options**. Set **Do not use top-level statements** to **true**. And finally, select **Create Project**. -1. In the **Terminal**, enter the following command: - - ```dotnetcli - dotnet new console --framework net8.0 --use-program-main - ``` +1. In the **Do you trust the authors of the files in this folder?** dialog, select **Yes, I trust the authors**. You can trust the authors because this folder only has files generated by .NET and added or modified by you. - Open the *Program.cs* file to see the simple application created by the template: +1. Open the *Program.cs* file to see the simple application created by the template: ```csharp namespace HelloWorld; @@ -58,30 +50,18 @@ Create a .NET console app project named "HelloWorld". } ``` - The first time you open a *.cs* file, Visual Studio Code prompts you to add assets to build and debug your app. Select **Yes**, and Visual Studio Code creates a *.vscode* folder with *launch.json* and *tasks.json* files. - - > [!NOTE] - > If you don't get the prompt, or if you accidentally dismiss it without selecting **Yes**, do the following steps to create *launch.json* and *tasks.json*: - > - >* Select **Run** > **Add Configuration** from the menu. - >* Select **.NET 5+ and .NET Core** at the **Select environment** prompt. - The code defines a class, `Program`, with a single method, `Main`, that takes a array as an argument. `Main` is the application entry point, the method that's called automatically by the runtime when it launches the application. Any command-line arguments supplied when the application is launched are available in the *args* array. The code in `Main` calls the method to display a message in the console window. - C# has a feature named [top-level statements](../../csharp/fundamentals/program-structure/top-level-statements.md) that lets you omit the `Program` class and the `Main` method. This tutorial doesn't use this feature. Whether you use it in your programs is a matter of style preference. In the `dotnet new` command that created the project, the `--use-program-main` option prevented top-level statements from being used. + C# has a feature named [top-level statements](../../csharp/fundamentals/program-structure/top-level-statements.md) that lets you omit the `Program` class and the `Main` method. This tutorial doesn't use this feature. Whether you use it in your programs is a matter of style preference. By setting **Do not use top-level statements to true** when you created the project, you prevented top-level statements from being used. ## Run the app -Run the following command in the **Terminal**: +To run your app, select **Run** > **Run without Debugging** in the upper menu, or use the keyboard shortcut (Ctrl+F5). -```dotnetcli -dotnet run -``` +If asked to select a debugger, select **C#**, then select **C#: HelloWorld** The program displays "Hello, World!" and ends. -![The dotnet run command](media/with-visual-studio-code/dotnet-run-command.png) - ## Enhance the app Enhance the application to prompt the user for their name and display it along with the date and time. @@ -90,7 +70,7 @@ Enhance the application to prompt the user for their name and display it along w 1. Replace the contents of the `Main` method in *Program.cs*, which is the line that calls `Console.WriteLine`, with the following code: - :::code language="csharp" source="./snippets/with-visual-studio/csharp/Program.cs" id="MainMethod"::: + :::code language="csharp" source="./snippets/with-visual-studio/csharp/Program-Read.cs" id="MainMethod"::: This code displays a prompt in the console window and waits until the user enters a string followed by the Enter key. It stores this string in a variable named `name`. It also retrieves the value of the property, which contains the current local time, and assigns it to a variable named `currentDate`. And it displays these values in the console window. Finally, it displays a prompt in the console window and calls the method to wait for user input. @@ -103,17 +83,13 @@ Enhance the application to prompt the user for their name and display it along w > [!IMPORTANT] > In Visual Studio Code, you have to explicitly save changes. Unlike Visual Studio, file changes are not automatically saved when you build and run an app. -1. Run the program again: - - ```dotnetcli - dotnet run - ``` +1. Select **Run**>**Run without debugging**. 1. Respond to the prompt by entering a name and pressing the Enter key. :::image type="content" source="media/debugging-with-visual-studio-code/run-modified-program.png" alt-text="Terminal window with modified program output"::: -1. Press any key to exit the program. +1. Press Enter to exit the program. ## Additional resources @@ -182,7 +158,7 @@ Create a .NET console app project named "HelloWorld". } ``` - The first time you edit a *.cs* file, Visual Studio Code prompts you to add the missing assets to build and debug your app. Select **Yes**, and Visual Studio Code creates a *.vscode* folder with *launch.json* and *tasks.json* files. + The first time you edit a *.cs* file, Visual Studio Code prompts you to add the missing assets to build and debug your app. Select **Yes**, and Visual Studio Code creates a *.vscode* folder with *launch.json* and *tasks.json* files. > [!NOTE] > If you don't get the prompt, or if you accidentally dismiss it without selecting **Yes**, do the following steps to create *launch.json* and *tasks.json*: @@ -299,7 +275,7 @@ Create a .NET console app project named "HelloWorld". } ``` - The first time you edit a *.cs* file, Visual Studio Code prompts you to add the missing assets to build and debug your app. Select **Yes**, and Visual Studio Code creates a *.vscode* folder with *launch.json* and *tasks.json* files. + The first time you edit a *.cs* file, Visual Studio Code prompts you to add the missing assets to build and debug your app. Select **Yes**, and Visual Studio Code creates a *.vscode* folder with *launch.json* and *tasks.json* files. > [!NOTE] > If you don't get the prompt, or if you accidentally dismiss it without selecting **Yes**, do the following steps to create *launch.json* and *tasks.json*: diff --git a/docs/csharp/language-reference/attributes/general.md b/docs/csharp/language-reference/attributes/general.md index adefd58c8cfe2..bf355d8e61ac5 100644 --- a/docs/csharp/language-reference/attributes/general.md +++ b/docs/csharp/language-reference/attributes/general.md @@ -242,7 +242,7 @@ Overload resolution considers the two methods equally good for some argument typ :::code language="csharp" source="snippets/OrpaSnippets.cs" ID="SnippetOrpaExample"::: -All overloads with a lower priority than the highest overload priority are removed from the set of applicable methods. Methods without this attribute have the overload priority set to the default of zero. Library authors should use this attribute as a last resort when adding a new and better method overload. Library authors should have a deep understanding of how [Overload resolution](~/_csharplang/proposals/overload-resolution-priority.md#overload-resolution-priority) impacts choosing the better method. Otherwise, unexpected errors can result. +All overloads with a lower priority than the highest overload priority are removed from the set of applicable methods. Methods without this attribute have the overload priority set to the default of zero. Library authors should use this attribute as a last resort when adding a new and better method overload. Library authors should have a deep understanding of how [Overload resolution](~/_csharplang/proposals/csharp-13.0/overload-resolution-priority.md#overload-resolution-priority) impacts choosing the better method. Otherwise, unexpected errors can result. ## See also diff --git a/docs/csharp/specification/toc.yml b/docs/csharp/specification/toc.yml index 0268700fab199..9f6bb504ed6bb 100644 --- a/docs/csharp/specification/toc.yml +++ b/docs/csharp/specification/toc.yml @@ -77,6 +77,8 @@ items: items: - name: "Enhanced #line directives" href: ../../../_csharplang/proposals/csharp-10.0/enhanced-line-directives.md + - name: "Escape sequence '\\e'" + href: ../../../_csharplang/proposals/csharp-13.0/esc-escape-sequence.md - name: Basic concepts items: - name: Top-level statements @@ -145,6 +147,8 @@ items: href: ../../../_csharplang/proposals/csharp-9.0/extension-getenumerator.md - name: Collection expressions href: ../../../_csharplang/proposals/csharp-12.0/collection-expressions.md + - name: Better conversion from collection expression + href: ../../../_csharplang/proposals/csharp-13.0/collection-expressions-better-conversion.md - name: Lambda discard parameters href: ../../../_csharplang/proposals/csharp-9.0/lambda-discard-parameters.md - name: Static anonymous functions @@ -154,7 +158,7 @@ items: - name: Lambda improvements href: ../../../_csharplang/proposals/csharp-10.0/lambda-improvements.md - name: Method group natural type conversion - href: ../../../_csharplang/proposals/method-group-natural-type-improvements.md + href: ../../../_csharplang/proposals/csharp-13.0/method-group-natural-type-improvements.md - name: Optional Lambda expression parameters href: ../../../_csharplang/proposals/csharp-12.0/lambda-method-group-defaults.md - name: Checked user-defined operators @@ -168,7 +172,7 @@ items: - name: Extended nameof scope href: ../../../_csharplang/proposals/csharp-11.0/extended-nameof-scope.md - name: Overload resolution priority - href: ../../../_csharplang/proposals/overload-resolution-priority.md + href: ../../../_csharplang/proposals/csharp-13.0/overload-resolution-priority.md - name: Statements items: - name: Global using directive @@ -184,9 +188,9 @@ items: - name: Nested stackalloc href: ../../../_csharplang/proposals/csharp-8.0/nested-stackalloc.md - name: Lock object semantics - href: ../../../_csharplang/proposals/lock-object.md + href: ../../../_csharplang/proposals/csharp-13.0/lock-object.md - name: Allow `ref` and `unsafe` - href: ../../../_csharplang/proposals/ref-unsafe-in-iterators-async.md + href: ../../../_csharplang/proposals/csharp-13.0/ref-unsafe-in-iterators-async.md - name: Namespaces items: - name: File scoped namespaces @@ -196,7 +200,7 @@ items: - name: Extending partial methods href: ../../../_csharplang/proposals/csharp-9.0/extending-partial-methods.md - name: Partial properties - href: ../../../_csharplang/proposals/partial-properties.md + href: ../../../_csharplang/proposals/csharp-13.0/partial-properties.md - name: Covariant return types href: ../../../_csharplang/proposals/csharp-9.0/covariant-returns.md - name: Primary constructors @@ -208,7 +212,7 @@ items: - name: AsyncMethodBuilder override href: ../../../_csharplang/proposals/csharp-10.0/async-method-builders.md - name: Params collections - href: ../../../_csharplang/proposals/params-collections.md + href: ../../../_csharplang/proposals/csharp-13.0/params-collections.md - name: Structs items: - name: Readonly instance members @@ -228,7 +232,7 @@ items: - name: Static abstracts in interfaces href: ../../../_csharplang/proposals/csharp-11.0/static-abstracts-in-interfaces.md - name: Allow ref struct interfaces - href: ../../../_csharplang/proposals/ref-struct-interfaces.md + href: ../../../_csharplang/proposals/csharp-13.0/ref-struct-interfaces.md - name: Attributes items: - name: Generic attributes diff --git a/docs/csharp/whats-new/csharp-13.md b/docs/csharp/whats-new/csharp-13.md index 8db917f923ab6..252a3c3b6ae48 100644 --- a/docs/csharp/whats-new/csharp-13.md +++ b/docs/csharp/whats-new/csharp-13.md @@ -33,13 +33,13 @@ You can find any breaking changes introduced in C# 13 in our article on [breakin The `params` modifier isn't limited to array types. You can now use `params` with any recognized collection type, including , , and types that implement and have an `Add` method. In addition to concrete types, the interfaces , , , , and can also be used. -When an interface type is used, the compiler synthesizes the storage for the arguments supplied. You can learn more in the feature specification for [`params` collections](~/_csharplang/proposals/params-collections.md). +When an interface type is used, the compiler synthesizes the storage for the arguments supplied. You can learn more in the feature specification for [`params` collections](~/_csharplang/proposals/csharp-13.0/params-collections.md). ## New lock object The .NET 9 runtime includes a new type for thread synchronization, the type. This type provides better thread synchronization through its API. The method enters an exclusive scope. The `ref struct` returned from that supports the `Dispose()` pattern to exit the exclusive scope. -The C# [`lock`](../language-reference/statements/lock.md) statement recognizes if the target of the lock is a `Lock` object. If so, it uses the updated API, rather than the traditional API using . The compiler also recognizes if you convert a `Lock` object to another type and the `Monitor` based code would be generated. You can read more in the feature specification for the [new lock object](~/_csharplang/proposals/lock-object.md). +The C# [`lock`](../language-reference/statements/lock.md) statement recognizes if the target of the lock is a `Lock` object. If so, it uses the updated API, rather than the traditional API using . The compiler also recognizes if you convert a `Lock` object to another type and the `Monitor` based code would be generated. You can read more in the feature specification for the [new lock object](~/_csharplang/proposals/csharp-13.0/lock-object.md). ## New escape sequence @@ -51,7 +51,7 @@ This feature makes small optimizations to overload resolution involving method g The new behavior is to prune the set of candidate methods at each scope, removing those candidate methods that aren't applicable. Typically, the removed methods are generic methods with the wrong arity, or constraints that aren't satisfied. The process continues to the next outer scope only if no candidate methods are found. This process more closely follows the general algorithm for overload resolution. If all candidate methods found at a given scope don't match, the method group doesn't have a natural type. -You can read the details of the changes in the [proposal specification](~/_csharplang/proposals/method-group-natural-type-improvements.md). +You can read the details of the changes in the [proposal specification](~/_csharplang/proposals/csharp-13.0/method-group-natural-type-improvements.md). ## Implicit index access diff --git a/includes/core-changes/windowsforms/3.1/remove-controls-3.1.md b/includes/core-changes/windowsforms/3.1/remove-controls-3.1.md index 9968e8d2b22db..205e11308710e 100644 --- a/includes/core-changes/windowsforms/3.1/remove-controls-3.1.md +++ b/includes/core-changes/windowsforms/3.1/remove-controls-3.1.md @@ -14,6 +14,7 @@ The following types are no longer available: - - - +- - - - diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.choosingdates/cs/datetimereplacement1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.choosingdates/cs/datetimereplacement1.cs index a909c3e5e643c..2c9c0e1c618c1 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.choosingdates/cs/datetimereplacement1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.choosingdates/cs/datetimereplacement1.cs @@ -34,7 +34,7 @@ public bool IsOpenAt(TimeSpan time) storeDelta = tz.GetAdjustmentRules()[tz.GetAdjustmentRules().Length - 1].DaylightDelta; TimeSpan comparisonTime = time + (offset - tz.BaseUtcOffset).Negate() + (delta - storeDelta).Negate(); - return comparisonTime >= open & comparisonTime <= close; + return comparisonTime >= open && comparisonTime <= close; } } } @@ -66,7 +66,7 @@ public static void Main() // The example displays the following output: // Store is open now at 15:29:01.6129911: True // Store is open at 08:00:00: True -// Store is open at 21:00:00: False +// Store is open at 21:00:00: True // Store is open at 04:59:00: False -// Store is open at 18:31:00: False +// Store is open at 18:31:00: True //