From 2f6091a8d52f2b4204d86b450de754ca2b9da39b Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Wed, 22 Jan 2025 14:04:17 +1100 Subject: [PATCH 1/2] Append StringBuilder --- readme.md | 2 +- src/Polyfill/Polyfill_StringBuilder_Append.cs | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 4d886810..c56fb924 100644 --- a/readme.md +++ b/readme.md @@ -65,7 +65,7 @@ This project uses features from the current stable SDK and C# language. As such ```json { "sdk": { - "version": "9.0.101", + "version": "9.0.102", "allowPrerelease": true, "rollForward": "latestFeature" } diff --git a/src/Polyfill/Polyfill_StringBuilder_Append.cs b/src/Polyfill/Polyfill_StringBuilder_Append.cs index 91bc7987..0206482f 100644 --- a/src/Polyfill/Polyfill_StringBuilder_Append.cs +++ b/src/Polyfill/Polyfill_StringBuilder_Append.cs @@ -9,6 +9,38 @@ namespace Polyfills; static partial class Polyfill { +#if !NETSTANDARD2_1_OR_GREATER && !NETCOREAPP2_1_OR_GREATER + + /// + /// Appends a copy of a substring within a specified string builder to this instance. + /// + /// The string builder that contains the substring to append. + /// The starting position of the substring within value. + /// The number of characters in value to append. + /// A reference to this instance after the append operation is completed. + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.append#system-text-stringbuilder-append(system-text-stringbuilder-system-int32-system-int32) + public static StringBuilder Append(this StringBuilder target, StringBuilder? value, int startIndex, int count) + { + if (value == null) + { + if (startIndex == 0 && count == 0) + { + return target; + } + + throw new ArgumentNullException(nameof(value)); + } + + if (count == 0) + { + return target; + } + + return target.Append(value.ToString(), startIndex, count); + } + +#endif + #if FeatureMemory && (!NETSTANDARD2_1_OR_GREATER && !NETCOREAPP2_1_OR_GREATER) /// From 5b562a5b3ee7b28f8bcca81b188e7f3ff83e8c7d Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Wed, 22 Jan 2025 22:42:22 +1100 Subject: [PATCH 2/2] . --- apiCount.include.md | 2 +- api_list.include.md | 1 + readme.md | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apiCount.include.md b/apiCount.include.md index 76ee0fe3..a698570b 100644 --- a/apiCount.include.md +++ b/apiCount.include.md @@ -1 +1 @@ -**API count: 452** \ No newline at end of file +**API count: 453** \ No newline at end of file diff --git a/api_list.include.md b/api_list.include.md index 62b9281b..af3face9 100644 --- a/api_list.include.md +++ b/api_list.include.md @@ -341,6 +341,7 @@ #### StringBuilder + * `StringBuilder Append(StringBuilder, StringBuilder?, int, int)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.append#system-text-stringbuilder-append(system-text-stringbuilder-system-int32-system-int32)) * `StringBuilder Append(StringBuilder, ReadOnlySpan)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.append#system-text-stringbuilder-append(system-readonlyspan((system-char)))) * `StringBuilder Append(StringBuilder, AppendInterpolatedStringHandler)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.append#system-text-stringbuilder-append(system-text-stringbuilder-appendinterpolatedstringhandler@)) * `StringBuilder Append(StringBuilder, IFormatProvider?, AppendInterpolatedStringHandler)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.append#system-text-stringbuilder-append(system-iformatprovider-system-text-stringbuilder-appendinterpolatedstringhandler@)) diff --git a/readme.md b/readme.md index c56fb924..bf107204 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,7 @@ The package targets `netstandard2.0` and is designed to support the following ru * `net5.0`, `net6.0`, `net7.0`, `net8.0`, `net9.0` -**API count: 452** +**API count: 453** **See [Milestones](../../milestones?state=closed) for release notes.** @@ -810,6 +810,7 @@ The class `Polyfill` includes the following extension methods: #### StringBuilder + * `StringBuilder Append(StringBuilder, StringBuilder?, int, int)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.append#system-text-stringbuilder-append(system-text-stringbuilder-system-int32-system-int32)) * `StringBuilder Append(StringBuilder, ReadOnlySpan)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.append#system-text-stringbuilder-append(system-readonlyspan((system-char)))) * `StringBuilder Append(StringBuilder, AppendInterpolatedStringHandler)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.append#system-text-stringbuilder-append(system-text-stringbuilder-appendinterpolatedstringhandler@)) * `StringBuilder Append(StringBuilder, IFormatProvider?, AppendInterpolatedStringHandler)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.append#system-text-stringbuilder-append(system-iformatprovider-system-text-stringbuilder-appendinterpolatedstringhandler@))