Skip to content

Commit 77a88a4

Browse files
committed
Ensure we serialize only the necessary parts of location
1 parent 6862110 commit 77a88a4

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,8 +982,23 @@ private Package() { }
982982

983983
internal sealed class SimpleDiagnostic
984984
{
985-
public required FileLinePositionSpan Location { get; init; }
985+
public required Position Location { get; init; }
986986
public required string Message { get; init; }
987+
988+
/// <summary>
989+
/// An adapter of <see cref="FileLinePositionSpan"/> that ensures we JSON-serialize only the necessary fields.
990+
/// </summary>
991+
public readonly struct Position
992+
{
993+
public string Path { get; init; }
994+
public LinePositionSpan Span { get; init; }
995+
996+
public static implicit operator Position(FileLinePositionSpan fileLinePositionSpan) => new()
997+
{
998+
Path = fileLinePositionSpan.Path,
999+
Span = fileLinePositionSpan.Span,
1000+
};
1001+
}
9871002
}
9881003

9891004
internal sealed class RunFileBuildCacheEntry

0 commit comments

Comments
 (0)