@@ -2539,7 +2539,18 @@ public void AppendFormatted<T>(T value)
2539
2539
// if it only implements IFormattable, we come out even: only if it implements both do we
2540
2540
// end up paying for an extra interface check.
2541
2541
2542
- if ( value is ISpanFormattable )
2542
+ if ( typeof ( T ) . IsEnum )
2543
+ {
2544
+ if ( Enum . TryFormatUnconstrained ( value , _stringBuilder . RemainingCurrentChunk , out int charsWritten ) )
2545
+ {
2546
+ _stringBuilder . m_ChunkLength += charsWritten ;
2547
+ }
2548
+ else
2549
+ {
2550
+ AppendFormattedWithTempSpace ( value , 0 , format : null ) ;
2551
+ }
2552
+ }
2553
+ else if ( value is ISpanFormattable )
2543
2554
{
2544
2555
Span < char > destination = _stringBuilder . RemainingCurrentChunk ;
2545
2556
if ( ( ( ISpanFormattable ) value ) . TryFormat ( destination , out int charsWritten , default , _provider ) ) // constrained call avoiding boxing for value types
@@ -2560,17 +2571,6 @@ public void AppendFormatted<T>(T value)
2560
2571
AppendFormattedWithTempSpace ( value , 0 , format : null ) ;
2561
2572
}
2562
2573
}
2563
- else if ( typeof ( T ) . IsEnum )
2564
- {
2565
- if ( Enum . TryFormatUnconstrained ( value , _stringBuilder . RemainingCurrentChunk , out int charsWritten ) )
2566
- {
2567
- _stringBuilder . m_ChunkLength += charsWritten ;
2568
- }
2569
- else
2570
- {
2571
- AppendFormattedWithTempSpace ( value , 0 , format : null ) ;
2572
- }
2573
- }
2574
2574
else
2575
2575
{
2576
2576
_stringBuilder . Append ( ( ( IFormattable ) value ) . ToString ( format : null , _provider ) ) ; // constrained call avoiding boxing for value types
0 commit comments