Skip to content

Commit e4bf4e7

Browse files
author
LinkDotNet Bot
committed
Updating to newest release
2 parents dd21624 + 1d30696 commit e4bf4e7

14 files changed

+232
-17
lines changed

.github/workflows/codeql.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
steps:
2424
- name: Checkout repository
25-
uses: actions/checkout@v5
25+
uses: actions/checkout@v6
2626

2727
- uses: actions/setup-dotnet@v5
2828
with:
@@ -32,10 +32,10 @@ jobs:
3232
10.0.x
3333
3434
- name: Initialize CodeQL
35-
uses: github/codeql-action/init@v3
35+
uses: github/codeql-action/init@v4
3636

3737
- name: Autobuild
38-
uses: github/codeql-action/autobuild@v3
38+
uses: github/codeql-action/autobuild@v4
3939

4040
- name: Perform CodeQL Analysis
41-
uses: github/codeql-action/analyze@v3
41+
uses: github/codeql-action/analyze@v4

.github/workflows/create-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
steps:
2121

2222
- name: Checkout repository
23-
uses: actions/checkout@v5
23+
uses: actions/checkout@v6
2424
with:
2525
token: ${{ secrets.SBPAT }}
2626
persist-credentials: true

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: windows-latest
1313

1414
steps:
15-
- uses: actions/checkout@v5
15+
- uses: actions/checkout@v6
1616

1717
- name: Setup .NET
1818
uses: actions/setup-dotnet@v5

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v5
15+
- uses: actions/checkout@v6
1616
- name: Setup .NET
1717
uses: actions/setup-dotnet@v5
1818
with:

.github/workflows/update-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
steps:
1515
- name: Checkout repository
16-
uses: actions/checkout@v5
16+
uses: actions/checkout@v6
1717
with:
1818
token: ${{ secrets.SBPAT }}
1919
persist-credentials: false

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.3.0] - 2026-01-19
10+
11+
### Added
12+
13+
- Added `AppendInterpolatedStringHandler` to support zero-allocation string interpolation in `Append` and `AppendLine` methods.
14+
915
## [3.2.0] - 2025-10-31
1016

1117
### Changed
@@ -521,7 +527,8 @@ This release brings extensions to the `ValueStringBuilder` API. For `v1.0` the `
521527

522528
- Initial release
523529

524-
[unreleased]: https://github.com/linkdotnet/StringBuilder/compare/3.2.0...HEAD
530+
[unreleased]: https://github.com/linkdotnet/StringBuilder/compare/3.3.0...HEAD
531+
[3.3.0]: https://github.com/linkdotnet/StringBuilder/compare/3.2.0...3.3.0
525532
[3.2.0]: https://github.com/linkdotnet/StringBuilder/compare/3.1.0...3.2.0
526533
[3.1.0]: https://github.com/linkdotnet/StringBuilder/compare/3.0.0...3.1.0
527534
[3.0.0]: https://github.com/linkdotnet/StringBuilder/compare/2.4.1...3.0.0

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup>
4-
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.15.0.120848">
4+
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.17.0.131074">
55
<PrivateAssets>all</PrivateAssets>
66
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
77
</PackageReference>

src/LinkDotNet.StringBuilder/LinkDotNet.StringBuilder.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</PropertyGroup>
4343

4444
<ItemGroup>
45-
<PackageReference Include="Meziantou.Analyzer" Version="2.0.239">
45+
<PackageReference Include="Meziantou.Analyzer" Version="2.0.267">
4646
<PrivateAssets>all</PrivateAssets>
4747
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4848
</PackageReference>
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
using System.Runtime.CompilerServices;
2+
3+
namespace LinkDotNet.StringBuilder;
4+
5+
public ref partial struct ValueStringBuilder
6+
{
7+
/// <summary>
8+
/// Appends an interpolated string to the builder.
9+
/// </summary>
10+
/// <param name="handler">The interpolated string handler.</param>
11+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
12+
public void Append([InterpolatedStringHandlerArgument("")] ref AppendInterpolatedStringHandler handler)
13+
{
14+
this = handler.Builder;
15+
}
16+
17+
/// <summary>
18+
/// Appends an interpolated string followed by a new line to the builder.
19+
/// </summary>
20+
/// <param name="handler">The interpolated string handler.</param>
21+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
22+
public void AppendLine([InterpolatedStringHandlerArgument("")] ref AppendInterpolatedStringHandler handler)
23+
{
24+
this = handler.Builder;
25+
Append(Environment.NewLine);
26+
}
27+
28+
/// <summary>
29+
/// Nested struct which handles interpolated strings for <see cref="ValueStringBuilder"/>.
30+
/// </summary>
31+
[InterpolatedStringHandler]
32+
public ref struct AppendInterpolatedStringHandler
33+
{
34+
internal ValueStringBuilder Builder;
35+
36+
/// <summary>
37+
/// Initializes a new instance of the <see cref="AppendInterpolatedStringHandler"/> struct.
38+
/// </summary>
39+
/// <param name="literalLength">The length of the literal part of the interpolated string.</param>
40+
/// <param name="formattedCount">The number of formatted segments in the interpolated string.</param>
41+
/// <param name="builder">The builder to append to.</param>
42+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
43+
public AppendInterpolatedStringHandler(int literalLength, int formattedCount, ValueStringBuilder builder)
44+
{
45+
this.Builder = builder;
46+
47+
// A conservative guess for the capacity.
48+
this.Builder.EnsureCapacity(this.Builder.Length + literalLength + (formattedCount * 11));
49+
}
50+
51+
/// <summary>
52+
/// Appends a literal string to the handler.
53+
/// </summary>
54+
/// <param name="value">The literal string.</param>
55+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
56+
public void AppendLiteral(string value) => Builder.Append(value);
57+
58+
/// <summary>
59+
/// Appends a formatted value to the handler.
60+
/// </summary>
61+
/// <param name="value">The value to format.</param>
62+
/// <typeparam name="T">The type of the value.</typeparam>
63+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
64+
public void AppendFormatted<T>(T value)
65+
{
66+
if (value is ISpanFormattable formattable)
67+
{
68+
Builder.Append(formattable);
69+
}
70+
else
71+
{
72+
Builder.Append(value?.ToString());
73+
}
74+
}
75+
76+
/// <summary>
77+
/// Appends a formatted value with a given format.
78+
/// </summary>
79+
/// <param name="value">The value to format.</param>
80+
/// <param name="format">The format string.</param>
81+
/// <typeparam name="T">The type of the value.</typeparam>
82+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
83+
public void AppendFormatted<T>(T value, string? format)
84+
{
85+
if (value is ISpanFormattable formattable)
86+
{
87+
Builder.Append(formattable, format);
88+
}
89+
else
90+
{
91+
Builder.Append(value?.ToString());
92+
}
93+
}
94+
95+
/// <summary>
96+
/// Appends a character span to the handler.
97+
/// </summary>
98+
/// <param name="value">The character span.</param>
99+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
100+
public void AppendFormatted(ReadOnlySpan<char> value) => Builder.Append(value);
101+
102+
/// <summary>
103+
/// Appends a string to the handler.
104+
/// </summary>
105+
/// <param name="value">The string value.</param>
106+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
107+
public void AppendFormatted(string? value) => Builder.Append(value);
108+
}
109+
}

src/LinkDotNet.StringBuilder/ValueStringBuilder.Replace.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public ref partial struct ValueStringBuilder
2424
public readonly void Replace(char oldValue, char newValue, int startIndex, int count)
2525
{
2626
ArgumentOutOfRangeException.ThrowIfLessThan(startIndex, 0);
27-
ArgumentOutOfRangeException.ThrowIfGreaterThan(startIndex + count, Length);
27+
ArgumentOutOfRangeException.ThrowIfGreaterThan(startIndex + count, Length, nameof(count));
2828

2929
buffer.Slice(startIndex, count).Replace(oldValue, newValue);
3030
}
@@ -84,7 +84,7 @@ public void Replace(scoped ReadOnlySpan<char> oldValue, scoped ReadOnlySpan<char
8484
public void Replace(scoped ReadOnlySpan<char> oldValue, scoped ReadOnlySpan<char> newValue, int startIndex, int count)
8585
{
8686
ArgumentOutOfRangeException.ThrowIfLessThan(startIndex, 0);
87-
ArgumentOutOfRangeException.ThrowIfGreaterThan(startIndex + count, Length);
87+
ArgumentOutOfRangeException.ThrowIfGreaterThan(startIndex + count, Length, nameof(count));
8888

8989
if (oldValue.IsEmpty || oldValue.Equals(newValue, StringComparison.Ordinal))
9090
{

0 commit comments

Comments
 (0)