using System.Collections.Generic;
using System.Collections.Immutable;
static void Main(string[] args)
var current = new Test { Foo = "Hello" };
var originalProperties = GetProps(current);
var t = (current, originalProperties);
Console.WriteLine(t.originalProperties["Foo"]);
Console.WriteLine(((List<string>)t.originalProperties["Bar"]).Count());
Console.WriteLine(Environment.NewLine);
t.current.Foo = "Goodbye";
t.current.Bar.Add("abcd");
Console.WriteLine(t.originalProperties["Foo"]);
Console.WriteLine(((List<string>)t.originalProperties["Bar"]).Count());
public static ImmutableDictionary<string, object> GetProps(Test t)
.ToDictionary(x => x.Name, x => x.GetValue(t))
.ToImmutableDictionary();
public string Foo { get; set; }
public List<string> Bar { get; set; } = new();