Skip to content

Commit e86baec

Browse files
committed
Added inlining and better exception message
1 parent f9f735d commit e86baec

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ All notable changes to **ValueStringBuilder** will be documented in this file. T
99
### Added
1010
- `Append(char* value, int length)` overload.
1111

12+
### Changed
13+
- Better exception when appending `ISpanFormattable` and buffer is not large enough.
14+
1215
## [1.9.0] - 2022-11-18
1316

1417
### Added

src/LinkDotNet.StringBuilder/ValueStringBuilder.Append.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void Append(scoped ReadOnlySpan<char> str)
4444
/// </summary>
4545
/// <param name="value">The pointer to the start of the buffer.</param>
4646
/// <param name="length">The number of characters in the buffer.</param>
47+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
4748
public unsafe void Append(char* value, int length)
4849
{
4950
Append(new ReadOnlySpan<char>(value, length));
@@ -87,7 +88,7 @@ private void AppendSpanFormattable<T>(T value, ReadOnlySpan<char> format = defau
8788
}
8889
else
8990
{
90-
throw new InvalidOperationException($"Could not insert {value} into given buffer. Is the buffer large enough?");
91+
throw new InvalidOperationException($"Could not insert {value} into given buffer. Is the buffer (size: {bufferSize}) large enough?");
9192
}
9293
}
9394
}

src/LinkDotNet.StringBuilder/ValueStringBuilder.Insert.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private void InsertSpanFormattable<T>(int index, T value, ReadOnlySpan<char> for
9090
}
9191
else
9292
{
93-
throw new InvalidOperationException($"Could not insert {value} into given buffer. Is the buffer large enough?");
93+
throw new InvalidOperationException($"Could not insert {value} into given buffer. Is the buffer (size: {bufferSize}) large enough?");
9494
}
9595
}
9696
}

0 commit comments

Comments
 (0)