From 2e3c577ccb129c15c9244755cb8671cd7d9a4e00 Mon Sep 17 00:00:00 2001 From: Tony Qu Date: Mon, 31 Mar 2025 18:46:18 +0800 Subject: [PATCH 1/3] Append methods return Utf8ValueStringBuilder object --- .../Scripts/ZString/Utf8ValueStringBuilder.cs | 43 +++++++++++-------- src/ZString/Utf8ValueStringBuilder.cs | 43 +++++++++++-------- 2 files changed, 52 insertions(+), 34 deletions(-) diff --git a/src/ZString.Unity/Assets/Scripts/ZString/Utf8ValueStringBuilder.cs b/src/ZString.Unity/Assets/Scripts/ZString/Utf8ValueStringBuilder.cs index 19df488..818010f 100644 --- a/src/ZString.Unity/Assets/Scripts/ZString/Utf8ValueStringBuilder.cs +++ b/src/ZString.Unity/Assets/Scripts/ZString/Utf8ValueStringBuilder.cs @@ -153,7 +153,7 @@ public void Grow(int sizeHint) /// Appends the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine() + public Utf8ValueStringBuilder AppendLine() { if (crlf) { @@ -168,11 +168,12 @@ public void AppendLine() buffer[index] = newLine1; index += 1; } + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public unsafe void Append(char value) + public unsafe Utf8ValueStringBuilder Append(char value) { var maxLen = UTF8NoBom.GetMaxByteCount(1); if (buffer!.Length - index < maxLen) @@ -184,10 +185,11 @@ public unsafe void Append(char value) { index += UTF8NoBom.GetBytes(&value, 1, bp, maxLen); } + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(char value, int repeatCount) + public Utf8ValueStringBuilder Append(char value, int repeatCount) { if (repeatCount < 0) { @@ -215,52 +217,54 @@ public void Append(char value, int repeatCount) Advance(len); } } + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(char value) + public Utf8ValueStringBuilder AppendLine(char value) { Append(value); AppendLine(); + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(string value, int startIndex, int count) + public Utf8ValueStringBuilder Append(string value, int startIndex, int count) { if (value == null) { if (startIndex == 0 && count == 0) { - return; - } - else - { - throw new ArgumentNullException(nameof(value)); + return this; } + throw new ArgumentNullException(nameof(value)); } Append(value.AsSpan(startIndex, count)); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(string value) + public Utf8ValueStringBuilder Append(string value) { Append(value.AsSpan()); + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(string value) + public Utf8ValueStringBuilder AppendLine(string value) { Append(value); AppendLine(); + return this; } /// Appends a contiguous region of arbitrary memory to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(ReadOnlySpan value) + public Utf8ValueStringBuilder Append(ReadOnlySpan value) { var maxLen = UTF8NoBom.GetMaxByteCount(value.Length); if (buffer!.Length - index < maxLen) @@ -269,16 +273,18 @@ public void Append(ReadOnlySpan value) } index += UTF8NoBom.GetBytes(value, buffer.AsSpan(index)); + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(ReadOnlySpan value) + public Utf8ValueStringBuilder AppendLine(ReadOnlySpan value) { Append(value); AppendLine(); + return this; } - public void AppendLiteral(ReadOnlySpan value) + public Utf8ValueStringBuilder AppendLiteral(ReadOnlySpan value) { if ((buffer!.Length - index) < value.Length) { @@ -287,10 +293,11 @@ public void AppendLiteral(ReadOnlySpan value) value.CopyTo(buffer.AsSpan(index)); index += value.Length; + return this; } /// Appends the string representation of a specified value to this instance. - public void Append(T value) + public Utf8ValueStringBuilder Append(T value) { if (!FormatterCache.TryFormatDelegate(value, buffer.AsSpan(index), out var written, default)) { @@ -301,13 +308,15 @@ public void Append(T value) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. - public void AppendLine(T value) + public Utf8ValueStringBuilder AppendLine(T value) { Append(value); AppendLine(); + return this; } // Output diff --git a/src/ZString/Utf8ValueStringBuilder.cs b/src/ZString/Utf8ValueStringBuilder.cs index 19df488..818010f 100644 --- a/src/ZString/Utf8ValueStringBuilder.cs +++ b/src/ZString/Utf8ValueStringBuilder.cs @@ -153,7 +153,7 @@ public void Grow(int sizeHint) /// Appends the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine() + public Utf8ValueStringBuilder AppendLine() { if (crlf) { @@ -168,11 +168,12 @@ public void AppendLine() buffer[index] = newLine1; index += 1; } + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public unsafe void Append(char value) + public unsafe Utf8ValueStringBuilder Append(char value) { var maxLen = UTF8NoBom.GetMaxByteCount(1); if (buffer!.Length - index < maxLen) @@ -184,10 +185,11 @@ public unsafe void Append(char value) { index += UTF8NoBom.GetBytes(&value, 1, bp, maxLen); } + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(char value, int repeatCount) + public Utf8ValueStringBuilder Append(char value, int repeatCount) { if (repeatCount < 0) { @@ -215,52 +217,54 @@ public void Append(char value, int repeatCount) Advance(len); } } + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(char value) + public Utf8ValueStringBuilder AppendLine(char value) { Append(value); AppendLine(); + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(string value, int startIndex, int count) + public Utf8ValueStringBuilder Append(string value, int startIndex, int count) { if (value == null) { if (startIndex == 0 && count == 0) { - return; - } - else - { - throw new ArgumentNullException(nameof(value)); + return this; } + throw new ArgumentNullException(nameof(value)); } Append(value.AsSpan(startIndex, count)); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(string value) + public Utf8ValueStringBuilder Append(string value) { Append(value.AsSpan()); + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(string value) + public Utf8ValueStringBuilder AppendLine(string value) { Append(value); AppendLine(); + return this; } /// Appends a contiguous region of arbitrary memory to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(ReadOnlySpan value) + public Utf8ValueStringBuilder Append(ReadOnlySpan value) { var maxLen = UTF8NoBom.GetMaxByteCount(value.Length); if (buffer!.Length - index < maxLen) @@ -269,16 +273,18 @@ public void Append(ReadOnlySpan value) } index += UTF8NoBom.GetBytes(value, buffer.AsSpan(index)); + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(ReadOnlySpan value) + public Utf8ValueStringBuilder AppendLine(ReadOnlySpan value) { Append(value); AppendLine(); + return this; } - public void AppendLiteral(ReadOnlySpan value) + public Utf8ValueStringBuilder AppendLiteral(ReadOnlySpan value) { if ((buffer!.Length - index) < value.Length) { @@ -287,10 +293,11 @@ public void AppendLiteral(ReadOnlySpan value) value.CopyTo(buffer.AsSpan(index)); index += value.Length; + return this; } /// Appends the string representation of a specified value to this instance. - public void Append(T value) + public Utf8ValueStringBuilder Append(T value) { if (!FormatterCache.TryFormatDelegate(value, buffer.AsSpan(index), out var written, default)) { @@ -301,13 +308,15 @@ public void Append(T value) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. - public void AppendLine(T value) + public Utf8ValueStringBuilder AppendLine(T value) { Append(value); AppendLine(); + return this; } // Output From a330fbcc10f451b1393a94751f87951d8ac35199 Mon Sep 17 00:00:00 2001 From: Tony Qu Date: Mon, 31 Mar 2025 18:46:29 +0800 Subject: [PATCH 2/3] Append methods return Utf16ValueStringBuilder object --- .../ZString/Utf16ValueStringBuilder.cs | 40 +++++++++++-------- src/ZString/Utf16ValueStringBuilder.cs | 40 +++++++++++-------- 2 files changed, 48 insertions(+), 32 deletions(-) diff --git a/src/ZString.Unity/Assets/Scripts/ZString/Utf16ValueStringBuilder.cs b/src/ZString.Unity/Assets/Scripts/ZString/Utf16ValueStringBuilder.cs index df6ec3b..c7deef8 100644 --- a/src/ZString.Unity/Assets/Scripts/ZString/Utf16ValueStringBuilder.cs +++ b/src/ZString.Unity/Assets/Scripts/ZString/Utf16ValueStringBuilder.cs @@ -166,7 +166,7 @@ public void AppendLine() /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(char value) + public Utf16ValueStringBuilder Append(char value) { if (buffer!.Length - index < 1) { @@ -174,10 +174,11 @@ public void Append(char value) } buffer[index++] = value; + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(char value, int repeatCount) + public Utf16ValueStringBuilder Append(char value, int repeatCount) { if (repeatCount < 0) { @@ -186,51 +187,53 @@ public void Append(char value, int repeatCount) GetSpan(repeatCount).Fill(value); Advance(repeatCount); + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(char value) + public Utf16ValueStringBuilder AppendLine(char value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(string value) + public Utf16ValueStringBuilder Append(string value) { Append(value.AsSpan()); + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(string value) + public Utf16ValueStringBuilder AppendLine(string value) { Append(value); AppendLine(); + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(string value, int startIndex, int count) + public Utf16ValueStringBuilder Append(string value, int startIndex, int count) { if (value == null) { if (startIndex == 0 && count == 0) { - return; - } - else - { - throw new ArgumentNullException(nameof(value)); + return this; } + throw new ArgumentNullException(nameof(value)); } Append(value.AsSpan(startIndex, count)); + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(char[] value, int startIndex, int charCount) + public Utf16ValueStringBuilder Append(char[] value, int startIndex, int charCount) { if (buffer!.Length - index < charCount) { @@ -238,11 +241,12 @@ public void Append(char[] value, int startIndex, int charCount) } Array.Copy(value, startIndex, buffer, index, charCount); index += charCount; + return this; } /// Appends a contiguous region of arbitrary memory to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(ReadOnlySpan value) + public Utf16ValueStringBuilder Append(ReadOnlySpan value) { if (buffer!.Length - index < value.Length) { @@ -251,17 +255,19 @@ public void Append(ReadOnlySpan value) value.CopyTo(buffer.AsSpan(index)); index += value.Length; + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(ReadOnlySpan value) + public Utf16ValueStringBuilder AppendLine(ReadOnlySpan value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. - public void Append(T value) + public Utf16ValueStringBuilder Append(T value) { if (!FormatterCache.TryFormatDelegate(value, buffer.AsSpan(index), out var written, default)) { @@ -272,13 +278,15 @@ public void Append(T value) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. - public void AppendLine(T value) + public Utf16ValueStringBuilder AppendLine(T value) { Append(value); AppendLine(); + return this; } static class ExceptionUtil diff --git a/src/ZString/Utf16ValueStringBuilder.cs b/src/ZString/Utf16ValueStringBuilder.cs index df6ec3b..c7deef8 100644 --- a/src/ZString/Utf16ValueStringBuilder.cs +++ b/src/ZString/Utf16ValueStringBuilder.cs @@ -166,7 +166,7 @@ public void AppendLine() /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(char value) + public Utf16ValueStringBuilder Append(char value) { if (buffer!.Length - index < 1) { @@ -174,10 +174,11 @@ public void Append(char value) } buffer[index++] = value; + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(char value, int repeatCount) + public Utf16ValueStringBuilder Append(char value, int repeatCount) { if (repeatCount < 0) { @@ -186,51 +187,53 @@ public void Append(char value, int repeatCount) GetSpan(repeatCount).Fill(value); Advance(repeatCount); + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(char value) + public Utf16ValueStringBuilder AppendLine(char value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(string value) + public Utf16ValueStringBuilder Append(string value) { Append(value.AsSpan()); + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(string value) + public Utf16ValueStringBuilder AppendLine(string value) { Append(value); AppendLine(); + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(string value, int startIndex, int count) + public Utf16ValueStringBuilder Append(string value, int startIndex, int count) { if (value == null) { if (startIndex == 0 && count == 0) { - return; - } - else - { - throw new ArgumentNullException(nameof(value)); + return this; } + throw new ArgumentNullException(nameof(value)); } Append(value.AsSpan(startIndex, count)); + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(char[] value, int startIndex, int charCount) + public Utf16ValueStringBuilder Append(char[] value, int startIndex, int charCount) { if (buffer!.Length - index < charCount) { @@ -238,11 +241,12 @@ public void Append(char[] value, int startIndex, int charCount) } Array.Copy(value, startIndex, buffer, index, charCount); index += charCount; + return this; } /// Appends a contiguous region of arbitrary memory to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(ReadOnlySpan value) + public Utf16ValueStringBuilder Append(ReadOnlySpan value) { if (buffer!.Length - index < value.Length) { @@ -251,17 +255,19 @@ public void Append(ReadOnlySpan value) value.CopyTo(buffer.AsSpan(index)); index += value.Length; + return this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(ReadOnlySpan value) + public Utf16ValueStringBuilder AppendLine(ReadOnlySpan value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. - public void Append(T value) + public Utf16ValueStringBuilder Append(T value) { if (!FormatterCache.TryFormatDelegate(value, buffer.AsSpan(index), out var written, default)) { @@ -272,13 +278,15 @@ public void Append(T value) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. - public void AppendLine(T value) + public Utf16ValueStringBuilder AppendLine(T value) { Append(value); AppendLine(); + return this; } static class ExceptionUtil From 95ceb93139e39a66bf4699323066c63bb77d7c01 Mon Sep 17 00:00:00 2001 From: Tony Qu Date: Mon, 16 Jun 2025 12:31:22 +0800 Subject: [PATCH 3/3] change AppendLine methods --- ...alueStringBuilder.SpanFormattableAppend.cs | 180 ++++++++++------ src/ZString/Utf16ValueStringBuilder.cs | 3 +- ...alueStringBuilder.SpanFormattableAppend.cs | 192 ++++++++++++------ 3 files changed, 250 insertions(+), 125 deletions(-) diff --git a/src/ZString/Utf16/Utf16ValueStringBuilder.SpanFormattableAppend.cs b/src/ZString/Utf16/Utf16ValueStringBuilder.SpanFormattableAppend.cs index 39009e3..8fed529 100644 --- a/src/ZString/Utf16/Utf16ValueStringBuilder.SpanFormattableAppend.cs +++ b/src/ZString/Utf16/Utf16ValueStringBuilder.SpanFormattableAppend.cs @@ -7,7 +7,7 @@ public partial struct Utf16ValueStringBuilder { /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Byte value) + public Utf16ValueStringBuilder Append(System.Byte value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -18,11 +18,12 @@ public void Append(System.Byte value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Byte value, string format) + public Utf16ValueStringBuilder Append(System.Byte value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -33,26 +34,29 @@ public void Append(System.Byte value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Byte value) + public Utf16ValueStringBuilder AppendLine(System.Byte value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Byte value, string format) + public Utf16ValueStringBuilder AppendLine(System.Byte value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.DateTime value) + public Utf16ValueStringBuilder Append(System.DateTime value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -63,11 +67,12 @@ public void Append(System.DateTime value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.DateTime value, string format) + public Utf16ValueStringBuilder Append(System.DateTime value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -78,26 +83,29 @@ public void Append(System.DateTime value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.DateTime value) + public Utf16ValueStringBuilder AppendLine(System.DateTime value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.DateTime value, string format) + public Utf16ValueStringBuilder AppendLine(System.DateTime value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.DateTimeOffset value) + public Utf16ValueStringBuilder Append(System.DateTimeOffset value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -108,11 +116,12 @@ public void Append(System.DateTimeOffset value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.DateTimeOffset value, string format) + public Utf16ValueStringBuilder Append(System.DateTimeOffset value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -123,26 +132,29 @@ public void Append(System.DateTimeOffset value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.DateTimeOffset value) + public Utf16ValueStringBuilder AppendLine(System.DateTimeOffset value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.DateTimeOffset value, string format) + public Utf16ValueStringBuilder AppendLine(System.DateTimeOffset value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Decimal value) + public Utf16ValueStringBuilder Append(System.Decimal value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -153,11 +165,12 @@ public void Append(System.Decimal value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Decimal value, string format) + public Utf16ValueStringBuilder Append(System.Decimal value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -168,26 +181,29 @@ public void Append(System.Decimal value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Decimal value) + public Utf16ValueStringBuilder AppendLine(System.Decimal value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Decimal value, string format) + public Utf16ValueStringBuilder AppendLine(System.Decimal value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Double value) + public Utf16ValueStringBuilder Append(System.Double value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -198,11 +214,12 @@ public void Append(System.Double value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Double value, string format) + public Utf16ValueStringBuilder Append(System.Double value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -213,26 +230,29 @@ public void Append(System.Double value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Double value) + public Utf16ValueStringBuilder AppendLine(System.Double value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Double value, string format) + public Utf16ValueStringBuilder AppendLine(System.Double value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Int16 value) + public Utf16ValueStringBuilder Append(System.Int16 value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -243,11 +263,12 @@ public void Append(System.Int16 value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Int16 value, string format) + public Utf16ValueStringBuilder Append(System.Int16 value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -258,26 +279,29 @@ public void Append(System.Int16 value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Int16 value) + public Utf16ValueStringBuilder AppendLine(System.Int16 value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Int16 value, string format) + public Utf16ValueStringBuilder AppendLine(System.Int16 value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Int32 value) + public Utf16ValueStringBuilder Append(System.Int32 value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -288,11 +312,12 @@ public void Append(System.Int32 value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Int32 value, string format) + public Utf16ValueStringBuilder Append(System.Int32 value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -303,26 +328,29 @@ public void Append(System.Int32 value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Int32 value) + public Utf16ValueStringBuilder AppendLine(System.Int32 value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Int32 value, string format) + public Utf16ValueStringBuilder AppendLine(System.Int32 value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Int64 value) + public Utf16ValueStringBuilder Append(System.Int64 value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -333,11 +361,12 @@ public void Append(System.Int64 value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Int64 value, string format) + public Utf16ValueStringBuilder Append(System.Int64 value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -348,26 +377,29 @@ public void Append(System.Int64 value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Int64 value) + public Utf16ValueStringBuilder AppendLine(System.Int64 value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Int64 value, string format) + public Utf16ValueStringBuilder AppendLine(System.Int64 value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.SByte value) + public Utf16ValueStringBuilder Append(System.SByte value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -378,11 +410,12 @@ public void Append(System.SByte value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.SByte value, string format) + public Utf16ValueStringBuilder Append(System.SByte value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -393,26 +426,29 @@ public void Append(System.SByte value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.SByte value) + public Utf16ValueStringBuilder AppendLine(System.SByte value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.SByte value, string format) + public Utf16ValueStringBuilder AppendLine(System.SByte value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Single value) + public Utf16ValueStringBuilder Append(System.Single value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -423,11 +459,12 @@ public void Append(System.Single value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Single value, string format) + public Utf16ValueStringBuilder Append(System.Single value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -438,26 +475,29 @@ public void Append(System.Single value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Single value) + public Utf16ValueStringBuilder AppendLine(System.Single value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Single value, string format) + public Utf16ValueStringBuilder AppendLine(System.Single value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.TimeSpan value) + public Utf16ValueStringBuilder Append(System.TimeSpan value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -468,11 +508,12 @@ public void Append(System.TimeSpan value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.TimeSpan value, string format) + public Utf16ValueStringBuilder Append(System.TimeSpan value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -483,26 +524,29 @@ public void Append(System.TimeSpan value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.TimeSpan value) + public Utf16ValueStringBuilder AppendLine(System.TimeSpan value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.TimeSpan value, string format) + public Utf16ValueStringBuilder AppendLine(System.TimeSpan value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.UInt16 value) + public Utf16ValueStringBuilder Append(System.UInt16 value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -513,11 +557,12 @@ public void Append(System.UInt16 value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.UInt16 value, string format) + public Utf16ValueStringBuilder Append(System.UInt16 value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -528,26 +573,29 @@ public void Append(System.UInt16 value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.UInt16 value) + public Utf16ValueStringBuilder AppendLine(System.UInt16 value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.UInt16 value, string format) + public Utf16ValueStringBuilder AppendLine(System.UInt16 value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.UInt32 value) + public Utf16ValueStringBuilder Append(System.UInt32 value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -558,11 +606,12 @@ public void Append(System.UInt32 value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.UInt32 value, string format) + public Utf16ValueStringBuilder Append(System.UInt32 value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -573,26 +622,29 @@ public void Append(System.UInt32 value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.UInt32 value) + public Utf16ValueStringBuilder AppendLine(System.UInt32 value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.UInt32 value, string format) + public Utf16ValueStringBuilder AppendLine(System.UInt32 value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.UInt64 value) + public Utf16ValueStringBuilder Append(System.UInt64 value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -603,11 +655,12 @@ public void Append(System.UInt64 value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.UInt64 value, string format) + public Utf16ValueStringBuilder Append(System.UInt64 value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -618,26 +671,29 @@ public void Append(System.UInt64 value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.UInt64 value) + public Utf16ValueStringBuilder AppendLine(System.UInt64 value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.UInt64 value, string format) + public Utf16ValueStringBuilder AppendLine(System.UInt64 value, string format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Guid value) + public Utf16ValueStringBuilder Append(System.Guid value) { if(!value.TryFormat(buffer.AsSpan(index), out var written)) { @@ -648,11 +704,12 @@ public void Append(System.Guid value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Guid value, string format) + public Utf16ValueStringBuilder Append(System.Guid value, string format) { if(!value.TryFormat(buffer.AsSpan(index), out var written, format.AsSpan())) { @@ -663,22 +720,25 @@ public void Append(System.Guid value, string format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Guid value) + public Utf16ValueStringBuilder AppendLine(System.Guid value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Guid value, string format) + public Utf16ValueStringBuilder AppendLine(System.Guid value, string format) { Append(value, format); AppendLine(); + return this; } } } diff --git a/src/ZString/Utf16ValueStringBuilder.cs b/src/ZString/Utf16ValueStringBuilder.cs index c7deef8..ef9811b 100644 --- a/src/ZString/Utf16ValueStringBuilder.cs +++ b/src/ZString/Utf16ValueStringBuilder.cs @@ -147,7 +147,7 @@ public void Grow(int sizeHint) /// Appends the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine() + public Utf16ValueStringBuilder AppendLine() { if (crlf) { @@ -162,6 +162,7 @@ public void AppendLine() buffer[index] = newLine1; index += 1; } + return this; } /// Appends the string representation of a specified value to this instance. diff --git a/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs b/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs index 5321ecb..6a303f8 100644 --- a/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs +++ b/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs @@ -9,7 +9,7 @@ public partial struct Utf8ValueStringBuilder { /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Byte value) + public Utf8ValueStringBuilder Append(System.Byte value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -20,11 +20,12 @@ public void Append(System.Byte value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Byte value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.Byte value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -35,27 +36,30 @@ public void Append(System.Byte value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Byte value) + public Utf8ValueStringBuilder AppendLine(System.Byte value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Byte value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.Byte value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.DateTime value) + public Utf8ValueStringBuilder Append(System.DateTime value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -66,11 +70,12 @@ public void Append(System.DateTime value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.DateTime value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.DateTime value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -81,27 +86,30 @@ public void Append(System.DateTime value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.DateTime value) + public Utf8ValueStringBuilder AppendLine(System.DateTime value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.DateTime value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.DateTime value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.DateTimeOffset value) + public Utf8ValueStringBuilder Append(System.DateTimeOffset value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -112,11 +120,12 @@ public void Append(System.DateTimeOffset value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.DateTimeOffset value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.DateTimeOffset value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -127,27 +136,30 @@ public void Append(System.DateTimeOffset value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.DateTimeOffset value) + public Utf8ValueStringBuilder AppendLine(System.DateTimeOffset value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.DateTimeOffset value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.DateTimeOffset value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Decimal value) + public Utf8ValueStringBuilder Append(System.Decimal value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -158,11 +170,12 @@ public void Append(System.Decimal value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Decimal value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.Decimal value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -173,27 +186,30 @@ public void Append(System.Decimal value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Decimal value) + public Utf8ValueStringBuilder AppendLine(System.Decimal value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Decimal value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.Decimal value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Double value) + public Utf8ValueStringBuilder Append(System.Double value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -204,11 +220,12 @@ public void Append(System.Double value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Double value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.Double value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -219,27 +236,30 @@ public void Append(System.Double value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Double value) + public Utf8ValueStringBuilder AppendLine(System.Double value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Double value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.Double value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Int16 value) + public Utf8ValueStringBuilder Append(System.Int16 value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -250,11 +270,12 @@ public void Append(System.Int16 value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Int16 value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.Int16 value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -265,27 +286,30 @@ public void Append(System.Int16 value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Int16 value) + public Utf8ValueStringBuilder AppendLine(System.Int16 value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Int16 value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.Int16 value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Int32 value) + public Utf8ValueStringBuilder Append(System.Int32 value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -296,11 +320,12 @@ public void Append(System.Int32 value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Int32 value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.Int32 value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -311,27 +336,30 @@ public void Append(System.Int32 value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Int32 value) + public Utf8ValueStringBuilder AppendLine(System.Int32 value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Int32 value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.Int32 value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Int64 value) + public Utf8ValueStringBuilder Append(System.Int64 value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -342,11 +370,12 @@ public void Append(System.Int64 value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Int64 value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.Int64 value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -357,27 +386,30 @@ public void Append(System.Int64 value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Int64 value) + public Utf8ValueStringBuilder AppendLine(System.Int64 value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Int64 value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.Int64 value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.SByte value) + public Utf8ValueStringBuilder Append(System.SByte value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -388,11 +420,12 @@ public void Append(System.SByte value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.SByte value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.SByte value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -403,27 +436,30 @@ public void Append(System.SByte value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.SByte value) + public Utf8ValueStringBuilder AppendLine(System.SByte value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.SByte value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.SByte value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Single value) + public Utf8ValueStringBuilder Append(System.Single value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -434,11 +470,12 @@ public void Append(System.Single value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Single value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.Single value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -449,27 +486,30 @@ public void Append(System.Single value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Single value) + public Utf8ValueStringBuilder AppendLine(System.Single value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Single value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.Single value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.TimeSpan value) + public Utf8ValueStringBuilder Append(System.TimeSpan value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -480,11 +520,12 @@ public void Append(System.TimeSpan value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.TimeSpan value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.TimeSpan value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -495,27 +536,30 @@ public void Append(System.TimeSpan value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.TimeSpan value) + public Utf8ValueStringBuilder AppendLine(System.TimeSpan value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.TimeSpan value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.TimeSpan value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.UInt16 value) + public Utf8ValueStringBuilder Append(System.UInt16 value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -526,11 +570,12 @@ public void Append(System.UInt16 value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.UInt16 value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.UInt16 value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -541,27 +586,30 @@ public void Append(System.UInt16 value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.UInt16 value) + public Utf8ValueStringBuilder AppendLine(System.UInt16 value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.UInt16 value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.UInt16 value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.UInt32 value) + public Utf8ValueStringBuilder Append(System.UInt32 value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -572,11 +620,12 @@ public void Append(System.UInt32 value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.UInt32 value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.UInt32 value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -587,27 +636,30 @@ public void Append(System.UInt32 value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.UInt32 value) + public Utf8ValueStringBuilder AppendLine(System.UInt32 value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.UInt32 value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.UInt32 value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.UInt64 value) + public Utf8ValueStringBuilder Append(System.UInt64 value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -618,11 +670,12 @@ public void Append(System.UInt64 value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.UInt64 value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.UInt64 value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -633,27 +686,30 @@ public void Append(System.UInt64 value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.UInt64 value) + public Utf8ValueStringBuilder AppendLine(System.UInt64 value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.UInt64 value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.UInt64 value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Guid value) + public Utf8ValueStringBuilder Append(System.Guid value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -664,11 +720,12 @@ public void Append(System.Guid value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Guid value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.Guid value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -679,27 +736,30 @@ public void Append(System.Guid value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Guid value) + public Utf8ValueStringBuilder AppendLine(System.Guid value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Guid value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.Guid value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Boolean value) + public Utf8ValueStringBuilder Append(System.Boolean value) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) { @@ -710,11 +770,12 @@ public void Append(System.Boolean value) } } index += written; + return this; } /// Appends the string representation of a specified value to this instance with numeric format strings. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Append(System.Boolean value, StandardFormat format) + public Utf8ValueStringBuilder Append(System.Boolean value, StandardFormat format) { if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) { @@ -725,22 +786,25 @@ public void Append(System.Boolean value, StandardFormat format) } } index += written; + return this; } /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Boolean value) + public Utf8ValueStringBuilder AppendLine(System.Boolean value) { Append(value); AppendLine(); + return this; } /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLine(System.Boolean value, StandardFormat format) + public Utf8ValueStringBuilder AppendLine(System.Boolean value, StandardFormat format) { Append(value, format); AppendLine(); + return this; } }