Skip to content

Commit

Permalink
Fixed bug when serializing DiffPiece.
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix-CodingClimber committed Apr 6, 2024
1 parent 6b4b36a commit fd9b126
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace DotNetElements.Core.StringDiff;
using System.Text.Json.Serialization;

namespace DotNetElements.Core.StringDiff;

public enum ChangeType
{
Expand All @@ -12,5 +14,13 @@ public enum ChangeType
public record struct DiffPiece(string? Text, ChangeType Type, int? PositionOld = null, int? PositionNew = null)
{
public List<DiffPiece> SubPieces { get; private init; } = [];
public bool IsOldPiece { get; set; }
public bool IsOldPiece { get; init; }

[JsonConstructor]
public DiffPiece(string? text, ChangeType type, int? positionOld, int? positionNew, List<DiffPiece> subPieces, bool isOldPiece) :
this(text, type, positionOld, positionNew)
{
SubPieces = subPieces;
IsOldPiece = isOldPiece;
}
}

0 comments on commit fd9b126

Please # to comment.