diff --git a/src/LinkDotNet.StringBuilder/ValueStringBuilder.Append.cs b/src/LinkDotNet.StringBuilder/ValueStringBuilder.Append.cs index c3259e0..d126ea8 100644 --- a/src/LinkDotNet.StringBuilder/ValueStringBuilder.Append.cs +++ b/src/LinkDotNet.StringBuilder/ValueStringBuilder.Append.cs @@ -7,7 +7,7 @@ namespace LinkDotNet.StringBuilder; public ref partial struct ValueStringBuilder { /// - /// Appends the string representation of the boolean to the builder. + /// Appends the string representation of the boolean. /// /// Bool value to add. [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -46,7 +46,7 @@ public unsafe void Append(bool value) } /// - /// Appends the string representation of the character to the builder. + /// Appends the string representation of the value. /// /// Formattable span to add. /// Optional formatter. If not provided the default of the given instance is taken. @@ -58,9 +58,9 @@ public void Append(T value, ReadOnlySpan format = default, int bufferSi where T : ISpanFormattable => AppendSpanFormattable(value, format, bufferSize); /// - /// Appends a string to the string builder. + /// Appends a string. /// - /// String, which will be added to this builder. + /// String to be added to this builder. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(scoped ReadOnlySpan str) { @@ -81,7 +81,7 @@ ref Unsafe.As(ref strRef), } /// - /// Appends a character buffer to this builder. + /// Appends a character buffer. /// /// The pointer to the start of the buffer. /// The number of characters in the buffer. @@ -102,7 +102,7 @@ public void Append(ReadOnlyMemory memory) } /// - /// Appends a single character to the string builder. + /// Appends a single character. /// /// Character to add. [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -142,7 +142,7 @@ public void AppendLine() } /// - /// Does the same as but adds a newline at the end. + /// Calls and appends a newline. /// /// String to be added to this builder. [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -153,9 +153,9 @@ public void AppendLine(scoped ReadOnlySpan str) } /// - /// Increases the size of the string builder returning a span of the length appended. + /// Appends a span of the given length, which can be written to later. /// - /// Integer representing the length to be appended. + /// Integer representing the number of characters to be appended. /// A span with the characters appended. [MethodImpl(MethodImplOptions.AggressiveInlining)] public Span AppendSpan(int length) diff --git a/src/LinkDotNet.StringBuilder/ValueStringBuilder.AppendFormat.cs b/src/LinkDotNet.StringBuilder/ValueStringBuilder.AppendFormat.cs index c7ccdad..b20b91e 100644 --- a/src/LinkDotNet.StringBuilder/ValueStringBuilder.AppendFormat.cs +++ b/src/LinkDotNet.StringBuilder/ValueStringBuilder.AppendFormat.cs @@ -65,8 +65,8 @@ public void AppendFormat( /// Format string. /// Argument for {0}. /// Argument for {1}. - /// Any type for . - /// Any type for . + /// Any type for . + /// Any type for . /// /// The current version does not allow for a custom format. /// So: AppendFormat("{0:00}") is not allowed and will result in an exception. @@ -132,9 +132,9 @@ public void AppendFormat( /// Argument for {0}. /// Argument for {1}. /// Argument for {2}. - /// Any type for . - /// Any type for . - /// Any type for . + /// Any type for . + /// Any type for . + /// Any type for . /// /// The current version does not allow for a custom format. /// So: AppendFormat("{0:00}") is not allowed and will result in an exception. @@ -205,10 +205,10 @@ public void AppendFormat( /// Argument for {1}. /// Argument for {2}. /// Argument for {3}. - /// Any type for . - /// Any type for . - /// Any type for . - /// Any type for . + /// Any type for . + /// Any type for . + /// Any type for . + /// Any type for . /// /// The current version does not allow for a custom format. /// So: AppendFormat("{0:00}") is not allowed and will result in an exception. @@ -284,11 +284,11 @@ public void AppendFormat( /// Argument for {2}. /// Argument for {3}. /// Argument for {4}. - /// Any type for . - /// Any type for . - /// Any type for . - /// Any type for . - /// Any type for . + /// Any type for . + /// Any type for . + /// Any type for . + /// Any type for . + /// Any type for . /// /// The current version does not allow for a custom format. /// So: AppendFormat("{0:00}") is not allowed and will result in an exception. diff --git a/src/LinkDotNet.StringBuilder/ValueStringBuilder.Enumerator.cs b/src/LinkDotNet.StringBuilder/ValueStringBuilder.Enumerator.cs index 964d3ce..2ca7e80 100644 --- a/src/LinkDotNet.StringBuilder/ValueStringBuilder.Enumerator.cs +++ b/src/LinkDotNet.StringBuilder/ValueStringBuilder.Enumerator.cs @@ -32,7 +32,7 @@ public readonly char Current } /// Advances the enumerator to the next element of the span. - /// True if the enumerator was successfully advancing to the next element; false if the enumerator has passed the end of the span. + /// if the enumerator successfully advanced to the next element; if the enumerator reached the end of the span. [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool MoveNext() => ++index < span.Length; } diff --git a/src/LinkDotNet.StringBuilder/ValueStringBuilder.Replace.cs b/src/LinkDotNet.StringBuilder/ValueStringBuilder.Replace.cs index 294484f..2b4b1ce 100644 --- a/src/LinkDotNet.StringBuilder/ValueStringBuilder.Replace.cs +++ b/src/LinkDotNet.StringBuilder/ValueStringBuilder.Replace.cs @@ -47,56 +47,12 @@ public readonly void Replace(char oldValue, char newValue, int startIndex, int c /// The string to replace. /// The string to replace with. /// - /// If is empty, instances of - /// are removed from this builder. + /// If is empty, instances of are removed. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Replace(ReadOnlySpan oldValue, ReadOnlySpan newValue) => Replace(oldValue, newValue, 0, Length); - /// - /// Replaces all instances of one string with another in this builder. - /// - /// The string to replace. - /// Object to replace with. - /// - /// If is from type an optimized version is taken. - /// Otherwise the ToString method is called. - /// - /// /// Any type. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ReplaceGeneric(ReadOnlySpan oldValue, T newValue) - => ReplaceGeneric(oldValue, newValue, 0, Length); - - /// - /// Replaces all instances of one string with another in this builder. - /// - /// The string to replace. - /// Object to replace with. - /// The index to start in this builder. - /// The number of characters to read in this builder. - /// - /// If is from type an optimized version is taken. - /// Otherwise the ToString method is called. - /// - /// /// Any type. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ReplaceGeneric(ReadOnlySpan oldValue, T newValue, int startIndex, int count) - { - if (newValue is ISpanFormattable spanFormattable) - { - Span tempBuffer = stackalloc char[24]; - if (spanFormattable.TryFormat(tempBuffer, out var written, default, null)) - { - Replace(oldValue, tempBuffer[..written], startIndex, count); - } - } - else - { - Replace(oldValue, (ReadOnlySpan)newValue?.ToString(), startIndex, count); - } - } - /// /// Replaces all instances of one string with another in this builder. /// @@ -105,8 +61,7 @@ public void ReplaceGeneric(ReadOnlySpan oldValue, T newValue, int start /// The index to start in this builder. /// The number of characters to read in this builder. /// - /// If is empty, instances of - /// are removed from this builder. + /// If is empty, instances of are removed. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Replace(scoped ReadOnlySpan oldValue, scoped ReadOnlySpan newValue, int startIndex, int count) @@ -160,4 +115,47 @@ public void Replace(scoped ReadOnlySpan oldValue, scoped ReadOnlySpan + /// Replaces all instances of one string with another in this builder. + /// + /// The string to replace. + /// Object to replace with. + /// + /// If is from type an optimized version is taken. + /// Otherwise the ToString method is called. + /// + /// /// Any type. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void ReplaceGeneric(ReadOnlySpan oldValue, T newValue) + => ReplaceGeneric(oldValue, newValue, 0, Length); + + /// + /// Replaces all instances of one string with another in this builder. + /// + /// The string to replace. + /// Object to replace with. + /// The index to start in this builder. + /// The number of characters to read in this builder. + /// + /// If is from type an optimized version is taken. + /// Otherwise the ToString method is called. + /// + /// /// Any type. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void ReplaceGeneric(ReadOnlySpan oldValue, T newValue, int startIndex, int count) + { + if (newValue is ISpanFormattable spanFormattable) + { + Span tempBuffer = stackalloc char[24]; + if (spanFormattable.TryFormat(tempBuffer, out var written, default, null)) + { + Replace(oldValue, tempBuffer[..written], startIndex, count); + } + } + else + { + Replace(oldValue, (ReadOnlySpan)newValue?.ToString(), startIndex, count); + } + } } \ No newline at end of file diff --git a/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs b/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs index 0a413ce..9f8c758 100644 --- a/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs +++ b/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs @@ -49,9 +49,7 @@ public ValueStringBuilder(Span initialBuffer) /// /// Initializes a new instance of the struct. /// - /// The initial text used to initialize this instance. If is null - /// the will return an empty string (). - /// + /// The initial text used to initialize this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public ValueStringBuilder(ReadOnlySpan initialText) { @@ -291,7 +289,7 @@ public readonly int LastIndexOf(ReadOnlySpan word, int startIndex) /// Returns a value indicating whether the characters in this instance are equal to the characters in a specified read-only character span. /// /// The character span to compare with the current instance. - /// true if the characters are equal to this instance, otherwise false. + /// if the characters are equal to this instance, otherwise . [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly bool Equals(ReadOnlySpan span) => span.SequenceEqual(AsSpan());