diff --git a/docs/azure/includes/dotnet-all.md b/docs/azure/includes/dotnet-all.md index d9a7b46846fe7..662b3ac7822af 100644 --- a/docs/azure/includes/dotnet-all.md +++ b/docs/azure/includes/dotnet-all.md @@ -27,7 +27,7 @@ | Content Safety | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.ContentSafety/1.0.0) | [docs](/dotnet/api/overview/azure/AI.ContentSafety-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.ContentSafety_1.0.0/sdk/contentsafety/Azure.AI.ContentSafety/) | | Conversational Language Understanding | NuGet [1.1.0](https://www.nuget.org/packages/Azure.AI.Language.Conversations/1.1.0)
NuGet [2.0.0-beta.1](https://www.nuget.org/packages/Azure.AI.Language.Conversations/2.0.0-beta.1) | [docs](/dotnet/api/overview/azure/AI.Language.Conversations-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_1.1.0/sdk/cognitivelanguage/Azure.AI.Language.Conversations/)
GitHub [2.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_2.0.0-beta.1/sdk/cognitivelanguage/Azure.AI.Language.Conversations/) | | Core - Client - AMQP | NuGet [1.3.1](https://www.nuget.org/packages/Azure.Core.Amqp/1.3.1) | [docs](/dotnet/api/overview/azure/Core.Amqp-readme) | GitHub [1.3.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core.Amqp_1.3.1/sdk/core/Azure.Core.Amqp/) | -| Core - Client - Core | NuGet [1.43.0](https://www.nuget.org/packages/Azure.Core/1.43.0) | [docs](/dotnet/api/overview/azure/Core-readme) | GitHub [1.43.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core_1.43.0/sdk/core/Azure.Core/) | +| Core - Client - Core | NuGet [1.44.0](https://www.nuget.org/packages/Azure.Core/1.44.0) | [docs](/dotnet/api/overview/azure/Core-readme) | GitHub [1.44.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core_1.44.0/sdk/core/Azure.Core/) | | Core Newtonsoft Json | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.Core.NewtonsoftJson/2.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Core.NewtonsoftJson-readme) | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.NewtonsoftJson_2.0.0/sdk/core/Microsoft.Azure.Core.NewtonsoftJson/) | | Core WCF Storage Queues | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Microsoft.CoreWCF.Azure.StorageQueues/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Microsoft.CoreWCF.Azure.StorageQueues-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.CoreWCF.Azure.StorageQueues_1.0.0-beta.1/sdk/extension-wcf/Microsoft.CoreWCF.Azure.StorageQueues/) | | Data Movement | NuGet [12.0.0-beta.5](https://www.nuget.org/packages/Azure.Storage.DataMovement/12.0.0-beta.5) | [docs](/dotnet/api/overview/azure/Storage.DataMovement-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [12.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.DataMovement_12.0.0-beta.5/sdk/storage/Azure.Storage.DataMovement/) | @@ -120,7 +120,7 @@ | Synapse - Monitoring | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Analytics.Synapse.Monitoring/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Monitoring-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Monitoring_1.0.0-beta.3/sdk/synapse/Azure.Analytics.Synapse.Monitoring/) | | Synapse - Spark | NuGet [1.0.0-preview.8](https://www.nuget.org/packages/Azure.Analytics.Synapse.Spark/1.0.0-preview.8) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Spark-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-preview.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Spark_1.0.0-preview.8/sdk/synapse/Azure.Analytics.Synapse.Spark/) | | System Events | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Messaging.EventGrid.SystemEvents/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Messaging.EventGrid.SystemEvents-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid.SystemEvents_1.0.0-beta.1/sdk/eventgrid/Azure.Messaging.EventGrid.SystemEvents/) | -| System.ClientModel | NuGet [1.1.0](https://www.nuget.org/packages/System.ClientModel/1.1.0) | [docs](/dotnet/api/overview/azure/System.ClientModel-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/System.ClientModel_1.1.0/sdk/core/System.ClientModel/) | +| System.ClientModel | NuGet [1.2.0](https://www.nuget.org/packages/System.ClientModel/1.2.0) | [docs](/dotnet/api/overview/azure/System.ClientModel-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/System.ClientModel_1.2.0/sdk/core/System.ClientModel/) | | Tables | NuGet [12.9.1](https://www.nuget.org/packages/Azure.Data.Tables/12.9.1) | [docs](/dotnet/api/overview/azure/Data.Tables-readme) | GitHub [12.9.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.Tables_12.9.1/sdk/tables/Azure.Data.Tables/) | | Text Analytics | NuGet [5.3.0](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.3.0) | [docs](/dotnet/api/overview/azure/AI.TextAnalytics-readme) | GitHub [5.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.3.0/sdk/textanalytics/Azure.AI.TextAnalytics/) | | Text Translation | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.Translation.Text/1.0.0) | [docs](/dotnet/api/overview/azure/AI.Translation.Text-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Translation.Text_1.0.0/sdk/translation/Azure.AI.Translation.Text/) | diff --git a/docs/azure/includes/dotnet-new.md b/docs/azure/includes/dotnet-new.md index 4e61df4c9653b..817394753dbd2 100644 --- a/docs/azure/includes/dotnet-new.md +++ b/docs/azure/includes/dotnet-new.md @@ -28,7 +28,7 @@ | Content Safety | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.ContentSafety/1.0.0) | [docs](/dotnet/api/overview/azure/AI.ContentSafety-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.ContentSafety_1.0.0/sdk/contentsafety/Azure.AI.ContentSafety/) | | Conversational Language Understanding | NuGet [1.1.0](https://www.nuget.org/packages/Azure.AI.Language.Conversations/1.1.0)
NuGet [2.0.0-beta.1](https://www.nuget.org/packages/Azure.AI.Language.Conversations/2.0.0-beta.1) | [docs](/dotnet/api/overview/azure/AI.Language.Conversations-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_1.1.0/sdk/cognitivelanguage/Azure.AI.Language.Conversations/)
GitHub [2.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_2.0.0-beta.1/sdk/cognitivelanguage/Azure.AI.Language.Conversations/) | | Core - Client - AMQP | NuGet [1.3.1](https://www.nuget.org/packages/Azure.Core.Amqp/1.3.1) | [docs](/dotnet/api/overview/azure/Core.Amqp-readme) | GitHub [1.3.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core.Amqp_1.3.1/sdk/core/Azure.Core.Amqp/) | -| Core - Client - Core | NuGet [1.43.0](https://www.nuget.org/packages/Azure.Core/1.43.0) | [docs](/dotnet/api/overview/azure/Core-readme) | GitHub [1.43.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core_1.43.0/sdk/core/Azure.Core/) | +| Core - Client - Core | NuGet [1.44.0](https://www.nuget.org/packages/Azure.Core/1.44.0) | [docs](/dotnet/api/overview/azure/Core-readme) | GitHub [1.44.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core_1.44.0/sdk/core/Azure.Core/) | | Core Newtonsoft Json | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.Core.NewtonsoftJson/2.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Core.NewtonsoftJson-readme) | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.NewtonsoftJson_2.0.0/sdk/core/Microsoft.Azure.Core.NewtonsoftJson/) | | Core WCF Storage Queues | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Microsoft.CoreWCF.Azure.StorageQueues/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Microsoft.CoreWCF.Azure.StorageQueues-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.CoreWCF.Azure.StorageQueues_1.0.0-beta.1/sdk/extension-wcf/Microsoft.CoreWCF.Azure.StorageQueues/) | | Data Movement | NuGet [12.0.0-beta.5](https://www.nuget.org/packages/Azure.Storage.DataMovement/12.0.0-beta.5) | [docs](/dotnet/api/overview/azure/Storage.DataMovement-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [12.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.DataMovement_12.0.0-beta.5/sdk/storage/Azure.Storage.DataMovement/) | @@ -124,7 +124,7 @@ | Synapse - Monitoring | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Analytics.Synapse.Monitoring/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Monitoring-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Monitoring_1.0.0-beta.3/sdk/synapse/Azure.Analytics.Synapse.Monitoring/) | | Synapse - Spark | NuGet [1.0.0-preview.8](https://www.nuget.org/packages/Azure.Analytics.Synapse.Spark/1.0.0-preview.8) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Spark-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-preview.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Spark_1.0.0-preview.8/sdk/synapse/Azure.Analytics.Synapse.Spark/) | | System Events | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Messaging.EventGrid.SystemEvents/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Messaging.EventGrid.SystemEvents-readme?view=azure-dotnet-preview&preserve-view=true) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid.SystemEvents_1.0.0-beta.1/sdk/eventgrid/Azure.Messaging.EventGrid.SystemEvents/) | -| System.ClientModel | NuGet [1.1.0](https://www.nuget.org/packages/System.ClientModel/1.1.0) | [docs](/dotnet/api/overview/azure/System.ClientModel-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/System.ClientModel_1.1.0/sdk/core/System.ClientModel/) | +| System.ClientModel | NuGet [1.2.0](https://www.nuget.org/packages/System.ClientModel/1.2.0) | [docs](/dotnet/api/overview/azure/System.ClientModel-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/System.ClientModel_1.2.0/sdk/core/System.ClientModel/) | | Tables | NuGet [12.9.1](https://www.nuget.org/packages/Azure.Data.Tables/12.9.1) | [docs](/dotnet/api/overview/azure/Data.Tables-readme) | GitHub [12.9.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.Tables_12.9.1/sdk/tables/Azure.Data.Tables/) | | Text Analytics | NuGet [5.3.0](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.3.0) | [docs](/dotnet/api/overview/azure/AI.TextAnalytics-readme) | GitHub [5.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.3.0/sdk/textanalytics/Azure.AI.TextAnalytics/) | | Text Translation | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.Translation.Text/1.0.0) | [docs](/dotnet/api/overview/azure/AI.Translation.Text-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Translation.Text_1.0.0/sdk/translation/Azure.AI.Translation.Text/) | diff --git a/docs/core/compatibility/8.0.md b/docs/core/compatibility/8.0.md index d45b8b7e2430a..e2a4269aa9320 100644 --- a/docs/core/compatibility/8.0.md +++ b/docs/core/compatibility/8.0.md @@ -115,6 +115,7 @@ If you're migrating an app to .NET 8, the breaking changes listed here might aff | Title | Type of change | | ------------------------------------------------------------------------------------------------- | ----------------- | | [SendFile throws NotSupportedException for connectionless sockets](networking/8.0/sendfile-connectionless.md) | Behavioral change | +| [User info in `mailto:` URIs is compared](networking/8.0/uri-comparison.md) | Behavioral change | ## Reflection diff --git a/docs/core/compatibility/9.0.md b/docs/core/compatibility/9.0.md index 7b52fe2f7c208..723c3b2c5edc0 100644 --- a/docs/core/compatibility/9.0.md +++ b/docs/core/compatibility/9.0.md @@ -36,12 +36,14 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff | [Altered UnsafeAccessor support for non-open generics](core-libraries/9.0/unsafeaccessor-generics.md) | Behavioral change | Preview 6 | | [API obsoletions with custom diagnostic IDs](core-libraries/9.0/obsolete-apis-with-custom-diagnostics.md) | Source incompatible | Preview 16 | | [BigInteger maximum length](core-libraries/9.0/biginteger-limit.md) | Behavioral change | Preview 6 | +| [BinaryReader.GetString() returns "/uFFFD" on malformed sequences](core-libraries/9.0/binaryreader.md) | Behavioral change | Preview 7 | | [Creating type of array of System.Void not allowed](core-libraries/9.0/type-instance.md) | Behavioral change | Preview 1 | | [Default `Equals()` and `GetHashCode()` throw for types marked with `InlineArrayAttribute`](core-libraries/9.0/inlinearrayattribute.md) | Behavioral change | Preview 6 | | [FromKeyedServicesAttribute no longer injects non-keyed parameter](core-libraries/9.0/non-keyed-params.md) | Behavioral change | RC 1 | | [IncrementingPollingCounter initial callback is asynchronous](core-libraries/9.0/async-callback.md) | Behavioral change | RC 1 | | [Inline array struct size limit is enforced](core-libraries/9.0/inlinearray-size.md) | Behavioral change | Preview 1 | | [InMemoryDirectoryInfo prepends rootDir to files](core-libraries/9.0/inmemorydirinfo-prepends-rootdir.md) | Behavioral change | Preview 1 | +| [New TimeSpan.From*() overloads that take integers](core-libraries/9.0/timespan-from-overloads.md) | Source incompatible | Preview 3 | | [RuntimeHelpers.GetSubArray returns different type](core-libraries/9.0/getsubarray-return.md) | Behavioral change | Preview 1 | | [Support for empty environment variables](core-libraries/9.0/empty-env-variable.md) | Behavioral change | Preview 6 | | [ZipArchiveEntry names and comments respect UTF8 flag](core-libraries/9.0/ziparchiveentry-encoding.md) | Behavioral change | RC 1 | @@ -97,6 +99,7 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff | [ComponentDesigner.Initialize throws ArgumentNullException](windows-forms/9.0/componentdesigner-initialize.md) | Behavioral change | Preview 1 | | [DataGridViewRowAccessibleObject.Name starting row index](windows-forms/9.0/datagridviewrowaccessibleobject-name-row.md) | Behavioral change | Preview 1 | | [IMsoComponent support is opt-in](windows-forms/9.0/imsocomponent-support.md) | Behavioral change | Preview 2 | +| [New security analyzers](windows-forms/9.0/security-analyzers.md) | Source incompatible | RC 1 | | [No exception if DataGridView is null](windows-forms/9.0/datagridviewheadercell-nre.md) | Behavioral change | Preview 1 | | [PictureBox raises HttpClient exceptions](windows-forms/9.0/httpclient-exceptions.md) | Behavioral change | Preview 6 | diff --git a/docs/core/compatibility/core-libraries/9.0/binaryreader.md b/docs/core/compatibility/core-libraries/9.0/binaryreader.md new file mode 100644 index 0000000000000..c615900370335 --- /dev/null +++ b/docs/core/compatibility/core-libraries/9.0/binaryreader.md @@ -0,0 +1,58 @@ +--- +title: "Breaking change:BinaryReader.GetString() returns '\uFFFD' on malformed sequences" +description: Learn about the .NET 9 breaking change in core .NET libraries where BinaryReader.GetString() returns "\uFFFD" on malformed encoded string sequences. +ms.date: 10/03/2024 +--- +# BinaryReader.GetString() returns "\uFFFD" on malformed sequences + +A a minor breaking change was introduced that only affects malformed encoded payloads. + +Prior to .NET 9, a malformed encoded string `[0x01, 0xC2]` that was parsed with returned an empty string. + +Starting in .NET 9, returns "\uFFFD", which is the `REPLACEMENT CHARACTER` used to replace an unknown, unrecognized, or unrepresentable character. This change only affects malformed payloads and matches Unicode standards. + +## Previous behavior + +```csharp +var ms = new MemoryStream(new byte[] { 0x01, 0xC2 }); +using (var br = new BinaryReader(ms)) +{ + string s = br.ReadString(); + Console.WriteLine(s == "\uFFFD"); // false + Console.WriteLine(s.Length); // 0 +} +``` + +## New behavior + +Starting in .NET 9, the same code snippet produces different results for `s == "\uFFFD"` and `s.Length`, as shown in the code comments: + +```csharp +var ms = new MemoryStream(new byte[] { 0x01, 0xC2 }); +using (var br = new BinaryReader(ms)) +{ + string s = br.ReadString(); + Console.WriteLine(s == "\uFFFD"); // true + Console.WriteLine(s.Length); // 1 +} +``` + +## Version introduced + +.NET 9 Preview 7 + +## Type of breaking change + +This change is a [behavioral change](../../categories.md#behavioral-change). + +## Reason for change + +This change was made as a performance improvement that affects a rare scenario. + +## Recommended action + +If you want to keep the previous behavior where incomplete byte sequence were omitted at the end of the string, call `TrimEnd("\uFFFD")` on the result. + +## Affected APIs + +- diff --git a/docs/core/compatibility/core-libraries/9.0/timespan-from-overloads.md b/docs/core/compatibility/core-libraries/9.0/timespan-from-overloads.md new file mode 100644 index 0000000000000..bd485d8d610d9 --- /dev/null +++ b/docs/core/compatibility/core-libraries/9.0/timespan-from-overloads.md @@ -0,0 +1,50 @@ +--- +title: "Breaking change: New TimeSpan.From*() overloads that take integers" +description: Learn about the .NET 9 breaking change in core .NET libraries where new TimeSpan.From*() overloads were introduced that take integer arguments. +ms.date: 10/03/2024 +--- +# New TimeSpan.From*() overloads that take integers + +New `TimeSpan.From*()` overloads that accept integers were introduced in .NET 9. This change can cause ambiguity for the F# compiler and result in compile-time errors. + +## Previous behavior + +Previously, there was a single overload for each `TimeSpan.From*()` method, namely: + +- +- +- +- +- +- + +## New behavior + +Starting in .NET 9, new overloads have been added that accept integer arguments. Calling a method such as `TimeSpan.FromMinutes(20)` in F# code results in a compile-time error: + +> error FS0041: A unique overload for method 'FromMinutes' could not be determined based on type information prior to this program point. A type annotation may be needed. Known type of argument: intCandidates: - TimeSpan.FromMinutes(minutes: int64) : TimeSpan - TimeSpan.FromMinutes(minutes: int64, ?seconds: int64, ?milliseconds: int64, ?microseconds: int64) : TimeSpan - TimeSpan.FromMinutes(value: float) : TimeSpan + +## Version introduced + +.NET 9 Preview 3 + +## Type of breaking change + +This change can affect [source compatibility](../../categories.md#source-compatibility) for F# code. + +## Reason for change + +The pre-existing overloads accepted a argument. However, is a binary-based, floating-point format and thus has natural imprecision that can introduce error. This behavior has led to user confusion and bugs in the API surface. It's also one of the less efficient ways to represent this data. To produce the intended behavior, new overloads were introduced that allow users to pass in integers. + +## Recommended action + +If this change affects your F# code, specify the type of argument so the compiler selects the appropriate overload. + +## Affected APIs + +- +- +- +- +- +- diff --git a/docs/core/compatibility/networking/8.0/uri-comparison.md b/docs/core/compatibility/networking/8.0/uri-comparison.md new file mode 100644 index 0000000000000..58f1dfaf84e36 --- /dev/null +++ b/docs/core/compatibility/networking/8.0/uri-comparison.md @@ -0,0 +1,58 @@ +--- +title: "Breaking change: User info in `mailto:` URIs is compared" +description: Learn about the .NET 8 breaking change in networking where URI comparison now considers user info for `mailto:` URIs. +ms.date: 10/03/2024 +--- +# User info in `mailto:` URIs is compared + +Previously, didn't compare user info when comparing two `Uri` instances for equality. However, this behavior is not intuitive in the case of `mailto:` URIs. With this change, and the [`==`](xref:System.Uri.op_Equality(System.Uri,System.Uri)) operator now consider user info when comparing URIs. + +## Previous behavior + +Prior to .NET 8, both of the following comparisons returned `true`. + +```csharp +Uri uri1 = new Uri("https://user1@www.microsoft.com"); +Uri uri2 = new Uri("https://user2@www.microsoft.com"); +System.Console.WriteLine(uri1 == uri2); // True. + +Uri uri3 = new Uri("mailto:user1@microsoft.com"); +Uri uri4 = new Uri("mailto:user2@microsoft.com"); +System.Console.WriteLine(uri3 == uri4); // True. +``` + +## New behavior + +Starting in .NET 8, the first comparison still returns `true`, but the second comparison (of `mailto` URIs) returns `false`. + +```csharp +Uri uri1 = new Uri("https://user1@www.microsoft.com"); +Uri uri2 = new Uri("https://user2@www.microsoft.com"); +System.Console.WriteLine(uri1 == uri2); // True. + +Uri uri3 = new Uri("mailto:user1@microsoft.com"); +Uri uri4 = new Uri("mailto:user2@microsoft.com"); +System.Console.WriteLine(uri3 == uri4); // False. +``` + +## Version introduced + +.NET 8 + +## Type of breaking change + +This change is a [behavioral change](../../categories.md#behavioral-change). + +## Reason for change + +The previous behavior was unexpected and unintuitive. + +## Recommended action + +If you want to compare only the host part of email addresses, compare only the members. + +## Affected APIs + +- +- +- diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index 4f2b75d9a4586..255c067adbf79 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -40,6 +40,8 @@ items: href: core-libraries/9.0/inlinearray-size.md - name: InMemoryDirectoryInfo prepends rootDir to files href: core-libraries/9.0/inmemorydirinfo-prepends-rootdir.md + - name: New TimeSpan.From*() overloads that take integers + href: core-libraries/9.0/timespan-from-overloads.md - name: RuntimeHelpers.GetSubArray returns different type href: core-libraries/9.0/getsubarray-return.md - name: Support for empty environment variables @@ -94,6 +96,8 @@ items: href: windows-forms/9.0/datagridviewrowaccessibleobject-name-row.md - name: IMsoComponent support is opt-in href: windows-forms/9.0/imsocomponent-support.md + - name: New security analyzers + href: windows-forms/9.0/security-analyzers.md - name: No exception if DataGridView is null href: windows-forms/9.0/datagridviewheadercell-nre.md - name: PictureBox raises HttpClient exceptions @@ -150,6 +154,8 @@ items: href: core-libraries/8.0/file-path-backslash.md - name: Base64.DecodeFromUtf8 methods ignore whitespace href: core-libraries/8.0/decodefromutf8-whitespace.md + - name: BinaryReader.GetString() returns "/uFFFD" on malformed sequences + href: core-libraries/9.0/binaryreader.md - name: Boolean-backed enum type support removed href: core-libraries/8.0/bool-backed-enum.md - name: Complex.ToString format changed to `` @@ -238,6 +244,8 @@ items: items: - name: SendFile throws NotSupportedException for connectionless sockets href: networking/8.0/sendfile-connectionless.md + - name: User info in `mailto:` URIs is compared + href: networking/8.0/uri-comparison.md - name: Reflection items: - name: IntPtr no longer used for function pointer types @@ -1242,6 +1250,8 @@ items: href: core-libraries/9.0/obsolete-apis-with-custom-diagnostics.md - name: BigInteger maximum length href: core-libraries/9.0/biginteger-limit.md + - name: BinaryReader.GetString() returns "/uFFFD" on malformed sequences + href: core-libraries/9.0/binaryreader.md - name: Creating type of array of System.Void not allowed href: core-libraries/9.0/type-instance.md - name: "`Equals`/`GetHashCode` throw for `InlineArrayAttribute` types" @@ -1254,6 +1264,8 @@ items: href: core-libraries/9.0/inlinearray-size.md - name: InMemoryDirectoryInfo prepends rootDir to files href: core-libraries/9.0/inmemorydirinfo-prepends-rootdir.md + - name: New TimeSpan.From*() overloads that take integers + href: core-libraries/9.0/timespan-from-overloads.md - name: RuntimeHelpers.GetSubArray returns different type href: core-libraries/9.0/getsubarray-return.md - name: Support for empty environment variables @@ -1670,6 +1682,8 @@ items: items: - name: SendFile throws NotSupportedException for connectionless sockets href: networking/8.0/sendfile-connectionless.md + - name: User info in `mailto:` URIs is compared + href: networking/8.0/uri-comparison.md - name: .NET 7 items: - name: AllowRenegotiation default is false @@ -1928,6 +1942,8 @@ items: href: windows-forms/9.0/datagridviewrowaccessibleobject-name-row.md - name: IMsoComponent support is opt-in href: windows-forms/9.0/imsocomponent-support.md + - name: New security analyzers + href: windows-forms/9.0/security-analyzers.md - name: No exception if DataGridView is null href: windows-forms/9.0/datagridviewheadercell-nre.md - name: PictureBox raises HttpClient exceptions diff --git a/docs/core/compatibility/windows-forms/9.0/security-analyzers.md b/docs/core/compatibility/windows-forms/9.0/security-analyzers.md new file mode 100644 index 0000000000000..8a35c79c69e1c --- /dev/null +++ b/docs/core/compatibility/windows-forms/9.0/security-analyzers.md @@ -0,0 +1,60 @@ +--- +title: "Breaking change: New security analyzers" +description: Learn about the .NET 9 breaking change in Windows Forms where new security analyzers have been introduced to prevent accidental leaks of sensitive data. +ms.date: 10/04/2024 +--- +# New security analyzers + +New security analyzers have been introduced to prevent the accidental leaking of user data through certain properties. These analyzers enforce best practices by identifying properties that lack explicit serialization settings, for example: + +- +- +- `ShouldSerialize[propertyName]` methods + +The analyzers produce warnings such as: + +> WFO1000: Property 'property' does not configure the code serialization for its property content. + +By default, each analyzer produces an error, ensuring that developers are made aware of potential security and data leakage issues early in the development process. + +This change aims to enhance the security and maintainability of Windows Forms apps by enforcing proper serialization practices, thus reducing the risk of accidental data exposure. + +## Previous behavior + +Previously, properties in Windows Forms and controls could be serialized by the designer without explicit configuration of their serialization behavior. This could result in unintended data being included in the generated code or resource files, creating a potential security risk. This behavior was particularly problematic in custom line-of-business objects, where it was easy to overlook the serialization of sensitive data that should not have been exposed. For example, properties containing sensitive information, such as user data or internal configurations, could be written directly into the designer-generated *.cs* files or embedded within *.resx* files. + +## New behavior + +Starting in .NET 9, the new Windows Forms security analyzers enforce stricter control over the serialization of properties in controls and objects. By default, the analyzer produces an error if a property does not have its CodeDOM serialization behavior explicitly defined. This behavior ensures that properties aren't inadvertently serialized. You can adjust the *.editorconfig* settings to change the analyzer's [severity](../../../../fundamentals/code-analysis/configuration-options.md#severity-level) or suppress the error. + +## Version introduced + +.NET 9 RC 1 + +## Type of breaking change + +This change can affect [source compatibility](../../categories.md#source-compatibility). + +## Reason for change + +This change was made for two primary reasons: + +- Enhanced security: By forcing explicit serialization definitions, the analyzer significantly reduces the risk of unintentional data exposure, particularly in LOB applications. This has happened in the past, and it's all the more necessary now in the context of the [BinaryFormatter serializer removal](../../serialization/9.0/binaryformatter-removal.md). By preventing as much as possible from being serialized by accident to begin with, there won't be backwards compatibility or security issues around binary serialization in resource files for types that don't have a dedicated type converter. + +- Improved code clarity and maintainability: This feature ensures that serialization behavior is transparent and intentional, which aids in code reviews and future maintenance. + +## Recommended action + +- Review the properties flagged by the analyzer and configure appropriate serialization settings as needed. +- For a quick fix (not recommended), add the following entry in an *.editorconfig* file at the solution folder or project folder level: + + ```ini + [*.cs] + + # WFO1000: A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method + dotnet_diagnostic.WFO1000.severity = silent + ``` + +## Affected APIs + +- N/A diff --git a/docs/core/deploying/trimming/intrinsic-requiresunreferencedcode-apis.md b/docs/core/deploying/trimming/intrinsic-requiresunreferencedcode-apis.md new file mode 100644 index 0000000000000..4a2512a86934b --- /dev/null +++ b/docs/core/deploying/trimming/intrinsic-requiresunreferencedcode-apis.md @@ -0,0 +1,52 @@ +--- +title: Intrinsic APIs marked RequiresUnreferencedCode +description: Learn how the tooling recognizes certain patterns in calls to APIs annotated with RequiresUnreferencedCode. +author: MichalStrehovsky +ms.author: michals +ms.date: 09/13/2024 +--- + +# Intrinsic APIs marked RequiresUnreferencedCode + +Under normal circumstances, calling APIs annotated with in an app published with trimming triggers warning [IL2026 (Members attributed with RequiresUnreferencedCode may break when trimming)](trim-warnings/il2026.md). APIs that trigger the warning might not behave correctly in a trimmed deployment. + +Some APIs annotated `[RequiresUnreferencedCode]` can still be used without triggering the warning if they're called in a specific pattern. When used as part of a pattern, the call to the API can be statically analyzed by the compiler, does not generate a warning, and behaves as expected at run time. + +## MethodInfo.MakeGenericMethod(Type[]) method + +Calls to this API don't trigger a warning if the generic method definition is statically visible within the calling method body and none of the generic method's generic parameters have the `new()` constraint or `DynamicallyAccessedMembers` attribute. For example, `typeof(SomeType).GetMethod("GenericMethod").MakeGenericMethod(someType)` doesn't generate a warning provided there are no `new()` constraints or `DynamicallyAccessedMembers` annotations on the generic parameters. + +If the generic method has parameters with the `new()` constraint or `DynamicallyAccessedMembers` attribute, the generic arguments used with `MakeGenericMethod` need to also be statically visible within the calling method body. Otherwise the warning is issued. + +## MethodInfo.MakeGenericType(Type[]) method + +Calls to this API don't trigger a warning if the generic type definition is statically visible within the calling method body and none of the generic type's generic parameters have the `new()` constraint or `DynamicallyAccessedMembers` attribute. For example, `typeof(SomeType<>).MakeGenericType(someType)` doesn't generate a warning provided there are no `new()` constraints or `DynamicallyAccessedMembers` annotations on the generic parameters. + +If the generic type has parameters with the `new()` constraint or `DynamicallyAccessedMembers` attribute, the generic arguments used with `MakeGenericType` need to also be statically visible within the calling method body. Otherwise the warning is issued. + +## RuntimeHelpers.RunClassConstructor(Type) method + +Calls to this API don't trigger a warning if the concrete type is statically visible in the calling method body. For example, `RuntimeHelpers.RunClassConstructor(typeof(string).TypeHandle)` does not trigger a warning, but `RuntimeHelpers.RunClassConstructor(typeof(T).TypeHandle)` and `RuntimeHelpers.RunClassConstructor(someTypeHandle)` do. + +Additionally, starting with .NET 9, the warning isn't issued when the type handle was loaded from `Type` stored in a location annotated as `DynamicallyAccessedMemberTypes.NonPublicConstructors`. That's because non-public constructors include the static constructor: + +```csharp +static void M<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)] T> + ([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type t) +{ + RuntimeHelpers.RunClassConstructor(typeof(T).TypeHandle); // No IL2026 warning + RuntimeHelpers.RunClassConstructor(t.TypeHandle); // No IL2026 warning +} + +``` + +## Type.GetType overloads + +Calls to this API don't trigger a warning if the string parameter is passed as a string literal and case-insensitive search isn't requested. The API also doesn't trigger a warning if a non-literal string is used, but the string was loaded from a location annotated with `[DynamicallyAccessedMembers]`. + +```csharp +static void GetTheType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)] string s) +{ + Type.GetType(s); // No IL2026 warning +} +``` diff --git a/docs/core/diagnostics/diagnostic-health-checks.md b/docs/core/diagnostics/diagnostic-health-checks.md index fbd9c89d632fc..1eed4f2e0d072 100644 --- a/docs/core/diagnostics/diagnostic-health-checks.md +++ b/docs/core/diagnostics/diagnostic-health-checks.md @@ -25,16 +25,12 @@ To perform health checks on the resource utilization of your .NET apps, add a pa The preceding code: - Creates a new instance. -- Adds resource monitoring by calling . - Adds a health check for resource utilization by chaining a call from the call to the extension method. - Builds the instance as the `app` variable. - Gets an instance of the class from the service provider. - Performs a health check and displays the result. - Runs the application. -> [!NOTE] -> The `Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization` library assumes that the consumer will register the dependent call to . If you don't register this, when resolving the `HealthCheckService` an exception is thrown. - ## Application lifetime health checks To perform health checks on the application lifetime events of , use the extension method available in the [Microsoft.Extensions.Diagnostics.HealthChecks.Common](https://www.nuget.org/packages/Microsoft.Extensions.Diagnostics.HealthChecks.Common) NuGet package. diff --git a/docs/core/diagnostics/snippets/health-checks/Program.cs b/docs/core/diagnostics/snippets/health-checks/Program.cs index 47efc981236ac..83c82c6544291 100644 --- a/docs/core/diagnostics/snippets/health-checks/Program.cs +++ b/docs/core/diagnostics/snippets/health-checks/Program.cs @@ -1,12 +1,9 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; -using Microsoft.Extensions.Diagnostics.ResourceMonitoring; using Microsoft.Extensions.Hosting; var builder = Host.CreateApplicationBuilder(args); -builder.Services.AddResourceMonitoring(); - builder.Services.AddHealthChecks() .AddResourceUtilizationHealthCheck(); diff --git a/docs/core/whats-new/dotnet-9/runtime.md b/docs/core/whats-new/dotnet-9/runtime.md index 16d3e6d135fdf..3c8d84c109025 100644 --- a/docs/core/whats-new/dotnet-9/runtime.md +++ b/docs/core/whats-new/dotnet-9/runtime.md @@ -325,7 +325,7 @@ Consider the following snippet: `Compare` is conveniently written such that if you wanted to compare other types, like strings or `double` values, you could reuse the same implementation. But in this example, it also has the performance drawback of requiring any value types that are passed to it to be *boxed*. -The x64 assembly code generated for `Main` is as follows: +The x64 assembly code generated for `RunIt` is as follows: ```al push rbx @@ -352,9 +352,9 @@ pop rbx ret ``` -The calls to `CORINFO_HELP_NEWSFAST` are the heap allocations for the boxed integer arguments. Also, notice that there isn't any call to `Compare`; the compiler decided to inline it into `Main`. This inlining means the boxes never "escape." In other words, throughout the execution of `Compare`, it knows `x` and `y` are actually integers, and they can be safely unboxed them without affecting the comparison logic. +The calls to `CORINFO_HELP_NEWSFAST` are the heap allocations for the boxed integer arguments. Also, notice that there isn't any call to `Compare`; the compiler decided to inline it into `RunIt`. This inlining means the boxes never "escape." In other words, throughout the execution of `Compare`, it knows `x` and `y` are actually integers, and they can be safely unboxed them without affecting the comparison logic. -Starting in .NET 9, the 64-bit compiler allocates unescaped boxes on the stack, which unlocks several other optimizations. In this example, not only does the compiler avoid the heap allocations, but it also evaluates the expressions `x.Equals(y)` and `result ? 0 : 100` at compile time. Here's the updated assembly: +Starting in .NET 9, the 64-bit compiler allocates unescaped boxes on the stack, which unlocks several other optimizations. In this example, the compiler now omits the heap allocations, but because it knows `x` and `y` are 3 and 4, it can also omit the body of `Compare`; the compiler can determine `x.Equals(y)` is false at compile time, so `RunIt` should always return 100. Here's the updated assembly: ```al mov eax, 100 diff --git a/docs/navigate/devops-testing/toc.yml b/docs/navigate/devops-testing/toc.yml index 22db686aac788..d0825da987aff 100644 --- a/docs/navigate/devops-testing/toc.yml +++ b/docs/navigate/devops-testing/toc.yml @@ -253,6 +253,8 @@ items: href: ../../core/deploying/trimming/trimming-options.md - name: Trimming libraries href: ../../core/deploying/trimming/prepare-libraries-for-trimming.md + - name: Intrinsic APIs marked RequiresUnreferencedCode + href: ../../core/deploying/trimming/intrinsic-requiresunreferencedcode-apis.md - name: Trim warnings items: - name: IL2001 diff --git a/samples/snippets/standard/data/sqlite/DapperSample/Program.cs b/samples/snippets/standard/data/sqlite/DapperSample/Program.cs index 52864a16bbc7e..2b6ab69900479 100644 --- a/samples/snippets/standard/data/sqlite/DapperSample/Program.cs +++ b/samples/snippets/standard/data/sqlite/DapperSample/Program.cs @@ -9,7 +9,7 @@ namespace DapperSample abstract class SqliteTypeHandler : SqlMapper.TypeHandler { // Parameters are converted by Microsoft.Data.Sqlite - public override void SetValue(IDbDataParameter parameter, T value) + public override void SetValue(IDbDataParameter parameter, T? value) => parameter.Value = value; }