-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: nullReferenceException thrown when FileLinePositionSpan does not…
… contain a path (#289)
- Loading branch information
1 parent
9383cbb
commit 6e48be3
Showing
3 changed files
with
12 additions
and
2 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/Tests/Tests.FileLinePositionSpanConverter_Empty.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
src/Verify.SourceGenerators/Converters/FileLinePositionSpanConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"); | ||
} | ||
} | ||
} |