using System.Collections.Generic;
public static void Main()
var obj = new List<FileDiff>()
Included = new Diff<int> {Added = new HashSet<int> {1, 2}},
Excluded = new Diff<int> {Added = new HashSet<int> {1, 2}},
Existing = new Diff<int> {Added = new HashSet<int> {1, 2, 3}}
Included = new Diff<int> {Added = new HashSet<int> {3, 4, 5}},
Excluded = new Diff<int> {Added = new HashSet<int> {11, 222}},
Existing = new Diff<int> {Added = new HashSet<int>()}
Included = new Diff<int> {Added = new HashSet<int> {1, 2}},
Excluded = new Diff<int> {Added = new HashSet<int> {1, 2}},
Existing = new Diff<int> {Added = new HashSet<int> {1, 2, 3}}
.Select(g => new FileDiff2
Names = g.Select(f => f.Name).ToArray(),
Included = g.Key.Included,
Excluded = g.Key.Excluded,
Existing = g.Key.Existing,
Console.WriteLine(JsonSerializer.Serialize<List<FileDiff2>>((List<FileDiff2>)obj2, new JsonSerializerOptions { WriteIndented = true }));
public string Name { get; set; }
public Diff<int> Included { get; set; }
public Diff<int> Excluded { get; set; }
public Diff<int> Existing { get; set; }
public string[] Names { get; set; }
public Diff<int> Included { get; set; }
public Diff<int> Excluded { get; set; }
public Diff<int> Existing { get; set; }
public class Diff<T> : IEquatable<Diff<T>>
public HashSet<T> Added { get; set; }
public override int GetHashCode()
foreach (var foo in Added)
hash = hash * 31 + foo.GetHashCode();
public override bool Equals(object obj)
return this.Equals(obj as Diff<T>);
public bool Equals(Diff<T> other)
return this.Added.SetEquals(other.Added);