Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apiCount.include.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
**API count: 452**
**API count: 453**
1 change: 1 addition & 0 deletions api_list.include.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>)` [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@))
Expand Down
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**<!-- singleLineInclude: apiCount. path: /apiCount.include.md -->
**API count: 453**<!-- singleLineInclude: apiCount. path: /apiCount.include.md -->


**See [Milestones](../../milestones?state=closed) for release notes.**
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -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<char>)` [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@))
Expand Down
32 changes: 32 additions & 0 deletions src/Polyfill/Polyfill_StringBuilder_Append.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,38 @@ namespace Polyfills;

static partial class Polyfill
{
#if !NETSTANDARD2_1_OR_GREATER && !NETCOREAPP2_1_OR_GREATER

/// <summary>
/// Appends a copy of a substring within a specified string builder to this instance.
/// </summary>
/// <param name="value">The string builder that contains the substring to append.</param>
/// <param name="startIndex">The starting position of the substring within value.</param>
/// <param name="count">The number of characters in value to append.</param>
/// <returns>A reference to this instance after the append operation is completed.</returns>
//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)

/// <summary>
Expand Down