From 31f8333b10e8c97fe2a631890fc2ded695549626 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Thu, 26 Dec 2024 11:51:57 +1100 Subject: [PATCH] split append --- src/Polyfill/Polyfill_StringBuilder_Append.cs | 42 ------------- .../Polyfill_StringBuilder_AppendLine.cs | 59 +++++++++++++++++++ 2 files changed, 59 insertions(+), 42 deletions(-) create mode 100644 src/Polyfill/Polyfill_StringBuilder_AppendLine.cs diff --git a/src/Polyfill/Polyfill_StringBuilder_Append.cs b/src/Polyfill/Polyfill_StringBuilder_Append.cs index e561191c..91bc7987 100644 --- a/src/Polyfill/Polyfill_StringBuilder_Append.cs +++ b/src/Polyfill/Polyfill_StringBuilder_Append.cs @@ -61,28 +61,6 @@ public static StringBuilder Append( [InterpolatedStringHandlerArgument(nameof(target), nameof(provider))] ref AppendInterpolatedStringHandler handler) => target; - /// Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object. - /// The interpolated string to append. - /// A reference to this instance after the append operation has completed. - //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(); - - /// Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object. - /// An object that supplies culture-specific formatting information. - /// The interpolated string to append. - /// A reference to this instance after the append operation has completed. - //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 /// Appends the specified interpolated string to this instance. @@ -105,25 +83,5 @@ public static StringBuilder Append( [InterpolatedStringHandlerArgument(nameof(target), nameof(provider))] ref StringBuilder.AppendInterpolatedStringHandler handler) => target.Append(provider, ref handler); - /// Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object. - /// The interpolated string to append. - /// A reference to this instance after the append operation has completed. - //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); - - /// Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object. - /// An object that supplies culture-specific formatting information. - /// The interpolated string to append. - /// A reference to this instance after the append operation has completed. - //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 - } \ No newline at end of file diff --git a/src/Polyfill/Polyfill_StringBuilder_AppendLine.cs b/src/Polyfill/Polyfill_StringBuilder_AppendLine.cs new file mode 100644 index 00000000..6c7af828 --- /dev/null +++ b/src/Polyfill/Polyfill_StringBuilder_AppendLine.cs @@ -0,0 +1,59 @@ +// +#pragma warning disable + +namespace Polyfills; + +using System; +using System.Runtime.CompilerServices; +using System.Text; + +static partial class Polyfill +{ +#if FeatureMemory && !NET6_0_OR_GREATER + + /// Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object. + /// The interpolated string to append. + /// A reference to this instance after the append operation has completed. + //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(); + + /// Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object. + /// An object that supplies culture-specific formatting information. + /// The interpolated string to append. + /// A reference to this instance after the append operation has completed. + //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 + + /// Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object. + /// The interpolated string to append. + /// A reference to this instance after the append operation has completed. + //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); + + /// Appends the specified interpolated string followed by the default line terminator to the end of the current StringBuilder object. + /// An object that supplies culture-specific formatting information. + /// The interpolated string to append. + /// A reference to this instance after the append operation has completed. + //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 + +} \ No newline at end of file