Skip to content

Commit

Permalink
Merge branch 'main' into add-Delegate.HasSingleTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Dec 26, 2024
2 parents d59f53e + 31f8333 commit 6191b3d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 42 deletions.
42 changes: 0 additions & 42 deletions src/Polyfill/Polyfill_StringBuilder_Append.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,6 @@ public static StringBuilder Append(
[InterpolatedStringHandlerArgument(nameof(target), nameof(provider))]
ref AppendInterpolatedStringHandler handler) => target;

/// <summary>Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object.</summary>
/// <param name="handler">The interpolated string to append.</param>
/// <returns>A reference to this instance after the append operation has completed.</returns>
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.appendline#system-text-stringbuilder-appendline(system-text-stringbuilder-appendinterpolatedstringhandler@)
public static StringBuilder AppendLine(
StringBuilder target,
[InterpolatedStringHandlerArgument(nameof(target))]
ref AppendInterpolatedStringHandler handler) =>
target.AppendLine();

/// <summary>Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object.</summary>
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
/// <param name="handler">The interpolated string to append.</param>
/// <returns>A reference to this instance after the append operation has completed.</returns>
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.appendline#system-text-stringbuilder-appendline(system-iformatprovider-system-text-stringbuilder-appendinterpolatedstringhandler@)
public static StringBuilder AppendLine(
StringBuilder target,
IFormatProvider? provider,
[InterpolatedStringHandlerArgument(nameof(target), nameof(provider))]
ref AppendInterpolatedStringHandler handler) =>
target.AppendLine();

#elif NET6_0_OR_GREATER

/// <summary>Appends the specified interpolated string to this instance.</summary>
Expand All @@ -105,25 +83,5 @@ public static StringBuilder Append(
[InterpolatedStringHandlerArgument(nameof(target), nameof(provider))] ref StringBuilder.AppendInterpolatedStringHandler handler) =>
target.Append(provider, ref handler);

/// <summary>Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object.</summary>
/// <param name="handler">The interpolated string to append.</param>
/// <returns>A reference to this instance after the append operation has completed.</returns>
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.appendline#system-text-stringbuilder-appendline(system-text-stringbuilder-appendinterpolatedstringhandler@)
public static StringBuilder AppendLine(
StringBuilder target,
[InterpolatedStringHandlerArgument(nameof(target))] ref StringBuilder.AppendInterpolatedStringHandler handler) =>
target.AppendLine(ref handler);

/// <summary>Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object.</summary>
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
/// <param name="handler">The interpolated string to append.</param>
/// <returns>A reference to this instance after the append operation has completed.</returns>
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.appendline#system-text-stringbuilder-appendline(system-iformatprovider-system-text-stringbuilder-appendinterpolatedstringhandler@)
public static StringBuilder AppendLine(
StringBuilder target,
IFormatProvider? provider,
[InterpolatedStringHandlerArgument(nameof(target), nameof(provider))] ref StringBuilder.AppendInterpolatedStringHandler handler) =>
target.AppendLine(provider, ref handler);
#endif

}
59 changes: 59 additions & 0 deletions src/Polyfill/Polyfill_StringBuilder_AppendLine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// <auto-generated />
#pragma warning disable

namespace Polyfills;

using System;
using System.Runtime.CompilerServices;
using System.Text;

static partial class Polyfill
{
#if FeatureMemory && !NET6_0_OR_GREATER

/// <summary>Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object.</summary>
/// <param name="handler">The interpolated string to append.</param>
/// <returns>A reference to this instance after the append operation has completed.</returns>
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.appendline#system-text-stringbuilder-appendline(system-text-stringbuilder-appendinterpolatedstringhandler@)
public static StringBuilder AppendLine(
StringBuilder target,
[InterpolatedStringHandlerArgument(nameof(target))]
ref AppendInterpolatedStringHandler handler) =>
target.AppendLine();

/// <summary>Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object.</summary>
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
/// <param name="handler">The interpolated string to append.</param>
/// <returns>A reference to this instance after the append operation has completed.</returns>
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.appendline#system-text-stringbuilder-appendline(system-iformatprovider-system-text-stringbuilder-appendinterpolatedstringhandler@)
public static StringBuilder AppendLine(
StringBuilder target,
IFormatProvider? provider,
[InterpolatedStringHandlerArgument(nameof(target), nameof(provider))]
ref AppendInterpolatedStringHandler handler) =>
target.AppendLine();

#elif NET6_0_OR_GREATER

/// <summary>Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object.</summary>
/// <param name="handler">The interpolated string to append.</param>
/// <returns>A reference to this instance after the append operation has completed.</returns>
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.appendline#system-text-stringbuilder-appendline(system-text-stringbuilder-appendinterpolatedstringhandler@)
public static StringBuilder AppendLine(
StringBuilder target,
[InterpolatedStringHandlerArgument(nameof(target))] ref StringBuilder.AppendInterpolatedStringHandler handler) =>
target.AppendLine(ref handler);

/// <summary>Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object.</summary>
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
/// <param name="handler">The interpolated string to append.</param>
/// <returns>A reference to this instance after the append operation has completed.</returns>
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.appendline#system-text-stringbuilder-appendline(system-iformatprovider-system-text-stringbuilder-appendinterpolatedstringhandler@)
public static StringBuilder AppendLine(
StringBuilder target,
IFormatProvider? provider,
[InterpolatedStringHandlerArgument(nameof(target), nameof(provider))] ref StringBuilder.AppendInterpolatedStringHandler handler) =>
target.AppendLine(provider, ref handler);
#endif

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace System.Text;
using Diagnostics.CodeAnalysis;
using Runtime.CompilerServices;

//https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs
/// <summary>Provides a handler used by the language compiler to append interpolated strings into <see cref="StringBuilder"/> instances.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[InterpolatedStringHandler]
Expand Down

0 comments on commit 6191b3d

Please sign in to comment.