Skip to content

Commit

Permalink
Use string interpolation handler in ContentTypesXml
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinungf committed Dec 22, 2024
1 parent a284bac commit c52c6b0
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions SpreadCheetah/MetadataXml/ContentTypesXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,9 @@ private bool TryWriteDrawings()

for (; _nextIndex < counter.WorksheetsWithImages; ++_nextIndex)
{
var span = _buffer.GetSpan();
var written = 0;

if (!DrawingStart.TryCopyTo(span, ref written)) return false;
if (!SpanHelper.TryWrite(_nextIndex + 1, span, ref written)) return false;
if (!DrawingEnd.TryCopyTo(span, ref written)) return false;

_buffer.Advance(written);
var success = _buffer.TryWrite($"{DrawingStart}{_nextIndex + 1}{DrawingEnd}");
if (!success)
return false;

Check warning on line 129 in SpreadCheetah/MetadataXml/ContentTypesXml.cs

View check run for this annotation

Codecov / codecov/patch

SpreadCheetah/MetadataXml/ContentTypesXml.cs#L129

Added line #L129 was not covered by tests
}

_nextIndex = 0;
Expand All @@ -151,14 +146,9 @@ private bool TryWriteWorksheets()
for (; _nextIndex < worksheets.Count; ++_nextIndex)
{
var worksheet = worksheets[_nextIndex];
var span = _buffer.GetSpan();
var written = 0;

if (!SheetStart.TryCopyTo(span, ref written)) return false;
if (!SpanHelper.TryWrite(worksheet.Path, span, ref written)) return false;
if (!SheetEnd.TryCopyTo(span, ref written)) return false;

_buffer.Advance(written);
var success = _buffer.TryWrite($"{SheetStart}{worksheet.Path}{SheetEnd}");
if (!success)
return false;
}

_nextIndex = 0;
Expand All @@ -172,14 +162,9 @@ private bool TryWriteComments()

for (; _nextIndex < counter.WorksheetsWithNotes; ++_nextIndex)
{
var span = _buffer.GetSpan();
var written = 0;

if (!CommentStart.TryCopyTo(span, ref written)) return false;
if (!SpanHelper.TryWrite(_nextIndex + 1, span, ref written)) return false;
if (!CommentEnd.TryCopyTo(span, ref written)) return false;

_buffer.Advance(written);
var success = _buffer.TryWrite($"{CommentStart}{_nextIndex + 1}{CommentEnd}");
if (!success)
return false;
}

_nextIndex = 0;
Expand Down

0 comments on commit c52c6b0

Please sign in to comment.