public static DynamicType CreateClass(string name, DynamicType baseClass = null, DynamicType genericArgument = null, IEnumerable <DynamicType> additionalTypes = null) { var result = new DynamicType(KindOfDynamicType.Class); result.name = name; result.baseClass = baseClass; result.genericArgument = genericArgument; result.additionalTypes = additionalTypes; return(result); }
public void ShouldHandleFieldRemovalInStructNestedInClass() { var type1 = DynamicType.CreateClass("A").WithField <string>("a").WithField("b", DynamicType.CreateStruct("B").WithField <string>("a").WithField <int>("b")); var type2 = DynamicType.CreateClass("A").WithField <string>("a").WithField("b", DynamicType.CreateStruct("B").WithField <int>("b")); testsOnDomain1.CreateInstanceOnAppDomain(type1); testsOnDomain1.SetValueOnAppDomain("a", "testing"); testsOnDomain1.SetValueOnAppDomain("b.a", "text"); testsOnDomain1.SetValueOnAppDomain("b.b", 147); var bytes = testsOnDomain1.SerializeOnAppDomain(); testsOnDomain2.CreateInstanceOnAppDomain(type2); testsOnDomain2.DeserializeOnAppDomain(bytes, GetSettingsAllowingGuidChange(Antmicro.Migrant.Customization.VersionToleranceLevel.AllowFieldRemoval)); Assert.AreEqual("testing", testsOnDomain2.GetValueOnAppDomain("a")); Assert.AreEqual(147, testsOnDomain2.GetValueOnAppDomain("b.b")); }