Skip to content

Commit

Permalink
Exclude unused methods on string interpolation handler from code cove…
Browse files Browse the repository at this point in the history
…rage
  • Loading branch information
sveinungf committed Dec 27, 2023
1 parent f9130ea commit c8630a2
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions SpreadCheetah/SpreadsheetBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using SpreadCheetah.Helpers;
using System.Buffers.Text;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.CompilerServices;

Expand Down Expand Up @@ -67,7 +68,7 @@ public TryWriteInterpolatedStringHandler(int literalLength, int formattedCount,

private readonly Span<byte> GetSpan() => _buffer._buffer.AsSpan(_buffer._index + _pos);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[ExcludeFromCodeCoverage]
public bool AppendLiteral(string value)
{
Debug.Fail("Use ReadOnlySpan<byte> instead of string literals");
Expand All @@ -92,17 +93,6 @@ public bool AppendFormatted(int value)
return Fail();
}

public bool AppendFormatted(uint value)
{
if (Utf8Formatter.TryFormat(value, GetSpan(), out var bytesWritten))
{
_pos += bytesWritten;
return true;
}

return Fail();
}

public bool AppendFormatted(float value)
{
if (Utf8Formatter.TryFormat(value, GetSpan(), out var bytesWritten))
Expand All @@ -125,6 +115,7 @@ public bool AppendFormatted(double value)
return Fail();
}

[ExcludeFromCodeCoverage]
public bool AppendFormatted<T>(T value)
{
Debug.Fail("Create non-generic overloads to avoid allocations when running on .NET Framework");
Expand Down

0 comments on commit c8630a2

Please sign in to comment.