From e87661e2bbde04758aae1356ddf52d5d4822dbe6 Mon Sep 17 00:00:00 2001 From: Martin Ruiz Date: Thu, 27 Feb 2025 07:38:28 -0800 Subject: [PATCH 1/7] Add configfile option to dotnet nuget push (#45050) --- docs/core/tools/dotnet-nuget-push.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/core/tools/dotnet-nuget-push.md b/docs/core/tools/dotnet-nuget-push.md index a32ff25f4ade2..3405c8b0adbfe 100644 --- a/docs/core/tools/dotnet-nuget-push.md +++ b/docs/core/tools/dotnet-nuget-push.md @@ -20,6 +20,7 @@ dotnet nuget push [] [-d|--disable-buffering] [--force-english-output] [--no-service-endpoint] [-s|--source ] [--skip-duplicate] [-sk|--symbol-api-key ] [-ss|--symbol-source ] [-t|--timeout ] + [--configfile ] dotnet nuget push -h|--help ``` @@ -94,6 +95,10 @@ Alternatively, use the NuGet CLI for the first package, then you can use `dotnet Specifies the timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes). Specifying 0 applies the default value. +- **`--configfile`** + + The NuGet configuration file (*nuget.config*) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used. For more information, see [Common NuGet Configurations](/nuget/consume-packages/configuring-nuget-behavior). + ## Examples - Push *foo.nupkg* to the default push source specified in the NuGet config file, using an API key: From 7093cde52fb0530d01661fa738fd846558cccf0f Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 27 Feb 2025 07:39:19 -0800 Subject: [PATCH 2/7] Update package index with latest published versions (#45056) --- docs/azure/includes/dotnet-all.md | 6 +++--- docs/azure/includes/dotnet-new.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/azure/includes/dotnet-all.md b/docs/azure/includes/dotnet-all.md index 8c7abb57dce11..11410d4d39b2f 100644 --- a/docs/azure/includes/dotnet-all.md +++ b/docs/azure/includes/dotnet-all.md @@ -4,7 +4,7 @@ | AI Model Inference | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.AI.Inference/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.Inference-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Inference_1.0.0-beta.3/sdk/ai/Azure.AI.Inference/) | | Anomaly Detector | NuGet [3.0.0-preview.7](https://www.nuget.org/packages/Azure.AI.AnomalyDetector/3.0.0-preview.7) | [docs](/dotnet/api/overview/azure/AI.AnomalyDetector-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [3.0.0-preview.7](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.AnomalyDetector_3.0.0-preview.7/sdk/anomalydetector/Azure.AI.AnomalyDetector/) | | App Configuration | NuGet [1.5.0](https://www.nuget.org/packages/Azure.Data.AppConfiguration/1.5.0) | [docs](/dotnet/api/overview/azure/Data.AppConfiguration-readme) | GitHub [1.5.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.AppConfiguration_1.5.0/sdk/appconfiguration/Azure.Data.AppConfiguration/) | -| App Configuration Provider | NuGet [8.1.0](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.AzureAppConfiguration/8.1.0) | | GitHub [8.1.0](https://github.com/Azure/AppConfiguration-DotnetProvider) | +| App Configuration Provider | NuGet [8.1.1](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.AzureAppConfiguration/8.1.1) | | GitHub [8.1.1](https://github.com/Azure/AppConfiguration-DotnetProvider) | | Attestation | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Security.Attestation/1.0.0) | [docs](/dotnet/api/overview/azure/Security.Attestation-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.Attestation_1.0.0/sdk/attestation/Azure.Security.Attestation/) | | Azure AI Search | NuGet [11.6.0](https://www.nuget.org/packages/Azure.Search.Documents/11.6.0)
NuGet [11.7.0-beta.2](https://www.nuget.org/packages/Azure.Search.Documents/11.7.0-beta.2) | [docs](/dotnet/api/overview/azure/Search.Documents-readme) | GitHub [11.6.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Search.Documents_11.6.0/sdk/search/Azure.Search.Documents/)
GitHub [11.7.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Search.Documents_11.7.0-beta.2/sdk/search/Azure.Search.Documents/) | | Azure Object Anchors Conversion | NuGet [0.3.0-beta.6](https://www.nuget.org/packages/Azure.MixedReality.ObjectAnchors.Conversion/0.3.0-beta.6) | [docs](/dotnet/api/overview/azure/MixedReality.ObjectAnchors.Conversion-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [0.3.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.ObjectAnchors.Conversion_0.3.0-beta.6/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/) | @@ -356,8 +356,8 @@ | Resource Management - Web PubSub | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.WebPubSub/1.1.0)
NuGet [1.2.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.WebPubSub/1.2.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.WebPubSub-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.WebPubSub_1.1.0/sdk/webpubsub/Azure.ResourceManager.WebPubSub/)
GitHub [1.2.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.WebPubSub_1.2.0-beta.2/sdk/webpubsub/Azure.ResourceManager.WebPubSub/) | | Resource Management - Workload Monitor | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.WorkloadMonitor/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.WorkloadMonitor-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.WorkloadMonitor_1.0.0-beta.4/sdk/workloadmonitor/Azure.ResourceManager.WorkloadMonitor/) | | Resource Management - Workloads | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.Workloads/1.1.0)
NuGet [1.2.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Workloads/1.2.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Workloads-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Workloads_1.1.0/sdk/workloads/Azure.ResourceManager.Workloads/)
GitHub [1.2.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Workloads_1.2.0-beta.1/sdk/workloads/Azure.ResourceManager.Workloads/) | -| App Configuration Extension | NuGet [8.1.0](https://www.nuget.org/packages/Microsoft.Azure.AppConfiguration.Functions.Worker/8.1.0) | | | -| App Configuration Provider | NuGet [8.1.0](https://www.nuget.org/packages/Microsoft.Azure.AppConfiguration.AspNetCore/8.1.0) | | | +| App Configuration Extension | NuGet [8.1.1](https://www.nuget.org/packages/Microsoft.Azure.AppConfiguration.Functions.Worker/8.1.1) | | | +| App Configuration Provider | NuGet [8.1.1](https://www.nuget.org/packages/Microsoft.Azure.AppConfiguration.AspNetCore/8.1.1) | | | | Azure.Communication.Administration | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Communication.Administration/1.0.0-beta.3) | | | | Communication Calling Windows Client | NuGet [1.11.0](https://www.nuget.org/packages/Azure.Communication.Calling.WindowsClient/1.11.0) | | | | DotNetty | NuGet [0.7.6](https://www.nuget.org/packages/DotNetty.Common/0.7.6) | | | diff --git a/docs/azure/includes/dotnet-new.md b/docs/azure/includes/dotnet-new.md index 78c76e739a854..c8f8c47b0e950 100644 --- a/docs/azure/includes/dotnet-new.md +++ b/docs/azure/includes/dotnet-new.md @@ -4,7 +4,7 @@ | AI Model Inference | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.AI.Inference/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.Inference-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Inference_1.0.0-beta.3/sdk/ai/Azure.AI.Inference/) | | Anomaly Detector | NuGet [3.0.0-preview.7](https://www.nuget.org/packages/Azure.AI.AnomalyDetector/3.0.0-preview.7) | [docs](/dotnet/api/overview/azure/AI.AnomalyDetector-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [3.0.0-preview.7](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.AnomalyDetector_3.0.0-preview.7/sdk/anomalydetector/Azure.AI.AnomalyDetector/) | | App Configuration | NuGet [1.5.0](https://www.nuget.org/packages/Azure.Data.AppConfiguration/1.5.0) | [docs](/dotnet/api/overview/azure/Data.AppConfiguration-readme) | GitHub [1.5.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.AppConfiguration_1.5.0/sdk/appconfiguration/Azure.Data.AppConfiguration/) | -| App Configuration Provider | NuGet [8.1.0](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.AzureAppConfiguration/8.1.0) | | GitHub [8.1.0](https://github.com/Azure/AppConfiguration-DotnetProvider) | +| App Configuration Provider | NuGet [8.1.1](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.AzureAppConfiguration/8.1.1) | | GitHub [8.1.1](https://github.com/Azure/AppConfiguration-DotnetProvider) | | Attestation | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Security.Attestation/1.0.0) | [docs](/dotnet/api/overview/azure/Security.Attestation-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.Attestation_1.0.0/sdk/attestation/Azure.Security.Attestation/) | | Azure AI Search | NuGet [11.6.0](https://www.nuget.org/packages/Azure.Search.Documents/11.6.0)
NuGet [11.7.0-beta.2](https://www.nuget.org/packages/Azure.Search.Documents/11.7.0-beta.2) | [docs](/dotnet/api/overview/azure/Search.Documents-readme) | GitHub [11.6.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Search.Documents_11.6.0/sdk/search/Azure.Search.Documents/)
GitHub [11.7.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Search.Documents_11.7.0-beta.2/sdk/search/Azure.Search.Documents/) | | Azure Object Anchors Conversion | NuGet [0.3.0-beta.6](https://www.nuget.org/packages/Azure.MixedReality.ObjectAnchors.Conversion/0.3.0-beta.6) | [docs](/dotnet/api/overview/azure/MixedReality.ObjectAnchors.Conversion-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [0.3.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.ObjectAnchors.Conversion_0.3.0-beta.6/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/) | From 653828092a00baaffadfd784ff4f62e17172a2c3 Mon Sep 17 00:00:00 2001 From: Rich Lander Date: Thu, 27 Feb 2025 09:02:49 -0800 Subject: [PATCH 3/7] Add breaking change for containers - default tag (#45054) * Add breaking change for containes - default tag * Apply suggestions from code review Co-authored-by: Logan Bussell Co-authored-by: Matt Thalman * Update per feedback * Fix TOC --------- Co-authored-by: Logan Bussell Co-authored-by: Matt Thalman Co-authored-by: Cam Soper --- docs/core/compatibility/10.0.md | 6 +++ .../10.0/default-images-use-ubuntu.md | 47 +++++++++++++++++++ docs/core/compatibility/toc.yml | 8 ++++ 3 files changed, 61 insertions(+) create mode 100644 docs/core/compatibility/containers/10.0/default-images-use-ubuntu.md diff --git a/docs/core/compatibility/10.0.md b/docs/core/compatibility/10.0.md index e738d6ea2a9d4..9ce43e70dd393 100644 --- a/docs/core/compatibility/10.0.md +++ b/docs/core/compatibility/10.0.md @@ -16,6 +16,12 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af > > This article is a work in progress. It's not a complete list of breaking changes in .NET 10. To query breaking changes that are still pending publication, see [Issues of .NET](https://issuesof.net/?q=%20is:open%20-label:Documented%20is:issue%20(label:%22Breaking%20Change%22%20or%20label:breaking-change)%20(repo:dotnet/docs%20or%20repo:aspnet/Announcements)%20group:repo%20(label:%22:checkered_flag:%20Release:%20.NET%2010%22%20or%20label:10.0.0)%20sort:created-desc). +## Containers + +| Title | Type of change | Introduced version | +|----------------------------------------------------------------------------------------------------------------------------|---------------------|--------------------| +| [Default .NET images use Ubuntu](containers/10.0/default-images-use-ubuntu.md) | Behavioral change | Preview 1 | + ## Core .NET libraries | Title | Type of change | Introduced version | diff --git a/docs/core/compatibility/containers/10.0/default-images-use-ubuntu.md b/docs/core/compatibility/containers/10.0/default-images-use-ubuntu.md new file mode 100644 index 0000000000000..289ecb27134e7 --- /dev/null +++ b/docs/core/compatibility/containers/10.0/default-images-use-ubuntu.md @@ -0,0 +1,47 @@ +--- +title: "Default .NET container tags now use Ubuntu" +description: Learn about the breaking change where the default .NET container tags, like `10.0`, use Ubuntu. +ms.date: 2/26/2025 +--- + +# Default .NET images use Ubuntu + +The default Linux distro for .NET tags has been changed from Debian to Ubuntu. This applies to all .NET tags that do not explicitly specify an OS. + +Debian images are still produced and supported. They can be referenced using the `-trixie-slim` suffix. + +- `docker pull mcr.microsoft.com/dotnet/sdk:10.0-preview` - Refers to Ubuntu 24.04 "Noble Numbat" +- `docker pull mcr.microsoft.com/dotnet/sdk:10.0-preview-noble` - Refers to Ubuntu 24.04 "Noble Numbat" +- `docker pull mcr.microsoft.com/dotnet/sdk:10.0-preview-trixie-slim` - Refers to Debian 13 "Trixie" + +The same change will apply to `10.0` tags once the `-preview` suffix is removed. This change was proposed in [dotnet-docker #5709](https://github.com/dotnet/dotnet-docker/discussions/5709). + +## Version introduced + +.NET 10 Preview 1 + +## Previous behavior + +.NET 9 and earlier default tags reference images based on Debian. + +## New behavior + +Default tags reference images based on Ubuntu. + +## Type of breaking change + +This change is a [behavioral change](../../categories.md#behavioral-change). + +## Reason for change + +Debian and .NET release cycles (for mainline support) are the same length, while Debian is released (and by extensions) goes out of support first. Ubuntu support periods are much longer, such that a given .NET release will go out of support before the given Ubuntu version. + +## Recommended action + +Test your application. This change is unlikely to affect users. + +If you prefer Debian or have a dependency on it, use a Debian specific tag, such as `10.0-preview-trixie-slim`. + +## Affected APIs + +N/A diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index 3193f1ec4861b..4180e5311ac7f 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -8,6 +8,10 @@ items: items: - name: Overview href: 10.0.md + - name: Containers + items: + - name: Default .NET images use Ubuntu + href: containers/10.0/default-images-use-ubuntu.md - name: Core .NET libraries items: - name: API obsoletions with non-default diagnostic IDs @@ -1316,6 +1320,10 @@ items: href: configuration/7.0/diagnostics-config-section.md - name: Containers items: + - name: .NET 10 + items: + - name: Default .NET images use Ubuntu + href: containers/10.0/default-images-use-ubuntu.md - name: .NET 9 items: - name: Container images no longer install zlib From 1209d6deca404cce9f3f3170941762efddbe8724 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 27 Feb 2025 12:58:20 -0500 Subject: [PATCH 4/7] update the article on the char type (#45060) * update the article on the char type Fixes #45049. In addition add implicit conversion to `nint` and `nuint`. Finally, perform an edit pass. * build issue --- .../language-reference/builtin-types/char.md | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/docs/csharp/language-reference/builtin-types/char.md b/docs/csharp/language-reference/builtin-types/char.md index 801b98e139cf6..72f03cd83924d 100644 --- a/docs/csharp/language-reference/builtin-types/char.md +++ b/docs/csharp/language-reference/builtin-types/char.md @@ -1,25 +1,24 @@ --- description: Learn about the built-in character type in C# -title: "char type" -ms.date: 05/11/2020 +title: "The char type" +ms.date: 02/27/2025 f1_keywords: - "char" - "char_CSharpKeyword" helpviewer_keywords: - "char data type [C#]" -ms.assetid: b51cf4fb-124c-4067-af48-afbac122b228 --- # char (C# reference) -The `char` type keyword is an alias for the .NET structure type that represents a Unicode UTF-16 character. +The `char` type keyword is an alias for the .NET structure type that represents a Unicode UTF-16 code unit, typically a UTF-16 character. -|Type|Range|Size|.NET type| -|----------|-----------|----------|-------------------------| -|`char`|U+0000 to U+FFFF|16 bit|| +| Type | Range | Size | .NET type | +|--------|------------------|--------|-------------------------------------------------| +| `char` | U+0000 to U+FFFF | 16 bit | | The default value of the `char` type is `\0`, that is, U+0000. -The `char` type supports [comparison](../operators/comparison-operators.md), [equality](../operators/equality-operators.md), [increment](../operators/arithmetic-operators.md#increment-operator-), and [decrement](../operators/arithmetic-operators.md#decrement-operator---) operators. Moreover, for `char` operands, [arithmetic](../operators/arithmetic-operators.md) and [bitwise logical](../operators/bitwise-and-shift-operators.md) operators perform an operation on the corresponding character codes and produce the result of the `int` type. +The `char` type supports [comparison](../operators/comparison-operators.md), [equality](../operators/equality-operators.md), [increment](../operators/arithmetic-operators.md#increment-operator-), and [decrement](../operators/arithmetic-operators.md#decrement-operator---) operators. Moreover, for `char` operands, [arithmetic](../operators/arithmetic-operators.md) and [bitwise logical](../operators/bitwise-and-shift-operators.md) operators perform an operation on the corresponding code points and produce the result as an `int` value. The [string](reference-types.md#the-string-type) type represents text as a sequence of `char` values. @@ -31,18 +30,18 @@ You can specify a `char` value with: - a Unicode escape sequence, which is `\u` followed by the four-symbol hexadecimal representation of a character code. - a hexadecimal escape sequence, which is `\x` followed by the hexadecimal representation of a character code. -[!code-csharp-interactive[char literals](snippets/shared/CharType.cs#Literals)] +:::code language="csharp" interactive="try-dotnet-method" source="snippets/shared/CharType.cs" id="Literals"::: As the preceding example shows, you can also cast the value of a character code into the corresponding `char` value. > [!NOTE] -> In the case of a Unicode escape sequence, you must specify all four hexadecimal digits. That is, `\u006A` is a valid escape sequence, while `\u06A` and `\u6A` are not valid. +> In a Unicode escape sequence, you must specify all four hexadecimal digits. That is, `\u006A` is a valid escape sequence, while `\u06A` and `\u6A` are invalid. > -> In the case of a hexadecimal escape sequence, you can omit the leading zeros. That is, the `\x006A`, `\x06A`, and `\x6A` escape sequences are valid and correspond to the same character. +> In a hexadecimal escape sequence, you can omit the leading zeros. That is, the `\x006A`, `\x06A`, and `\x6A` escape sequences are valid and correspond to the same character. ## Conversions -The `char` type is implicitly convertible to the following [integral](integral-numeric-types.md) types: `ushort`, `int`, `uint`, `long`, and `ulong`. It's also implicitly convertible to the built-in [floating-point](floating-point-numeric-types.md) numeric types: `float`, `double`, and `decimal`. It's explicitly convertible to `sbyte`, `byte`, and `short` integral types. +The `char` type is implicitly convertible to the following [integral](integral-numeric-types.md) types: `ushort`, `int`, `uint`, `long`, `ulong`, `nint`, and `nuint`. It's also implicitly convertible to the built-in [floating-point](floating-point-numeric-types.md) numeric types: `float`, `double`, and `decimal`. It's explicitly convertible to `sbyte`, `byte`, and `short` integral types. There are no implicit conversions from other types to the `char` type. However, any [integral](integral-numeric-types.md) or [floating-point](floating-point-numeric-types.md) numeric type is explicitly convertible to `char`. From 7d0f6659dddc2357c63b9ab40e9a2e463ff61756 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 27 Feb 2025 12:58:53 -0500 Subject: [PATCH 5/7] Add links to latest breaking changes (#45048) Add links to the last two breaking changes docs. --- docs/visual-basic/whats-new/breaking-changes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/visual-basic/whats-new/breaking-changes.md b/docs/visual-basic/whats-new/breaking-changes.md index 98ba3c3ad7154..670326e18155a 100644 --- a/docs/visual-basic/whats-new/breaking-changes.md +++ b/docs/visual-basic/whats-new/breaking-changes.md @@ -10,6 +10,8 @@ ms.date: 08/18/2020 The [Roslyn](https://github.com/dotnet/roslyn) team maintains a list of breaking changes in the C# and Visual Basic compilers. You can find information on those changes at these links on their GitHub repository: +- [Compiler breaking changes in .NET 10](https://github.com/dotnet/roslyn/blob/main/docs/compilers/Visual%20Basic/Compiler%20Breaking%20Changes%20-%20DotNet%2010.md) +- [Compiler breaking changes in .NET 7](https://github.com/dotnet/roslyn/blob/main/docs/compilers/Visual%20Basic/Compiler%20Breaking%20Changes%20-%20DotNet%207.md) - [Breaking changes in VS2019 Update 1 and beyond compared to VS2019](https://github.com/dotnet/roslyn/blob/main/docs/compilers/Visual%20Basic/Compiler%20Breaking%20Changes%20-%20post%20VS2019.md) - [Breaking changes since VS2017 (VB 15)](https://github.com/dotnet/roslyn/blob/main/docs/compilers/Visual%20Basic/Compiler%20Breaking%20Changes%20-%20post%20VS2017.md) - [Breaking changes in Roslyn 3.0 (VS2019) from Roslyn 2.* (VS2017)](https://github.com/dotnet/roslyn/blob/main/docs/compilers/Visual%20Basic/Compiler%20Breaking%20Changes%20-%20VS2019.md) From 35ea73285429f9d195895bf8bce2b314a4cf489a Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:48:34 -0800 Subject: [PATCH 6/7] Use static HttpClient (#45026) --- ...tomation-expandcollapse-control-pattern.md | 2 +- ...ordebugprocess-gethelperthreadid-method.md | 2 +- .../networking/http/httpclient-guidelines.md | 31 ++----------------- .../snippets/httpclient-guidelines/MyClass.cs | 29 +++++++++++++++++ .../httpclient-guidelines/Project.csproj | 14 +++++++++ 5 files changed, 48 insertions(+), 30 deletions(-) create mode 100644 docs/fundamentals/networking/http/snippets/httpclient-guidelines/MyClass.cs create mode 100644 docs/fundamentals/networking/http/snippets/httpclient-guidelines/Project.csproj diff --git a/docs/framework/ui-automation/implementing-the-ui-automation-expandcollapse-control-pattern.md b/docs/framework/ui-automation/implementing-the-ui-automation-expandcollapse-control-pattern.md index dfb25199ca061..93c350a24a64f 100644 --- a/docs/framework/ui-automation/implementing-the-ui-automation-expandcollapse-control-pattern.md +++ b/docs/framework/ui-automation/implementing-the-ui-automation-expandcollapse-control-pattern.md @@ -38,7 +38,7 @@ When implementing the ExpandCollapse control pattern, note the following guideli - Calling on a TreeItem may display all descendants or only immediate children. - - If calling or on a control maintains the state of its descendants, a visibility change event should be sent, not a state change event If the parent control does not maintain the state of its descendants when collapsed, the control may destroy all the descendants that are no longer visible and raise a destroyed event; or it may change the for each descendant and raise a visibility change event. + - If calling or on a control maintains the state of its descendants, a visibility change event should be sent, not a state change event If the parent control does not maintain the state of its descendants when collapsed, the control may destroy all the descendants that are no longer visible and raise a destroyed event; or it might change the for each descendant and raise a visibility change event. - To guarantee navigation, it is desirable for an object to be in the UI Automation tree (with appropriate visibility state) regardless of its parents . If descendants are generated on demand, they may only appear in the UI Automation tree after being displayed for the first time or only while they are visible. diff --git a/docs/framework/unmanaged-api/debugging/icordebugprocess-gethelperthreadid-method.md b/docs/framework/unmanaged-api/debugging/icordebugprocess-gethelperthreadid-method.md index 7a028e57d306c..e9cefc78027f9 100644 --- a/docs/framework/unmanaged-api/debugging/icordebugprocess-gethelperthreadid-method.md +++ b/docs/framework/unmanaged-api/debugging/icordebugprocess-gethelperthreadid-method.md @@ -38,7 +38,7 @@ HRESULT GetHelperThreadID ( During managed and unmanaged debugging, it is the debugger's responsibility to ensure that the thread with the specified ID remains running if it hits a breakpoint placed by the debugger. A debugger may also wish to hide this thread from the user. If no helper thread exists in the process yet, the `GetHelperThreadID` method returns zero in *`pThreadID`. - You cannot cache the thread ID of the helper thread, because it may change over time. You must re-query the thread ID at every stopping event. + You cannot cache the thread ID of the helper thread, because it might change over time. You must re-query the thread ID at every stopping event. The thread ID of the debugger's helper thread will be correct on every unmanaged [ICorDebugManagedCallback::CreateThread](icordebugmanagedcallback-createthread-method.md) event, thus allowing a debugger to determine the thread ID of its helper thread and hide it from the user. A thread that is identified as a helper thread during an unmanaged `ICorDebugManagedCallback::CreateThread` event will never run managed user code. diff --git a/docs/fundamentals/networking/http/httpclient-guidelines.md b/docs/fundamentals/networking/http/httpclient-guidelines.md index 82f38d833ec0c..fdb97b6eb7cd0 100644 --- a/docs/fundamentals/networking/http/httpclient-guidelines.md +++ b/docs/fundamentals/networking/http/httpclient-guidelines.md @@ -58,32 +58,7 @@ For more information about managing `HttpClient` lifetime with `IHttpClientFacto It's possible to configure a `static` or *singleton* client to use any number of resilience pipelines using the following pattern: -```csharp -using System; -using System.Net.Http; -using Microsoft.Extensions.Http; -using Microsoft.Extensions.Http.Resilience; -using Polly; - -var retryPipeline = new ResiliencePipelineBuilder() - .AddRetry(new HttpRetryStrategyOptions - { - BackoffType = DelayBackoffType.Exponential, - MaxRetryAttempts = 3 - }) - .Build(); - -var socketHandler = new SocketsHttpHandler -{ - PooledConnectionLifetime = TimeSpan.FromMinutes(15) -}; -var resilienceHandler = new ResilienceHandler(retryPipeline) -{ - InnerHandler = socketHandler, -}; - -var httpClient = new HttpClient(resilienceHandler); -``` +:::code language="csharp" source="snippets/httpclient-guidelines/MyClass.cs"::: The preceding code: @@ -91,10 +66,10 @@ The preceding code: - Specifies a transient HTTP error handler, configured with retry pipeline that with each attempt will exponentially backoff delay intervals. - Defines a pooled connection lifetime of fifteen minutes for the `socketHandler`. - Passes the `socketHandler` to the `resilienceHandler` with the retry logic. -- Instantiates an `HttpClient` given the `resilienceHandler`. +- Instantiates a shared `HttpClient` given the `resilienceHandler`. > [!IMPORTANT] -> The `Microsoft.Extensions.Http.Resilience` library is currently marked as [experimental](../../../csharp/language-reference/attributes/general.md#experimental-attributes) and it may change in the future. +> The `Microsoft.Extensions.Http.Resilience` library is currently marked as [experimental](../../../csharp/language-reference/attributes/general.md#experimental-attributes) and it might change in the future. ## See also diff --git a/docs/fundamentals/networking/http/snippets/httpclient-guidelines/MyClass.cs b/docs/fundamentals/networking/http/snippets/httpclient-guidelines/MyClass.cs new file mode 100644 index 0000000000000..1d2cd441a0df8 --- /dev/null +++ b/docs/fundamentals/networking/http/snippets/httpclient-guidelines/MyClass.cs @@ -0,0 +1,29 @@ +using Microsoft.Extensions.Http.Resilience; +using Polly; + +class MyClass +{ + static HttpClient? httpClient; + + MyClass() + { + var retryPipeline = new ResiliencePipelineBuilder() + .AddRetry(new HttpRetryStrategyOptions + { + BackoffType = DelayBackoffType.Exponential, + MaxRetryAttempts = 3 + }) + .Build(); + + var socketHandler = new SocketsHttpHandler + { + PooledConnectionLifetime = TimeSpan.FromMinutes(15) + }; + var resilienceHandler = new ResilienceHandler(retryPipeline) + { + InnerHandler = socketHandler, + }; + + httpClient = new HttpClient(resilienceHandler); + } +} diff --git a/docs/fundamentals/networking/http/snippets/httpclient-guidelines/Project.csproj b/docs/fundamentals/networking/http/snippets/httpclient-guidelines/Project.csproj new file mode 100644 index 0000000000000..64837c9836027 --- /dev/null +++ b/docs/fundamentals/networking/http/snippets/httpclient-guidelines/Project.csproj @@ -0,0 +1,14 @@ + + + + Library + net9.0 + enable + enable + + + + + + + From cdb02b27dd3150b363022546e0e128e48897b844 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:49:04 -0800 Subject: [PATCH 7/7] AI evaluation quickstart (#45055) --- .openpublishing.redirection.ai.json | 38 +++++- docs/ai/ai-extensions.md | 4 +- docs/ai/dotnet-ai-ecosystem.md | 4 +- docs/ai/get-started/dotnet-ai-overview.md | 12 +- docs/ai/how-to/content-filtering.md | 2 +- docs/ai/index.yml | 2 + ...et-started-openai.md => build-chat-app.md} | 4 +- ...ith-data.md => build-vector-search-app.md} | 4 +- ...kstart-local-ai.md => chat-local-model.md} | 4 +- ...tart-assistants.md => create-assistant.md} | 0 docs/ai/quickstarts/evaluate-ai-response.md | 116 ++++++++++++++++++ ...-generate-images.md => generate-images.md} | 2 +- .../quickstarts/includes/clone-sample-repo.md | 2 +- ...enai-summarize-text.md => prompt-model.md} | 2 +- .../snippets/evaluate-ai-responses/MyTests.cs | 85 +++++++++++++ .../evaluate-ai-responses/TestAI.csproj | 23 ++++ ...openai-tool.md => use-function-calling.md} | 2 +- docs/ai/semantic-kernel-dotnet-overview.md | 4 +- docs/ai/toc.yml | 16 +-- .../extensions/artificial-intelligence.md | 2 +- docs/whats-new/dotnet-docs-mod0.md | 2 +- docs/whats-new/dotnet-docs-mod1.md | 2 +- 22 files changed, 294 insertions(+), 38 deletions(-) rename docs/ai/quickstarts/{get-started-openai.md => build-chat-app.md} (96%) rename docs/ai/quickstarts/{quickstart-ai-chat-with-data.md => build-vector-search-app.md} (98%) rename docs/ai/quickstarts/{quickstart-local-ai.md => chat-local-model.md} (97%) rename docs/ai/quickstarts/{quickstart-assistants.md => create-assistant.md} (100%) create mode 100644 docs/ai/quickstarts/evaluate-ai-response.md rename docs/ai/quickstarts/{quickstart-openai-generate-images.md => generate-images.md} (98%) rename docs/ai/quickstarts/{quickstart-openai-summarize-text.md => prompt-model.md} (98%) create mode 100644 docs/ai/quickstarts/snippets/evaluate-ai-responses/MyTests.cs create mode 100644 docs/ai/quickstarts/snippets/evaluate-ai-responses/TestAI.csproj rename docs/ai/quickstarts/{quickstart-azure-openai-tool.md => use-function-calling.md} (98%) diff --git a/.openpublishing.redirection.ai.json b/.openpublishing.redirection.ai.json index 553533a2de2ef..f511610dc5ef2 100644 --- a/.openpublishing.redirection.ai.json +++ b/.openpublishing.redirection.ai.json @@ -1,8 +1,8 @@ { "redirections": [ { - "source_path_from_root": "/docs/ai/quickstarts/get-started-azure-openai.md", - "redirect_url": "/dotnet/ai/quickstarts/get-started-openai" + "source_path_from_root": "/docs/ai/how-to/app-service-db-auth.md", + "redirect_url": "/dotnet/ai" }, { "source_path_from_root": "/docs/ai/how-to/use-redis-for-memory.md", @@ -13,8 +13,36 @@ "redirect_url": "/dotnet/ai" }, { - "source_path_from_root": "/docs/ai/how-to/app-service-db-auth.md", - "redirect_url": "/dotnet/ai" + "source_path_from_root": "/docs/ai/quickstarts/get-started-azure-openai.md", + "redirect_url": "/dotnet/ai/quickstarts/build-chat-app" + }, + { + "source_path_from_root": "/docs/ai/quickstarts/get-started-openai.md", + "redirect_url": "/dotnet/ai/quickstarts/build-chat-app" + }, + { + "source_path_from_root": "/docs/ai/quickstarts/quickstart-ai-chat-with-data.md", + "redirect_url": "/dotnet/ai/quickstarts/build-vector-search-app" + }, + { + "source_path_from_root": "/docs/ai/quickstarts/quickstart-assistants.md", + "redirect_url": "/dotnet/ai/quickstarts/create-assistant" + }, + { + "source_path_from_root": "/docs/ai/quickstarts/quickstart-azure-openai-tool.md", + "redirect_url": "/dotnet/ai/quickstarts/use-function-calling" + }, + { + "source_path_from_root": "/docs/ai/quickstarts/quickstart-local-ai.md", + "redirect_url": "/dotnet/ai/quickstarts/chat-local-model" + }, + { + "source_path_from_root": "/docs/ai/quickstarts/quickstart-openai-generate-images.md", + "redirect_url": "/dotnet/ai/quickstarts/generate-images" + }, + { + "source_path_from_root": "/docs/ai/quickstarts/quickstart-openai-summarize-text.md", + "redirect_url": "/dotnet/ai/quickstarts/prompt-model" } ] -} \ No newline at end of file +} diff --git a/docs/ai/ai-extensions.md b/docs/ai/ai-extensions.md index 45a0e8da778a1..62afd7f8ac982 100644 --- a/docs/ai/ai-extensions.md +++ b/docs/ai/ai-extensions.md @@ -99,5 +99,5 @@ For an end-to-end sample using `Microsoft.Extensions.AI`, see [eShopSupport](htt ## Next steps -- [Build an AI chat app with .NET](./quickstarts/get-started-openai.md) -- [Quickstart - Summarize text using Azure AI chat app with .NET](./quickstarts/quickstart-openai-summarize-text.md) +- [Build an AI chat app with .NET](/dotnet/ai/quickstarts/build-chat-app) +- [Quickstart - Summarize text using Azure AI chat app with .NET](/dotnet/ai/quickstarts/prompt-model) diff --git a/docs/ai/dotnet-ai-ecosystem.md b/docs/ai/dotnet-ai-ecosystem.md index f7bda779e1049..a44f61c27f90f 100644 --- a/docs/ai/dotnet-ai-ecosystem.md +++ b/docs/ai/dotnet-ai-ecosystem.md @@ -63,7 +63,7 @@ Azure offers many other AI services to build specific application capabilities a .NET apps can also connect to local AI models for many different development scenarios. [Semantic Kernel](https://github.com/microsoft/semantic-kernel) is the recommended tool to connect to local models using .NET. Semantic Kernel can connect to many different models hosted across a variety of platforms and abstracts away lower-level implementation details. -For example, you can use [Ollama](https://ollama.com/) to [connect to local AI models with .NET](quickstarts/quickstart-local-ai.md), including several small language models (SLMs) developed by Microsoft: +For example, you can use [Ollama](https://ollama.com/) to [connect to local AI models with .NET](/dotnet/ai/quickstarts/chat-local-model), including several small language models (SLMs) developed by Microsoft: | Model | Description | |---------------------|-----------------------------------------------------------| @@ -84,7 +84,7 @@ This article summarized the tools and SDKs in the .NET ecosystem, with a focus o ## Next steps - [What is Semantic Kernel?](/semantic-kernel/overview/) -- [Quickstart - Summarize text using Azure AI chat app with .NET](./quickstarts/quickstart-openai-summarize-text.md) +- [Quickstart - Summarize text using Azure AI chat app with .NET](/dotnet/ai/quickstarts/prompt-model) [phi3]: https://azure.microsoft.com/products/phi-3 [orca]: https://www.microsoft.com/research/project/orca/ diff --git a/docs/ai/get-started/dotnet-ai-overview.md b/docs/ai/get-started/dotnet-ai-overview.md index 7aa4961e0b26a..a7d756756c414 100644 --- a/docs/ai/get-started/dotnet-ai-overview.md +++ b/docs/ai/get-started/dotnet-ai-overview.md @@ -36,16 +36,16 @@ We recommend the following sequence of tutorials and articles for an introductio | Scenario | Tutorial | |----------|----------| -| Create a chat application | [Build an Azure AI chat app with .NET](../quickstarts/get-started-openai.md)| -| Summarize text | [Summarize text using Azure AI chat app with .NET](../quickstarts/quickstart-openai-summarize-text.md) | -| Chat with your data | [Get insight about your data from an .NET Azure AI chat app](../quickstarts/quickstart-ai-chat-with-data.md) | -| Call .NET functions with AI | [Extend Azure AI using tools and execute a local function with .NET](../quickstarts/quickstart-azure-openai-tool.md) | -| Generate images | [Generate images using Azure AI with .NET](../quickstarts/quickstart-openai-generate-images.md) | +| Create a chat application | [Build an Azure AI chat app with .NET](/dotnet/ai/quickstarts/build-chat-app)| +| Summarize text | [Summarize text using Azure AI chat app with .NET](/dotnet/ai/quickstarts/prompt-model) | +| Chat with your data | [Get insight about your data from an .NET Azure AI chat app](/dotnet/ai/quickstarts/build-vector-search-app) | +| Call .NET functions with AI | [Extend Azure AI using tools and execute a local function with .NET](/dotnet/ai/quickstarts/use-function-calling) | +| Generate images | [Generate images using Azure AI with .NET](/dotnet/ai/quickstarts/generate-images) | | Train your own model |[ML.NET tutorial](https://dotnet.microsoft.com/learn/ml-dotnet/get-started-tutorial/intro) | Browse the table of contents to learn more about the core concepts, starting with [How generative AI and LLMs work](../conceptual/how-genai-and-llms-work.md). ## Next steps -- [Quickstart: Build an Azure AI chat app with .NET](../quickstarts/get-started-openai.md) +- [Quickstart: Build an Azure AI chat app with .NET](/dotnet/ai/quickstarts/build-chat-app) - [Video series: Machine Learning and AI with .NET](/shows/machine-learning-and-ai-with-dotnet-for-beginners) diff --git a/docs/ai/how-to/content-filtering.md b/docs/ai/how-to/content-filtering.md index e3227c8a77b04..7578093e2b261 100644 --- a/docs/ai/how-to/content-filtering.md +++ b/docs/ai/how-to/content-filtering.md @@ -49,4 +49,4 @@ The response was filtered due to the prompt triggering Azure OpenAI's content ma * [Create and assign a content filter](/azure/ai-services/openai/how-to/content-filters) * [Content Filtering concepts](/azure/ai-services/openai/concepts/content-filter) -* [Create a chat app](../quickstarts/quickstart-openai-summarize-text.md) +* [Create a chat app](/dotnet/ai/quickstarts/prompt-model) diff --git a/docs/ai/index.yml b/docs/ai/index.yml index 735f081f15350..b0032410d90da 100644 --- a/docs/ai/index.yml +++ b/docs/ai/index.yml @@ -49,6 +49,8 @@ landingContent: url: conceptual/vector-databases.md - text: Prompt engineering url: conceptual/prompt-engineering-dotnet.md + - text: Evaluation libraries + url: conceptual/evaluation-libraries.md # Card (Optional; Remove if not applicable.) - title: Common tasks diff --git a/docs/ai/quickstarts/get-started-openai.md b/docs/ai/quickstarts/build-chat-app.md similarity index 96% rename from docs/ai/quickstarts/get-started-openai.md rename to docs/ai/quickstarts/build-chat-app.md index b1e919042d596..ed45ee1acee43 100644 --- a/docs/ai/quickstarts/get-started-openai.md +++ b/docs/ai/quickstarts/build-chat-app.md @@ -153,5 +153,5 @@ azd down ## Next steps -- [Quickstart - Chat with a local AI model](quickstart-local-ai.md) -- [Generate images using AI with .NET](quickstart-openai-generate-images.md) +- [Quickstart - Chat with a local AI model](/dotnet/ai/quickstarts/chat-local-model) +- [Generate images using AI with .NET](/dotnet/ai/quickstarts/generate-images) diff --git a/docs/ai/quickstarts/quickstart-ai-chat-with-data.md b/docs/ai/quickstarts/build-vector-search-app.md similarity index 98% rename from docs/ai/quickstarts/quickstart-ai-chat-with-data.md rename to docs/ai/quickstarts/build-vector-search-app.md index 8daff4a8cba14..9959a14b4b192 100644 --- a/docs/ai/quickstarts/quickstart-ai-chat-with-data.md +++ b/docs/ai/quickstarts/build-vector-search-app.md @@ -205,5 +205,5 @@ azd down ## Next steps -- [Quickstart - Chat with a local AI model](quickstart-local-ai.md) -- [Generate images using AI with .NET](quickstart-openai-generate-images.md) +- [Quickstart - Chat with a local AI model](/dotnet/ai/quickstarts/chat-local-model) +- [Generate images using AI with .NET](/dotnet/ai/quickstarts/generate-images) diff --git a/docs/ai/quickstarts/quickstart-local-ai.md b/docs/ai/quickstarts/chat-local-model.md similarity index 97% rename from docs/ai/quickstarts/quickstart-local-ai.md rename to docs/ai/quickstarts/chat-local-model.md index 8bd22c102f4d5..bc7ca0c11e373 100644 --- a/docs/ai/quickstarts/quickstart-local-ai.md +++ b/docs/ai/quickstarts/chat-local-model.md @@ -20,7 +20,7 @@ In this quickstart, you learn how to create a conversational .NET console chat a ## Run the local AI model -Complete the following steps to configure and run a local AI Model on your device. Many different AI models are available to run locally and are trained for different tasks, such as generating code, analyzing images, generative chat, or creating embeddings. For this quickstart, you'll use the general purpose `phi3:mini` model, which is a small but capable generative AI created by Microsoft. +Complete the following steps to configure and run a local AI model on your device. Many different AI models are available to run locally and are trained for different tasks, such as generating code, analyzing images, generative chat, or creating embeddings. For this quickstart, you'll use the general purpose `phi3:mini` model, which is a small but capable generative AI created by Microsoft. 1. Open a terminal window and verify that Ollama is available on your device: @@ -54,7 +54,7 @@ Complete the following steps to configure and run a local AI Model on your devic ## Create the .NET app -Complete the following steps to create a .NET console app that will connect to your local `phi3:mini` AI model: +Complete the following steps to create a .NET console app that connects to your local `phi3:mini` AI model. 1. In a terminal window, navigate to an empty directory on your device and create a new app with the `dotnet new` command: diff --git a/docs/ai/quickstarts/quickstart-assistants.md b/docs/ai/quickstarts/create-assistant.md similarity index 100% rename from docs/ai/quickstarts/quickstart-assistants.md rename to docs/ai/quickstarts/create-assistant.md diff --git a/docs/ai/quickstarts/evaluate-ai-response.md b/docs/ai/quickstarts/evaluate-ai-response.md new file mode 100644 index 0000000000000..59084c736bbd6 --- /dev/null +++ b/docs/ai/quickstarts/evaluate-ai-response.md @@ -0,0 +1,116 @@ +--- +title: Quickstart - Evaluate a model's response +description: Learn how to create an MSTest app to evaluate the AI chat response of a language model. +ms.date: 02/25/2025 +ms.topic: quickstart +ms.custom: devx-track-dotnet, devx-track-dotnet-ai +--- + +# Evaluate a model's response + +In this quickstart, you create an MSTest app to evaluate the chat response of a model. The test app uses the [Microsoft.Extensions.AI.Evaluation](https://www.nuget.org/packages/Microsoft.Extensions.AI.Evaluation) libraries. + +## Prerequisites + +- [Install .NET 8.0](https://dotnet.microsoft.com/download) or a later version +- [Install Ollama](https://ollama.com/) locally on your machine +- [Visual Studio Code](https://code.visualstudio.com/) (optional) + +## Run the local AI model + +Complete the following steps to configure and run a local AI model on your device. For this quickstart, you'll use the general purpose `phi3:mini` model, which is a small but capable generative AI created by Microsoft. + +1. Open a terminal window and verify that Ollama is available on your device: + + ```bash + ollama + ``` + + If Ollama is available, it displays a list of available commands. + +1. Start Ollama: + + ```bash + ollama serve + ``` + + If Ollama is running, it displays a list of available commands. + +1. Pull the `phi3:mini` model from the Ollama registry and wait for it to download: + + ```bash + ollama pull phi3:mini + ``` + +1. After the download completes, run the model: + + ```bash + ollama run phi3:mini + ``` + + Ollama starts the `phi3:mini` model and provides a prompt for you to interact with it. + +## Create the test app + +Complete the following steps to create an MSTest project that connects to your local `phi3:mini` AI model. + +1. In a terminal window, navigate to the directory where you want to create your app, and create a new MSTest app with the `dotnet new` command: + + ```dotnetcli + dotnet new mstest -o TestAI + ``` + +1. Navigate to the `TestAI` directory, and add the necessary packages to your app: + + ```dotnetcli + dotnet add package Microsoft.Extensions.AI.Ollama --prerelease + dotnet add package Microsoft.Extensions.AI.Abstractions --prerelease + dotnet add package Microsoft.Extensions.AI.Evaluation --prerelease + dotnet add package Microsoft.Extensions.AI.Evaluation.Quality --prerelease + ``` + +1. Open the new app in your editor of choice, such as Visual Studio Code. + + ```dotnetcli + code . + ``` + +## Add the test app code + +1. Rename the file *Test1.cs* to *MyTests.cs*, and then open the file and rename the class to `MyTests`. +1. Add the private and chat message and response members to the `MyTests` class. The `s_messages` field is a list that contains two objects—one instructs the behavior of the chat bot, and the other is the question from the user. + + :::code language="csharp" source="./snippets/evaluate-ai-responses/MyTests.cs" id="PrivateMembers"::: + +1. Add the `InitializeAsync` method to the `MyTests` class. + + :::code language="csharp" source="./snippets/evaluate-ai-responses/MyTests.cs" id="Initialize"::: + + This methods accomplishes the following tasks: + + - Sets up the . + - Sets the , including the and the . + - Fetches the response to be evaluated by calling , and stores it in a static variable. + +1. Add the `GetOllamaChatConfiguration` method, which creates the that the evaluator uses to communicate with the model. + + :::code language="csharp" source="./snippets/evaluate-ai-responses/MyTests.cs" id="GetChatConfig"::: + +1. Add a test method to evaluate the model's response. + + :::code language="csharp" source="./snippets/evaluate-ai-responses/MyTests.cs" id="TestCoherence"::: + + This method does the following: + + - Invokes the to evaluate the *coherence* of the response. The method returns an that contains a . A `NumericMetric` contains a numeric value that's typically used to represent numeric scores that fall within a well-defined range. + - Retrieves the coherence score from the . + - Validates the *default interpretation* for the returned coherence metric. Evaluators can include a default interpretation for the metrics they return. You can also change the default interpretation to suit your specific requirements, if needed. + - Validates that no diagnostics are present on the returned coherence metric. Evaluators can include diagnostics on the metrics they return to indicate errors, warnings, or other exceptional conditions encountered during evaluation. + +## Run the test/evaluation + +Run the test using your preferred test workflow, for example, by using the CLI command `dotnet test` or through [Test Explorer](/visualstudio/test/run-unit-tests-with-test-explorer). + +## Next steps + +Next, try evaluating against different models to see if the results change. Then, check out the extensive examples in the [dotnet/ai-samples repo](https://github.com/dotnet/ai-samples/blob/main/src/microsoft-extensions-ai-evaluation/api/) to see how to invoke multiple evaluators, add additional context, invoke a custom evaluator, attach diagnostics, or change the default interpretation of metrics. diff --git a/docs/ai/quickstarts/quickstart-openai-generate-images.md b/docs/ai/quickstarts/generate-images.md similarity index 98% rename from docs/ai/quickstarts/quickstart-openai-generate-images.md rename to docs/ai/quickstarts/generate-images.md index 1c2bdec543848..14616350f68c9 100644 --- a/docs/ai/quickstarts/quickstart-openai-generate-images.md +++ b/docs/ai/quickstarts/generate-images.md @@ -144,5 +144,5 @@ azd down ## Next steps -- [Quickstart - Build an AI chat app with .NET](get-started-openai.md) +- [Quickstart - Build an AI chat app with .NET](/dotnet/ai/quickstarts/build-chat-app) - [Generate text and conversations with .NET and Azure OpenAI Completions](/training/modules/open-ai-dotnet-text-completions/) diff --git a/docs/ai/quickstarts/includes/clone-sample-repo.md b/docs/ai/quickstarts/includes/clone-sample-repo.md index c27f5d28d91b0..4a9c2d64568b7 100644 --- a/docs/ai/quickstarts/includes/clone-sample-repo.md +++ b/docs/ai/quickstarts/includes/clone-sample-repo.md @@ -7,7 +7,7 @@ ms.topic: include ## Clone the sample repository - You can create your own app using the steps in the sections ahead, or you can clone the GitHub repository that contains the completed sample apps for all of the quickstarts. If you plan to use Azure OpenAI, the sample repo is also structured as an Azure Developer CLI template that can provision an Azure OpenAI resource for you. +You can create your own app using the steps in the sections ahead, or you can clone the GitHub repository that contains the completed sample apps for all of the quickstarts. If you plan to use Azure OpenAI, the sample repo is also structured as an Azure Developer CLI template that can provision an Azure OpenAI resource for you. ```bash git clone https://github.com/dotnet/ai-samples.git diff --git a/docs/ai/quickstarts/quickstart-openai-summarize-text.md b/docs/ai/quickstarts/prompt-model.md similarity index 98% rename from docs/ai/quickstarts/quickstart-openai-summarize-text.md rename to docs/ai/quickstarts/prompt-model.md index 6cf25d3cee90a..76982282aefe2 100644 --- a/docs/ai/quickstarts/quickstart-openai-summarize-text.md +++ b/docs/ai/quickstarts/prompt-model.md @@ -153,5 +153,5 @@ azd down ## Next steps -- [Quickstart - Build an AI chat app with .NET](get-started-openai.md) +- [Quickstart - Build an AI chat app with .NET](/dotnet/ai/quickstarts/build-chat-app) - [Generate text and conversations with .NET and Azure OpenAI Completions](/training/modules/open-ai-dotnet-text-completions/) diff --git a/docs/ai/quickstarts/snippets/evaluate-ai-responses/MyTests.cs b/docs/ai/quickstarts/snippets/evaluate-ai-responses/MyTests.cs new file mode 100644 index 0000000000000..019793d552f77 --- /dev/null +++ b/docs/ai/quickstarts/snippets/evaluate-ai-responses/MyTests.cs @@ -0,0 +1,85 @@ +using Microsoft.Extensions.AI; +using Microsoft.Extensions.AI.Evaluation; +using Microsoft.Extensions.AI.Evaluation.Quality; + +namespace TestAI; + +[TestClass] +public sealed class MyTests +{ + // + private static ChatConfiguration? s_chatConfiguration; + private static IList s_messages = [ + new ChatMessage( + ChatRole.System, + """ + You're an AI assistant that can answer questions related to astronomy. + Keep your responses concise and try to stay under 100 words. + Use the imperial measurement system for all measurements in your response. + """), + new ChatMessage( + ChatRole.User, + "How far is the planet Venus from Earth at its closest and furthest points?")]; + private static ChatMessage s_response = new(); + // + + // + [ClassInitialize] + public static async Task InitializeAsync(TestContext _) + { + /// Set up the , + // which includes the that the + /// evaluator uses to communicate with the model. + s_chatConfiguration = GetOllamaChatConfiguration(); + + var chatOptions = + new ChatOptions + { + Temperature = 0.0f, + ResponseFormat = ChatResponseFormat.Text + }; + + /// Fetch the response to be evaluated + // and store it in a static variable. + ChatResponse response = await s_chatConfiguration.ChatClient.GetResponseAsync(s_messages, chatOptions); + s_response = response.Message; + } + // + + // + private static ChatConfiguration GetOllamaChatConfiguration() + { + /// Get a chat client for the Ollama endpoint. + IChatClient client = + new OllamaChatClient( + new Uri("http://localhost:11434"), + modelId: "phi3:mini"); + + return new ChatConfiguration(client); + } + // + + // + [TestMethod] + public async Task TestCoherence() + { + IEvaluator coherenceEvaluator = new CoherenceEvaluator(); + EvaluationResult result = await coherenceEvaluator.EvaluateAsync( + s_messages, + s_response, + s_chatConfiguration); + + /// Retrieve the score for coherence from the . + NumericMetric coherence = result.Get(CoherenceEvaluator.CoherenceMetricName); + + /// Validate the default interpretation + // for the returned coherence metric. + Assert.IsFalse(coherence.Interpretation!.Failed); + Assert.IsTrue(coherence.Interpretation.Rating is EvaluationRating.Good or EvaluationRating.Exceptional); + + // Validate that no diagnostics are present + // on the returned coherence metric. + Assert.IsFalse(coherence.ContainsDiagnostics()); + } + // +} diff --git a/docs/ai/quickstarts/snippets/evaluate-ai-responses/TestAI.csproj b/docs/ai/quickstarts/snippets/evaluate-ai-responses/TestAI.csproj new file mode 100644 index 0000000000000..05450bd762c47 --- /dev/null +++ b/docs/ai/quickstarts/snippets/evaluate-ai-responses/TestAI.csproj @@ -0,0 +1,23 @@ + + + + net9.0 + latest + enable + enable + + + + + + + + + + + + + + + + diff --git a/docs/ai/quickstarts/quickstart-azure-openai-tool.md b/docs/ai/quickstarts/use-function-calling.md similarity index 98% rename from docs/ai/quickstarts/quickstart-azure-openai-tool.md rename to docs/ai/quickstarts/use-function-calling.md index 1fb473bfd790b..c62fe7d5f1957 100644 --- a/docs/ai/quickstarts/quickstart-azure-openai-tool.md +++ b/docs/ai/quickstarts/use-function-calling.md @@ -154,5 +154,5 @@ azd down ## Next steps -- [Quickstart - Build an AI chat app with .NET](get-started-openai.md) +- [Quickstart - Build an AI chat app with .NET](/dotnet/ai/quickstarts/build-chat-app) - [Generate text and conversations with .NET and Azure OpenAI Completions](/training/modules/open-ai-dotnet-text-completions/) diff --git a/docs/ai/semantic-kernel-dotnet-overview.md b/docs/ai/semantic-kernel-dotnet-overview.md index b0e25dfc6200a..f2ee3e0f43b61 100644 --- a/docs/ai/semantic-kernel-dotnet-overview.md +++ b/docs/ai/semantic-kernel-dotnet-overview.md @@ -213,5 +213,5 @@ foreach (var fact in facts) { The preceding code loads a set of facts into memory so that the data is available to use when interacting with AI models and orchestrating tasks. >[!div class="step-by-step"] ->[Quickstart - Summarize text with OpenAI](quickstarts/quickstart-openai-summarize-text.md) ->[Quickstart - Chat with your data](quickstarts/quickstart-ai-chat-with-data.md) +>[Quickstart - Summarize text with OpenAI](/dotnet/ai/quickstarts/prompt-model) +>[Quickstart - Chat with your data](/dotnet/ai/quickstarts/build-vector-search-app) diff --git a/docs/ai/toc.yml b/docs/ai/toc.yml index c0b9b22243300..2fa6a78530998 100644 --- a/docs/ai/toc.yml +++ b/docs/ai/toc.yml @@ -4,7 +4,7 @@ items: - name: Overview href: get-started/dotnet-ai-overview.md - name: "Quickstart: Connect to and prompt an AI model" - href: quickstarts/quickstart-openai-summarize-text.md + href: /dotnet/ai/quickstarts/prompt-model - name: AI frameworks and SDKs items: - name: Overview @@ -16,17 +16,17 @@ items: - name: Quickstarts items: - name: Build a chat app - href: quickstarts/get-started-openai.md + href: /dotnet/ai/quickstarts/build-chat-app - name: Build a .NET AI vector search app - href: quickstarts/quickstart-ai-chat-with-data.md + href: /dotnet/ai/quickstarts/build-vector-search-app - name: Execute a local .NET function - href: quickstarts/quickstart-azure-openai-tool.md + href: /dotnet/ai/quickstarts/use-function-calling - name: Generate images - href: quickstarts/quickstart-openai-generate-images.md + href: /dotnet/ai/quickstarts/generate-images - name: Chat with a local AI model - href: quickstarts/quickstart-local-ai.md + href: /dotnet/ai/quickstarts/chat-local-model - name: Build a minimal AI assistant - href: quickstarts/quickstart-assistants.md + href: /dotnet/ai/quickstarts/create-assistant - name: Concepts items: - name: How generative AI and LLMs work @@ -75,6 +75,8 @@ items: items: - name: The Microsoft.Extensions.AI.Evaluation libraries href: conceptual/evaluation-libraries.md + - name: "Quickstart: Evaluate a model's response" + href: quickstarts/evaluate-ai-response.md - name: "Tutorial: Evaluate LLM prompt completions" href: tutorials/llm-eval.md - name: Resources diff --git a/docs/core/extensions/artificial-intelligence.md b/docs/core/extensions/artificial-intelligence.md index 8ad669af2a732..4c89abdbb3da5 100644 --- a/docs/core/extensions/artificial-intelligence.md +++ b/docs/core/extensions/artificial-intelligence.md @@ -274,7 +274,7 @@ In this way, the `RateLimitingEmbeddingGenerator` can be composed with other `IE - [Develop .NET applications with AI features](../../ai/get-started/dotnet-ai-overview.md) - [Unified AI building blocks for .NET using Microsoft.Extensions.AI](../../ai/ai-extensions.md) -- [Build an AI chat app with .NET](../../ai/quickstarts/get-started-openai.md) +- [Build an AI chat app with .NET](/dotnet/ai/quickstarts/build-chat-app) - [.NET dependency injection](dependency-injection.md) - [Rate limit an HTTP handler in .NET](http-ratelimiter.md) - [.NET Generic Host](generic-host.md) diff --git a/docs/whats-new/dotnet-docs-mod0.md b/docs/whats-new/dotnet-docs-mod0.md index 35581513d5d0a..38c0b0b313226 100644 --- a/docs/whats-new/dotnet-docs-mod0.md +++ b/docs/whats-new/dotnet-docs-mod0.md @@ -23,7 +23,7 @@ Welcome to what's new in the .NET docs for December 2024. This article lists som ### Updated articles -- [Build a .NET AI vector search app](../ai/quickstarts/quickstart-ai-chat-with-data.md) - New vector search quickstart +- [Build a .NET AI vector search app](/dotnet/ai/quickstarts/build-vector-search-app) - New vector search quickstart ## ML.NET diff --git a/docs/whats-new/dotnet-docs-mod1.md b/docs/whats-new/dotnet-docs-mod1.md index e541843080de7..dd2031bda3a58 100644 --- a/docs/whats-new/dotnet-docs-mod1.md +++ b/docs/whats-new/dotnet-docs-mod1.md @@ -31,7 +31,7 @@ Welcome to what's new in the .NET docs for January 2025. This article lists some ### New articles -- [Create a minimal AI assistant using .NET](../ai/quickstarts/quickstart-assistants.md) +- [Create a minimal AI assistant using .NET](/dotnet/ai/quickstarts/create-assistant) ## .NET fundamentals