public static int test_0_vt_ldfld_stfld() { var foo = new GFoo <Foo> () { t = new Foo() { i = 1, j = 2 }, i = 5, f = new Foo() { i = 5, j = 6 } }; var farr = new GFoo <Foo>[] { foo }; /* Normal fields with a variable offset */ var iarr = new int [10]; ldfld_nongeneric <Foo> (farr, iarr); if (iarr [0] != 5) { return(1); } iarr [0] = 16; stfld_nongeneric <Foo> (farr, iarr); if (farr [0].i != 16) { return(2); } /* Variable type field with a variable offset */ var arr = new Foo [10]; ldfld <Foo> (farr, arr); if (arr [0].i != 1 || arr [0].j != 2) { return(3); } arr [0] = new Foo() { i = 3, j = 4 }; stfld <Foo> (farr, arr); if (farr [0].t.i != 3 || farr [0].t.j != 4) { return(4); } ldflda <Foo> (farr, iarr); if (iarr [0] != 5) { return(5); } return(0); }
public void CheckPartialGeneric() { var g = new GFoo <string>(); g.Values[0] = "hello"; g.Values[1] = "bye"; var g2 = Serializer.Clone(g); Assert.Equal(2, g2.Values.Count); Assert.Equal(g.Values[0], g2.Values[0]); Assert.Equal(g.Values[1], g2.Values[1]); var store = new TokenPrimitiveWriter(); Serializer.Serialize(g, store); var g3 = Serializer.Deserialize <GFoo2 <string> >(new TokenPrimitiveReader(store.TokenStream)); var g3v = (Dictionary <int, string>)g3.Values; Assert.Equal(2, g3v.Count); Assert.Equal(g.Values[0], g3v[0]); Assert.Equal(g.Values[1], g3v[1]); }