Skip to content

Commit dd21624

Browse files
author
LinkDotNet Bot
committed
Updating to newest release
2 parents 0fb8f60 + 4a777f6 commit dd21624

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ All notable changes to **ValueStringBuilder** will be documented in this file. T
66

77
## [Unreleased]
88

9+
## [3.2.0] - 2025-10-31
10+
11+
### Changed
12+
13+
- Renamed `PadLeft(ReadOnlySpan<char>, int, char)` and `PadRight(ReadOnlySpan<char>, int, char)` to `AppendPadLeft(ReadOnlySpan<char>, int, char)` and `AppendPadRight(ReadOnlySpan<char>, int, char)` respectively.
14+
915
## [3.1.0] - 2025-10-31
1016

1117
### Added
@@ -515,7 +521,8 @@ This release brings extensions to the `ValueStringBuilder` API. For `v1.0` the `
515521

516522
- Initial release
517523

518-
[unreleased]: https://github.com/linkdotnet/StringBuilder/compare/3.1.0...HEAD
524+
[unreleased]: https://github.com/linkdotnet/StringBuilder/compare/3.2.0...HEAD
525+
[3.2.0]: https://github.com/linkdotnet/StringBuilder/compare/3.1.0...3.2.0
519526
[3.1.0]: https://github.com/linkdotnet/StringBuilder/compare/3.0.0...3.1.0
520527
[3.0.0]: https://github.com/linkdotnet/StringBuilder/compare/2.4.1...3.0.0
521528
[2.4.1]: https://github.com/linkdotnet/StringBuilder/compare/2.4.0...2.4.1

src/LinkDotNet.StringBuilder/ValueStringBuilder.Pad.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ public void PadRight(int totalWidth, char paddingChar)
4848
/// Appends the source string padded on the left with the given character to reach the specified total width.
4949
/// </summary>
5050
/// <param name="source">The source string to pad and append.</param>
51-
/// <param name="totalWidth">Total width of the padded string.</param>
51+
/// <param name="sourceTotalWidth">Total width of the padded string.</param>
5252
/// <param name="paddingChar">Character to pad the string with. Defaults to space.</param>
5353
[MethodImpl(MethodImplOptions.AggressiveInlining)]
54-
public void PadLeft(ReadOnlySpan<char> source, int totalWidth, char paddingChar = ' ')
54+
public void AppendPadLeft(scoped ReadOnlySpan<char> source, int sourceTotalWidth, char paddingChar = ' ')
5555
{
56-
if (totalWidth <= source.Length)
56+
if (sourceTotalWidth <= source.Length)
5757
{
5858
Append(source);
5959
return;
6060
}
6161

62-
var padding = totalWidth - source.Length;
63-
EnsureCapacity(bufferPosition + totalWidth);
62+
var padding = sourceTotalWidth - source.Length;
63+
EnsureCapacity(bufferPosition + sourceTotalWidth);
6464

6565
buffer.Slice(bufferPosition, padding).Fill(paddingChar);
6666
bufferPosition += padding;
@@ -73,19 +73,19 @@ public void PadLeft(ReadOnlySpan<char> source, int totalWidth, char paddingChar
7373
/// Appends the source string padded on the right with the given character to reach the specified total width.
7474
/// </summary>
7575
/// <param name="source">The source string to pad and append.</param>
76-
/// <param name="totalWidth">Total width of the padded string.</param>
76+
/// <param name="sourceTotalWidth">Total width of the padded string.</param>
7777
/// <param name="paddingChar">Character to pad the string with. Defaults to space.</param>
7878
[MethodImpl(MethodImplOptions.AggressiveInlining)]
79-
public void PadRight(ReadOnlySpan<char> source, int totalWidth, char paddingChar = ' ')
79+
public void AppendPadRight(scoped ReadOnlySpan<char> source, int sourceTotalWidth, char paddingChar = ' ')
8080
{
81-
if (totalWidth <= source.Length)
81+
if (sourceTotalWidth <= source.Length)
8282
{
8383
Append(source);
8484
return;
8585
}
8686

87-
var padding = totalWidth - source.Length;
88-
EnsureCapacity(bufferPosition + totalWidth);
87+
var padding = sourceTotalWidth - source.Length;
88+
EnsureCapacity(bufferPosition + sourceTotalWidth);
8989

9090
source.CopyTo(buffer[bufferPosition..]);
9191
bufferPosition += source.Length;

tests/LinkDotNet.StringBuilder.UnitTests/ValueStringBuilder.Pad.Tests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void ShouldPadLeftWithSource()
4747
{
4848
using var stringBuilder = new ValueStringBuilder();
4949

50-
stringBuilder.PadLeft("Hello".AsSpan(), 10, ' ');
50+
stringBuilder.AppendPadLeft("Hello".AsSpan(), 10, ' ');
5151

5252
stringBuilder.ToString().ShouldBe(" Hello");
5353
}
@@ -57,7 +57,7 @@ public void ShouldPadRightWithSource()
5757
{
5858
using var stringBuilder = new ValueStringBuilder();
5959

60-
stringBuilder.PadRight("Hello".AsSpan(), 10, ' ');
60+
stringBuilder.AppendPadRight("Hello".AsSpan(), 10, ' ');
6161

6262
stringBuilder.ToString().ShouldBe("Hello ");
6363
}
@@ -67,7 +67,7 @@ public void ShouldPadLeftWithSourceAndCustomChar()
6767
{
6868
using var stringBuilder = new ValueStringBuilder();
6969

70-
stringBuilder.PadLeft("42".AsSpan(), 5, '0');
70+
stringBuilder.AppendPadLeft("42".AsSpan(), 5, '0');
7171

7272
stringBuilder.ToString().ShouldBe("00042");
7373
}
@@ -77,7 +77,7 @@ public void ShouldPadRightWithSourceAndCustomChar()
7777
{
7878
using var stringBuilder = new ValueStringBuilder();
7979

80-
stringBuilder.PadRight("Test".AsSpan(), 8, '*');
80+
stringBuilder.AppendPadRight("Test".AsSpan(), 8, '*');
8181

8282
stringBuilder.ToString().ShouldBe("Test****");
8383
}
@@ -87,7 +87,7 @@ public void GivenTotalWidthIsSmallerThanSourceLength_WhenPadLeftWithSource_ThenS
8787
{
8888
using var stringBuilder = new ValueStringBuilder();
8989

90-
stringBuilder.PadLeft("Hello".AsSpan(), 3, ' ');
90+
stringBuilder.AppendPadLeft("Hello".AsSpan(), 3, ' ');
9191

9292
stringBuilder.ToString().ShouldBe("Hello");
9393
}
@@ -97,7 +97,7 @@ public void GivenTotalWidthIsSmallerThanSourceLength_WhenPadRightWithSource_Then
9797
{
9898
using var stringBuilder = new ValueStringBuilder();
9999

100-
stringBuilder.PadRight("Hello".AsSpan(), 3, ' ');
100+
stringBuilder.AppendPadRight("Hello".AsSpan(), 3, ' ');
101101

102102
stringBuilder.ToString().ShouldBe("Hello");
103103
}
@@ -107,8 +107,8 @@ public void ShouldPadLeftWithSourceMultipleTimes()
107107
{
108108
using var stringBuilder = new ValueStringBuilder();
109109

110-
stringBuilder.PadLeft("A".AsSpan(), 3, '-');
111-
stringBuilder.PadLeft("B".AsSpan(), 3, '-');
110+
stringBuilder.AppendPadLeft("A".AsSpan(), 3, '-');
111+
stringBuilder.AppendPadLeft("B".AsSpan(), 3, '-');
112112

113113
stringBuilder.ToString().ShouldBe("--A--B");
114114
}
@@ -118,8 +118,8 @@ public void ShouldPadRightWithSourceMultipleTimes()
118118
{
119119
using var stringBuilder = new ValueStringBuilder();
120120

121-
stringBuilder.PadRight("A".AsSpan(), 3, '-');
122-
stringBuilder.PadRight("B".AsSpan(), 3, '-');
121+
stringBuilder.AppendPadRight("A".AsSpan(), 3, '-');
122+
stringBuilder.AppendPadRight("B".AsSpan(), 3, '-');
123123

124124
stringBuilder.ToString().ShouldBe("A--B--");
125125
}
@@ -129,7 +129,7 @@ public void ShouldPadLeftWithSourceAndExistingContent()
129129
{
130130
using var stringBuilder = new ValueStringBuilder("Start ");
131131

132-
stringBuilder.PadLeft("End".AsSpan(), 10, '.');
132+
stringBuilder.AppendPadLeft("End".AsSpan(), 10, '.');
133133

134134
stringBuilder.ToString().ShouldBe("Start .......End");
135135
}
@@ -139,7 +139,7 @@ public void ShouldPadRightWithSourceAndExistingContent()
139139
{
140140
using var stringBuilder = new ValueStringBuilder("Start ");
141141

142-
stringBuilder.PadRight("End".AsSpan(), 10, '.');
142+
stringBuilder.AppendPadRight("End".AsSpan(), 10, '.');
143143

144144
stringBuilder.ToString().ShouldBe("Start End.......");
145145
}

0 commit comments

Comments
 (0)