Skip to content

Commit

Permalink
fix: nullReferenceException thrown when FileLinePositionSpan does not…
Browse files Browse the repository at this point in the history
… contain a path (#289)
  • Loading branch information
jasonwoods-7 authored Sep 11, 2024
1 parent 9383cbb commit 6e48be3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 4 additions & 0 deletions src/Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public Task LocalizableStringConverter() =>
public Task FileLinePositionSpanConverter() =>
Verify(new FileLinePositionSpan("the path", new(1,2), new(2,4)));

[Fact]
public Task FileLinePositionSpanConverter_Empty() =>
Verify(new FileLinePositionSpan());

class LocalizableStringImp :
LocalizableString
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
class FileLinePositionSpanConverter :
WriteOnlyJsonConverter<FileLinePositionSpan>
{
public override void Write(VerifyJsonWriter writer, FileLinePositionSpan value) =>
writer.WriteValue($"{value.Path.Replace('/', '\\')}: {value.Span}");
public override void Write(VerifyJsonWriter writer, FileLinePositionSpan value)
{
if (value.IsValid)
{
writer.WriteValue($"{value.Path.Replace('/', '\\')}: {value.Span}");
}
}
}

0 comments on commit 6e48be3

Please sign in to comment.