Skip to content

Commit 8ffb68b

Browse files
committed
Added compiler hints for AppendFormat
1 parent 305e670 commit 8ffb68b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ All notable changes to **ValueStringBuilder** will be documented in this file. T
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- Compiler hints for new `AppendFormat` methods
12+
913
## [1.11.1] - 2023-01-01
1014

1115
### Changed

src/LinkDotNet.StringBuilder/ValueStringBuilder.AppendFormat.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Diagnostics.CodeAnalysis;
2+
using System.Runtime.CompilerServices;
23

34
namespace LinkDotNet.StringBuilder;
45

@@ -14,6 +15,7 @@ public ref partial struct ValueStringBuilder
1415
/// The current version does not allow for a custom format.
1516
/// So: <code>AppendFormat("{0:00}")</code> is not allowed and will result in an exception.
1617
/// </remarks>
18+
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
1719
public void AppendFormat<T>(
1820
[StringSyntax(StringSyntaxAttribute.CompositeFormat)] ReadOnlySpan<char> format,
1921
T arg)
@@ -69,6 +71,7 @@ public void AppendFormat<T>(
6971
/// The current version does not allow for a custom format.
7072
/// So: <code>AppendFormat("{0:00}")</code> is not allowed and will result in an exception.
7173
/// </remarks>
74+
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
7275
public void AppendFormat<T1, T2>(
7376
[StringSyntax(StringSyntaxAttribute.CompositeFormat)] ReadOnlySpan<char> format,
7477
T1 arg1,
@@ -136,6 +139,7 @@ public void AppendFormat<T1, T2>(
136139
/// The current version does not allow for a custom format.
137140
/// So: <code>AppendFormat("{0:00}")</code> is not allowed and will result in an exception.
138141
/// </remarks>
142+
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
139143
public void AppendFormat<T1, T2, T3>(
140144
[StringSyntax(StringSyntaxAttribute.CompositeFormat)] ReadOnlySpan<char> format,
141145
T1 arg1,
@@ -193,6 +197,7 @@ public void AppendFormat<T1, T2, T3>(
193197
}
194198
}
195199

200+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
196201
private static int GetValidArgumentIndex(ReadOnlySpan<char> placeholder, int allowedRange)
197202
{
198203
#pragma warning disable MA0011

0 commit comments

Comments
 (0)