Skip to content

Commit 07ba7ef

Browse files
authored
Merge branch 'main' into more-runes
2 parents 37baccf + 1480c40 commit 07ba7ef

8 files changed

+80
-79
lines changed

src/LinkDotNet.StringBuilder/LinkDotNet.StringBuilder.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2020
<LangVersion>preview</LangVersion>
2121
<EmbedUntrackedSources>true</EmbedUntrackedSources>
22+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
2223
</PropertyGroup>
2324

2425
<ItemGroup>

src/LinkDotNet.StringBuilder/ValueStringBuilder.Append.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace LinkDotNet.StringBuilder;
77
public ref partial struct ValueStringBuilder
88
{
99
/// <summary>
10-
/// Appends the string representation of the boolean to the builder.
10+
/// Appends the string representation of the boolean.
1111
/// </summary>
1212
/// <param name="value">Bool value to add.</param>
1313
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -46,7 +46,7 @@ public unsafe void Append(bool value)
4646
}
4747

4848
/// <summary>
49-
/// Appends the string representation of the character to the builder.
49+
/// Appends the string representation of the value.
5050
/// </summary>
5151
/// <param name="value">Formattable span to add.</param>
5252
/// <param name="format">Optional formatter. If not provided the default of the given instance is taken.</param>
@@ -58,9 +58,9 @@ public void Append<T>(T value, ReadOnlySpan<char> format = default, int bufferSi
5858
where T : ISpanFormattable => AppendSpanFormattable(value, format, bufferSize);
5959

6060
/// <summary>
61-
/// Appends a string to the string builder.
61+
/// Appends a string.
6262
/// </summary>
63-
/// <param name="str">String, which will be added to this builder.</param>
63+
/// <param name="str">String to be added to this builder.</param>
6464
[MethodImpl(MethodImplOptions.AggressiveInlining)]
6565
public void Append(scoped ReadOnlySpan<char> str)
6666
{
@@ -81,7 +81,7 @@ ref Unsafe.As<char, byte>(ref strRef),
8181
}
8282

8383
/// <summary>
84-
/// Appends a character buffer to this builder.
84+
/// Appends a character buffer.
8585
/// </summary>
8686
/// <param name="value">The pointer to the start of the buffer.</param>
8787
/// <param name="length">The number of characters in the buffer.</param>
@@ -102,7 +102,7 @@ public void Append(ReadOnlyMemory<char> memory)
102102
}
103103

104104
/// <summary>
105-
/// Appends a single character to the string builder.
105+
/// Appends a single character.
106106
/// </summary>
107107
/// <param name="value">Character to add.</param>
108108
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -142,7 +142,7 @@ public void AppendLine()
142142
}
143143

144144
/// <summary>
145-
/// Does the same as <see cref="Append(char)"/> but adds a newline at the end.
145+
/// Calls <see cref="Append(ReadOnlySpan{char})"/> and appends a newline.
146146
/// </summary>
147147
/// <param name="str">String to be added to this builder.</param>
148148
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -153,9 +153,9 @@ public void AppendLine(scoped ReadOnlySpan<char> str)
153153
}
154154

155155
/// <summary>
156-
/// Increases the size of the string builder returning a span of the length appended.
156+
/// Appends a span of the given length, which can be written to later.
157157
/// </summary>
158-
/// <param name="length">Integer representing the length to be appended.</param>
158+
/// <param name="length">Integer representing the number of characters to be appended.</param>
159159
/// <returns>A span with the characters appended.</returns>
160160
[MethodImpl(MethodImplOptions.AggressiveInlining)]
161161
public Span<char> AppendSpan(int length)

src/LinkDotNet.StringBuilder/ValueStringBuilder.AppendFormat.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public void AppendFormat<T>(
6565
/// <param name="format">Format string.</param>
6666
/// <param name="arg1">Argument for <c>{0}</c>.</param>
6767
/// <param name="arg2">Argument for <c>{1}</c>.</param>
68-
/// <typeparam name="T1">Any type for <param name="arg1"></param>.</typeparam>
69-
/// <typeparam name="T2">Any type for <param name="arg2"></param>.</typeparam>
68+
/// <typeparam name="T1">Any type for <paramref name="arg1"/>.</typeparam>
69+
/// <typeparam name="T2">Any type for <paramref name="arg2"/>.</typeparam>
7070
/// <remarks>
7171
/// The current version does not allow for a custom format.
7272
/// So: <code>AppendFormat("{0:00}")</code> is not allowed and will result in an exception.
@@ -132,9 +132,9 @@ public void AppendFormat<T1, T2>(
132132
/// <param name="arg1">Argument for <c>{0}</c>.</param>
133133
/// <param name="arg2">Argument for <c>{1}</c>.</param>
134134
/// <param name="arg3">Argument for <c>{2}</c>.</param>
135-
/// <typeparam name="T1">Any type for <param name="arg1"></param>.</typeparam>
136-
/// <typeparam name="T2">Any type for <param name="arg2"></param>.</typeparam>
137-
/// <typeparam name="T3">Any type for <param name="arg3"></param>.</typeparam>
135+
/// <typeparam name="T1">Any type for <paramref name="arg1"/>.</typeparam>
136+
/// <typeparam name="T2">Any type for <paramref name="arg2"/>.</typeparam>
137+
/// <typeparam name="T3">Any type for <paramref name="arg3"/>.</typeparam>
138138
/// <remarks>
139139
/// The current version does not allow for a custom format.
140140
/// So: <code>AppendFormat("{0:00}")</code> is not allowed and will result in an exception.
@@ -205,10 +205,10 @@ public void AppendFormat<T1, T2, T3>(
205205
/// <param name="arg2">Argument for <c>{1}</c>.</param>
206206
/// <param name="arg3">Argument for <c>{2}</c>.</param>
207207
/// <param name="arg4">Argument for <c>{3}</c>.</param>
208-
/// <typeparam name="T1">Any type for <param name="arg1"></param>.</typeparam>
209-
/// <typeparam name="T2">Any type for <param name="arg2"></param>.</typeparam>
210-
/// <typeparam name="T3">Any type for <param name="arg3"></param>.</typeparam>
211-
/// <typeparam name="T4">Any type for <param name="arg4"></param>.</typeparam>
208+
/// <typeparam name="T1">Any type for <paramref name="arg1"/>.</typeparam>
209+
/// <typeparam name="T2">Any type for <paramref name="arg2"/>.</typeparam>
210+
/// <typeparam name="T3">Any type for <paramref name="arg3"/>.</typeparam>
211+
/// <typeparam name="T4">Any type for <paramref name="arg4"/>.</typeparam>
212212
/// <remarks>
213213
/// The current version does not allow for a custom format.
214214
/// So: <code>AppendFormat("{0:00}")</code> is not allowed and will result in an exception.
@@ -284,11 +284,11 @@ public void AppendFormat<T1, T2, T3, T4>(
284284
/// <param name="arg3">Argument for <c>{2}</c>.</param>
285285
/// <param name="arg4">Argument for <c>{3}</c>.</param>
286286
/// <param name="arg5">Argument for <c>{4}</c>.</param>
287-
/// <typeparam name="T1">Any type for <param name="arg1"></param>.</typeparam>
288-
/// <typeparam name="T2">Any type for <param name="arg2"></param>.</typeparam>
289-
/// <typeparam name="T3">Any type for <param name="arg3"></param>.</typeparam>
290-
/// <typeparam name="T4">Any type for <param name="arg4"></param>.</typeparam>
291-
/// <typeparam name="T5">Any type for <param name="arg5"></param>.</typeparam>
287+
/// <typeparam name="T1">Any type for <paramref name="arg1"/>.</typeparam>
288+
/// <typeparam name="T2">Any type for <paramref name="arg2"/>.</typeparam>
289+
/// <typeparam name="T3">Any type for <paramref name="arg3"/>.</typeparam>
290+
/// <typeparam name="T4">Any type for <paramref name="arg4"/>.</typeparam>
291+
/// <typeparam name="T5">Any type for <paramref name="arg5"/>.</typeparam>
292292
/// <remarks>
293293
/// The current version does not allow for a custom format.
294294
/// So: <code>AppendFormat("{0:00}")</code> is not allowed and will result in an exception.

src/LinkDotNet.StringBuilder/ValueStringBuilder.Concat.Helper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ public ref partial struct ValueStringBuilder
77
/// <summary>
88
/// Concatenates multiple objects together.
99
/// </summary>
10-
/// <param name="values">Values, which will be concatenated together.</param>
10+
/// <param name="values">Values to be concatenated together.</param>
1111
/// <typeparam name="T">Any given type, which can be translated to <see cref="string"/>.</typeparam>
12-
/// <returns>Concatenated string or an empty string if <see cref="values"/> is empty.</returns>
12+
/// <returns>Concatenated string or an empty string if <paramref name="values"/> is empty.</returns>
1313
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1414
public static string Concat<T>(params T[] values)
1515
{

src/LinkDotNet.StringBuilder/ValueStringBuilder.Enumerator.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ namespace LinkDotNet.StringBuilder;
55

66
public ref partial struct ValueStringBuilder
77
{
8+
/// <summary>
9+
/// Creates an enumerator over the characters in the builder.
10+
/// </summary>
11+
/// <returns>An enumerator over the characters in the builder.</returns>
812
public readonly Enumerator GetEnumerator() => new(buffer[..bufferPosition]);
913

1014
/// <summary>Enumerates the elements of a <see cref="Span{T}"/>.</summary>
@@ -32,7 +36,7 @@ public readonly char Current
3236
}
3337

3438
/// <summary>Advances the enumerator to the next element of the span.</summary>
35-
/// <returns>True if the enumerator was successfully advancing to the next element; false if the enumerator has passed the end of the span.</returns>
39+
/// <returns><see langword="true"/> if the enumerator successfully advanced to the next element; <see langword="false"/> if the enumerator reached the end of the span.</returns>
3640
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3741
public bool MoveNext() => ++index < span.Length;
3842
}

src/LinkDotNet.StringBuilder/ValueStringBuilder.Replace.cs

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -80,56 +80,12 @@ public void Replace(Rune oldValue, Rune newValue, int startIndex, int count)
8080
/// <param name="oldValue">The string to replace.</param>
8181
/// <param name="newValue">The string to replace <paramref name="oldValue"/> with.</param>
8282
/// <remarks>
83-
/// If <paramref name="newValue"/> is <c>empty</c>, instances of <paramref name="oldValue"/>
84-
/// are removed from this builder.
83+
/// If <paramref name="newValue"/> is <c>empty</c>, instances of <paramref name="oldValue"/> are removed.
8584
/// </remarks>
8685
[MethodImpl(MethodImplOptions.AggressiveInlining)]
8786
public void Replace(scoped ReadOnlySpan<char> oldValue, scoped ReadOnlySpan<char> newValue)
8887
=> Replace(oldValue, newValue, 0, Length);
8988

90-
/// <summary>
91-
/// Replaces all instances of one string with another in this builder.
92-
/// </summary>
93-
/// <param name="oldValue">The string to replace.</param>
94-
/// <param name="newValue">Object to replace <paramref name="oldValue"/> with.</param>
95-
/// <remarks>
96-
/// If <paramref name="newValue"/> is from type <see cref="ISpanFormattable"/> an optimized version is taken.
97-
/// Otherwise the ToString method is called.
98-
/// </remarks>
99-
/// /// <typeparam name="T">Any type.</typeparam>
100-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
101-
public void ReplaceGeneric<T>(scoped ReadOnlySpan<char> oldValue, T newValue)
102-
=> ReplaceGeneric(oldValue, newValue, 0, Length);
103-
104-
/// <summary>
105-
/// Replaces all instances of one string with another in this builder.
106-
/// </summary>
107-
/// <param name="oldValue">The string to replace.</param>
108-
/// <param name="newValue">Object to replace <paramref name="oldValue"/> with.</param>
109-
/// <param name="startIndex">The index to start in this builder.</param>
110-
/// <param name="count">The number of characters to read in this builder.</param>
111-
/// <remarks>
112-
/// If <paramref name="newValue"/> is from type <see cref="ISpanFormattable"/> an optimized version is taken.
113-
/// Otherwise the ToString method is called.
114-
/// </remarks>
115-
/// /// <typeparam name="T">Any type.</typeparam>
116-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
117-
public void ReplaceGeneric<T>(scoped ReadOnlySpan<char> oldValue, T newValue, int startIndex, int count)
118-
{
119-
if (newValue is ISpanFormattable spanFormattable)
120-
{
121-
Span<char> tempBuffer = stackalloc char[24];
122-
if (spanFormattable.TryFormat(tempBuffer, out var written, default, null))
123-
{
124-
Replace(oldValue, tempBuffer[..written], startIndex, count);
125-
}
126-
}
127-
else
128-
{
129-
Replace(oldValue, (ReadOnlySpan<char>)newValue?.ToString(), startIndex, count);
130-
}
131-
}
132-
13389
/// <summary>
13490
/// Replaces all instances of one string with another in this builder.
13591
/// </summary>
@@ -138,8 +94,7 @@ public void ReplaceGeneric<T>(scoped ReadOnlySpan<char> oldValue, T newValue, in
13894
/// <param name="startIndex">The index to start in this builder.</param>
13995
/// <param name="count">The number of characters to read in this builder.</param>
14096
/// <remarks>
141-
/// If <paramref name="newValue"/> is <c>empty</c>, instances of <paramref name="oldValue"/>
142-
/// are removed from this builder.
97+
/// If <paramref name="newValue"/> is <c>empty</c>, instances of <paramref name="oldValue"/> are removed.
14398
/// </remarks>
14499
[MethodImpl(MethodImplOptions.AggressiveInlining)]
145100
public void Replace(scoped ReadOnlySpan<char> oldValue, scoped ReadOnlySpan<char> newValue, int startIndex, int count)
@@ -193,4 +148,47 @@ public void Replace(scoped ReadOnlySpan<char> oldValue, scoped ReadOnlySpan<char
193148
}
194149
}
195150
}
151+
152+
/// <summary>
153+
/// Replaces all instances of one string with another in this builder.
154+
/// </summary>
155+
/// <param name="oldValue">The string to replace.</param>
156+
/// <param name="newValue">Object to replace <paramref name="oldValue"/> with.</param>
157+
/// <remarks>
158+
/// If <paramref name="newValue"/> is from type <see cref="ISpanFormattable"/> an optimized version is taken.
159+
/// Otherwise the ToString method is called.
160+
/// </remarks>
161+
/// /// <typeparam name="T">Any type.</typeparam>
162+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
163+
public void ReplaceGeneric<T>(ReadOnlySpan<char> oldValue, T newValue)
164+
=> ReplaceGeneric(oldValue, newValue, 0, Length);
165+
166+
/// <summary>
167+
/// Replaces all instances of one string with another in this builder.
168+
/// </summary>
169+
/// <param name="oldValue">The string to replace.</param>
170+
/// <param name="newValue">Object to replace <paramref name="oldValue"/> with.</param>
171+
/// <param name="startIndex">The index to start in this builder.</param>
172+
/// <param name="count">The number of characters to read in this builder.</param>
173+
/// <remarks>
174+
/// If <paramref name="newValue"/> is from type <see cref="ISpanFormattable"/> an optimized version is taken.
175+
/// Otherwise the ToString method is called.
176+
/// </remarks>
177+
/// /// <typeparam name="T">Any type.</typeparam>
178+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
179+
public void ReplaceGeneric<T>(ReadOnlySpan<char> oldValue, T newValue, int startIndex, int count)
180+
{
181+
if (newValue is ISpanFormattable spanFormattable)
182+
{
183+
Span<char> tempBuffer = stackalloc char[24];
184+
if (spanFormattable.TryFormat(tempBuffer, out var written, default, null))
185+
{
186+
Replace(oldValue, tempBuffer[..written], startIndex, count);
187+
}
188+
}
189+
else
190+
{
191+
Replace(oldValue, (ReadOnlySpan<char>)newValue?.ToString(), startIndex, count);
192+
}
193+
}
196194
}

src/LinkDotNet.StringBuilder/ValueStringBuilder.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ public ValueStringBuilder(Span<char> initialBuffer)
4949
/// <summary>
5050
/// Initializes a new instance of the <see cref="ValueStringBuilder"/> struct.
5151
/// </summary>
52-
/// <param name="initialText">The initial text used to initialize this instance. If <paramref name="initialText"/> is <c>null</c>
53-
/// the <see cref="ValueStringBuilder"/> will return an empty string (<see cref="string.Empty"/>).
54-
/// </param>
52+
/// <param name="initialText">The initial text used to initialize this instance.</param>
5553
[MethodImpl(MethodImplOptions.AggressiveInlining)]
5654
public ValueStringBuilder(ReadOnlySpan<char> initialText)
5755
{
@@ -87,7 +85,7 @@ public ValueStringBuilder(int initialCapacity)
8785
/// <summary>
8886
/// Returns the character at the given index or throws an <see cref="IndexOutOfRangeException"/> if the index is bigger than the string.
8987
/// </summary>
90-
/// <param name="index">Index position, which should be retrieved.</param>
88+
/// <param name="index">Character position to be retrieved.</param>
9189
public readonly ref char this[int index] => ref buffer[index];
9290

9391
/// <summary>
@@ -291,7 +289,7 @@ public readonly int LastIndexOf(ReadOnlySpan<char> word, int startIndex)
291289
/// Returns a value indicating whether the characters in this instance are equal to the characters in a specified read-only character span.
292290
/// </summary>
293291
/// <param name="span">The character span to compare with the current instance.</param>
294-
/// <returns><c>true</c> if the characters are equal to this instance, otherwise <c>false</c>.</returns>
292+
/// <returns><see langword="true"/> if the characters are equal to this instance, otherwise <see langword="false"/>.</returns>
295293
[MethodImpl(MethodImplOptions.AggressiveInlining)]
296294
public readonly bool Equals(ReadOnlySpan<char> span) => span.SequenceEqual(AsSpan());
297295

src/LinkDotNet.StringBuilder/ValueStringBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static System.Text.StringBuilder ToStringBuilder(this ValueStringBuilder
2323
/// Creates a new <see cref="ValueStringBuilder"/> from the given <paramref name="builder"/>.
2424
/// </summary>
2525
/// <param name="builder">The builder from which the new instance is derived.</param>
26-
/// <returns>A new <see cref="ValueStringBuilder"/> instance with the string represented by this <see cref="builder"/>.</returns>
26+
/// <returns>A new <see cref="ValueStringBuilder"/> instance with the string represented by this builder.</returns>
2727
/// <exception cref="ArgumentNullException">Throws if <paramref name="builder"/> is null.</exception>
2828
public static ValueStringBuilder ToValueStringBuilder(this System.Text.StringBuilder? builder)
2929
{

0 commit comments

Comments
 (0)