public static void ModifyIntCopy(int i) { i++; TestLogger.Log(i); }
static void MoreHappened() { TestLogger.Log("More happened"); }
public void S() { TestLogger.Log("SSimple::S"); }
private static void GenericModifier <T>(T t, Modifier <T> f) { TestLogger.Log(t.ToString()); f(t); TestLogger.Log(t.ToString()); }
public string Instance() { TestLogger.Log("Instance invoked"); return(v.ToString()); }
public static void ModifyStructInPlace(ref Struct s) { s.Modify(); TestLogger.Log(s.ToString()); }
public static void ModifyClassInPlace(ref Class c) { c.Modify(); TestLogger.Log(c.ToString()); }
void IImplicit.M(int i) { TestLogger.Log("BaseImplicit::Implicit.M(int)"); }
void IImplicit.M(bool b) { TestLogger.Log("BaseImplicit::Implicit.M(bool)"); }
public new void S() { TestLogger.Log("CDerived3::S"); }
public void M(SSimple t) { t.S(); TestLogger.Log(t.ToString()); TestLogger.Log(t.GetType().Name); }
public static void Main() { { TestLogger.Log("Testing Void -> Void..."); var a = new A() { i = 3 }; var d = new Test(a.One); d(); } { TestLogger.Log("Testing Void -> Int..."); var a = new A() { i = 3 }; var d = new TestInt(a.OneInt); TestLogger.Log(d()); } { TestLogger.Log("Testing Int -> Int..."); var a = new A() { i = 3 }; var d = new TestIntInt(a.OneIntInt); TestLogger.Log(d(5)); } { TestLogger.Log("Testing Void -> String..."); var a = new A() { i = 3 }; var d = new TestString(a.OneString); TestLogger.Log(d()); } { TestLogger.Log("Testing String -> String..."); var a = new A() { i = 3 }; var d = new TestStringString(a.OneStringString); TestLogger.Log(d("5")); } { TestLogger.Log("Testing String -> String static..."); var d = new TestStringString(A.StaticStringString); TestLogger.Log(d("2")); } { TestLogger.Log("Testing simple delegate hash..."); var a1 = new A() { i = 3 }; var a2 = new A() { i = 5 }; var d1 = new TestStringString(a1.OneStringString); var d2 = new TestStringString(a2.OneStringString); var d3 = new TestString(a1.OneString); // Remember: Hash code for simple delegates is based on delegate type alone TestLogger.Log(d1.GetHashCode() == d1.GetHashCode()); TestLogger.Log(d1.GetHashCode() == d2.GetHashCode()); TestLogger.Log(d1.GetHashCode() != d3.GetHashCode()); } { TestLogger.Log("Testing combined delegates..."); var a1 = new A() { i = 3 }; var a2 = new A() { i = 5 }; var d1 = new TestStringString(a1.OneStringString); var d2 = new TestStringString(a2.OneStringString); var d3 = new TestStringString(a1.TwoStringString); var d4 = new TestStringString(a1.ThreeStringString); var d5 = (TestStringString)Delegate.Combine(d1, d2); var d6 = (TestStringString)Delegate.Combine(d3, d5); var d7 = (TestStringString)Delegate.Combine(d6, d4); TestLogger.Log(d7("7")); TestLogger.Log("Testing combined delegate hash..."); TestLogger.Log(d7.GetHashCode() == d7.GetHashCode()); TestLogger.Log(d7.GetHashCode() != d6.GetHashCode()); TestLogger.Log("Testing removing delegates..."); var d8 = (TestStringString)Delegate.Remove(d7, d5); TestLogger.Log(d8("8")); var d9 = (TestStringString)Delegate.Remove(d7, d2); TestLogger.Log(d9("9")); var d10 = (TestStringString)Delegate.Combine(d3, d2); var d11 = (TestStringString)Delegate.Remove(d7, d10); TestLogger.Log(d11("11")); } { TestLogger.Log("Testing virtual delegate..."); var a = new A() { i = 3 }; var d1 = new TestString(a.Virtual); TestLogger.Log(d1()); var b = (A) new B() { i = 7 }; var d2 = new TestString(b.Virtual); TestLogger.Log(d2()); } { TestLogger.Log("Testing delegate with captured variable..."); var outer = 7; FromTo(1, 3, delegate(int i) { TestLogger.Log(outer); TestLogger.Log(i); return(outer * 4); }); FromTo(1, 3, i => { TestLogger.Log(outer); TestLogger.Log(i); return(outer * 4); }); } { TestLogger.Log("Testing delegate with captured reference variable..."); for (var i = 1; i <= 3; i++) { Prepare(delegate { TestLogger.Log(i); }); } Call(); } { TestLogger.Log("Testing delegate with captured value variable..."); for (var i = 1; i <= 3; i++) { var j = i; Prepare(delegate { TestLogger.Log(j); }); } Call(); } { TestLogger.Log("Testing event registering, triggering and unregestering..."); SomethingHappened += delegate { TestLogger.Log("Something happened."); }; if (SomethingHappened != null) { SomethingHappened(); } SomethingHappened += MoreHappened; if (SomethingHappened != null) { SomethingHappened(); } SomethingHappened -= MoreHappened; if (SomethingHappened != null) { SomethingHappened(); } } { TestLogger.Log("Testing delegates of higher-kinded type over polymorphic methods..."); var polyint = new Poly <int>(3); var polystr = new Poly <string>("four"); StringToString f = polyint.M <string>; TestLogger.Log(f("six")); IntToString g = polyint.M <int>; TestLogger.Log(g(7)); StringToString h = polystr.M <string>; TestLogger.Log(h("eight")); IntToString i = polystr.M <int>; TestLogger.Log(i(9)); } #if false { TestLogger.Log("Testing BeginInvoke/EndInvoke..."); Func <int, int, int> d = (x, y) => { TestLogger.Log("delegate called"); return(x + y); }; AsyncCallback cb = ar2 => { if (ar2.IsCompleted) { TestLogger.Log("completed asyncronously"); } else { TestLogger.Log("not completed asyncronously"); } TestLogger.Log(d.EndInvoke(ar2)); }; TestLogger.Log("invoking"); System.Diagnostics.Debugger.Break(); var ar = d.BeginInvoke(3, 7, cb, null); if (ar.IsCompleted) { TestLogger.Log("completed immediatly"); } else { TestLogger.Log("not completed immediatly"); } if (ar.CompletedSynchronously) { TestLogger.Log("completed syncronously"); TestLogger.Log(d.EndInvoke(ar)); } TestLogger.Log("done"); } #endif }
public static string StaticStringString(string s) { TestLogger.Log("StaticStringString invoked"); return("1" + s); }
protected void Log(string s) { TestLogger.Log(s + " invoked"); TestLogger.Log("i: " + i.ToString()); }
public static void ModifyIntInPlace(ref int i) { i++; TestLogger.Log(i); }
public void M(string s) { TestLogger.Log("BaseImplicit::M(string)"); }
public static void ModifyStructCopy(Struct s) { s.Modify(); TestLogger.Log(s.ToString()); }
public void M(float f) { TestLogger.Log("BaseImplicit::M(float)"); }
public static void ReplaceStructInPlace(ref Struct s) { s = new Struct(42); TestLogger.Log(s.ToString()); }
void IImplicit.M(bool b) { TestLogger.Log("DerivedImplicit::Implicit.M(bool)"); }
public static void ReplaceClassInPlace(ref Class c) { c = new Class(42); TestLogger.Log(c.ToString()); }
public new void M(string s) { TestLogger.Log("DerivedImplicit::M(string)"); }
private static void GenericCallToGenericModifier <T>(T t, Modifier <T> f) { TestLogger.Log(t.ToString()); GenericModifier <T>(t, f); TestLogger.Log(t.ToString()); }
static void Main() { { TestLogger.Log("Testing basic interface methods..."); ISimple s1 = new CSimple(); s1.S(); ISimple s2 = new SSimple(); s2.S(); ISimple s3 = new CDerived1(); s3.S(); ISimple s4 = new CDerived2(); s4.S(); ISimple s5 = new CDerived3(); s5.S(); } { TestLogger.Log("Testing virtuals..."); object c = new CChild(); var ia = c as IA; var d = c as Dummy; if (d != null) { TestLogger.Log("Invalid casting"); } TestLogger.Log(5.ToString()); TestLogger.Log(ia.A()); TestLogger.Log(((CA)c).Virtual()); TestLogger.Log(((CChild)c).VirtualDontOverride()); TestLogger.Log(((IB)c).A()); TestLogger.Log(((IAB)c).B()); TestLogger.Log((new CGrandChild()).Virtual()); // TestLogger.Log(((IAB)c).A()); // ambiguous at compile-time } { TestLogger.Log("Testing constrained call on 'naked' type parameter..."); var cic = new ConstrainedInterface <CSimple>(); cic.M(new CSimple()); var cis = new ConstrainedInterface <SSimple>(); cis.M(new SSimple()); var cc = new ConstrainedClass <CSimple>(); cc.M(new CSimple()); var cs = new ConstrainedStruct <SSimple>(); cs.M(new SSimple()); var kc = new KnownClass(); kc.M(new CSimple()); var ks = new KnownStruct(); ks.M(new SSimple()); } { TestLogger.Log("Testing implicit interface implementations..."); var b = new BaseImplicit(); var d = new DerivedImplicit(); ((IImplicit)b).M(1); ((IImplicit)b).M(false); ((IImplicit)b).M("three"); ((IImplicit)b).M(4.0f); ((IImplicit)d).M(2); ((IImplicit)d).M(true); ((IImplicit)d).M("five"); ((IImplicit)d).M(6.0f); } }
public static void Main() { { var i = 3; var o = (object)i; var o2 = (object)7; TestLogger.Log("Testing instance methods on unboxed int..."); TestLogger.Log(i + 9); TestLogger.Log(Math.Max(i, 9)); TestLogger.Log((int)i.GetTypeCode()); TestLogger.Log("Testing virtual method on unboxed int..."); TestLogger.Log(i.ToString()); TestLogger.Log("Testing virtual method on boxed int..."); TestLogger.Log(o.ToString()); TestLogger.Log("Testing interface call on unboxed int..."); TestLogger.Log(i.CompareTo(o)); TestLogger.Log(i.CompareTo(o2)); } { TestLogger.Log("Testing boxing of value field..."); var s = new Struct(5); var o = (object)s.v; TestLogger.Log(o.ToString()); TestLogger.Log("Testing boxing of value element..."); var a = new int[3] { 1, 2, 3 }; var o2 = (object)a[1]; TestLogger.Log(o2.ToString()); } { var s = new Struct(3); var o = (object)s; var o2 = (object)new Struct(7); TestLogger.Log("Testing instance methods on unboxed struct..."); TestLogger.Log(s.Instance()); TestLogger.Log("Testing virtual method on unboxed struct..."); TestLogger.Log(s.ToString()); TestLogger.Log("Testing virtual method on boxed struct..."); TestLogger.Log(o.ToString()); TestLogger.Log("Testing interface call on unboxed struct..."); TestLogger.Log(s.CompareTo(o)); TestLogger.Log(s.CompareTo(o2)); } { var c = new Class(3); var o = (object)c; var o2 = (object)new Class(7); TestLogger.Log("Testing instance methods on class..."); TestLogger.Log(c.Instance()); TestLogger.Log("Testing virtual method on class..."); TestLogger.Log(c.ToString()); TestLogger.Log("Testing virtual method on cast class..."); TestLogger.Log(o.ToString()); TestLogger.Log("Testing interface call on class..."); TestLogger.Log(c.CompareTo(o)); TestLogger.Log(c.CompareTo(o2)); } { var i = 3; TestLogger.Log("Testing passing int by value..."); TestLogger.Log(i); ModifyIntCopy(i); TestLogger.Log(i); TestLogger.Log("Testing passing int by ref..."); ModifyIntInPlace(ref i); TestLogger.Log(i); } { var s = new Struct(3); TestLogger.Log("Testing modifying struct in place..."); TestLogger.Log(s.ToString()); s.Modify(); TestLogger.Log(s.ToString()); TestLogger.Log("Testing passing struct by value..."); ModifyStructCopy(s); TestLogger.Log(s.ToString()); TestLogger.Log("Testing passing struct by boxed value..."); ModifyStructBoxed(s); TestLogger.Log(s.ToString()); TestLogger.Log("Testing passing struct by ref value..."); ModifyStructInPlace(ref s); TestLogger.Log(s.ToString()); TestLogger.Log("Testing replacing struct in place..."); ReplaceStructInPlace(ref s); TestLogger.Log(s.ToString()); } { var c = new Class(3); TestLogger.Log("Testing modifying class in place..."); TestLogger.Log(c.ToString()); c.Modify(); TestLogger.Log(c.ToString()); TestLogger.Log("Testing passing class..."); ModifyClass(c); TestLogger.Log(c.ToString()); TestLogger.Log("Testing passing class as object..."); ModifyClassAsObject(c); TestLogger.Log(c.ToString()); TestLogger.Log("Testing passing class by ref value..."); ModifyClassInPlace(ref c); TestLogger.Log(c.ToString()); TestLogger.Log("Testing replacing class in place..."); ReplaceClassInPlace(ref c); TestLogger.Log(c.ToString()); } { var s = new Struct(3); TestLogger.Log("Testing static field..."); f = s; f.Modify(); TestLogger.Log(s.ToString()); TestLogger.Log(f.ToString()); } { var s = new Struct(3); TestLogger.Log("Testing returning self..."); var self = s.ReturnSelf(); self.Modify(); TestLogger.Log(self.ToString()); TestLogger.Log(s.ToString()); } { TestLogger.Log("Testing wrapping..."); var w = new WrappedStruct(new Struct(5)); TestLogger.Log(w.ToString()); } { TestLogger.Log("Testing generic struct of ref type..."); var g = new GenericStruct <string>(); g.v = "a"; TestLogger.Log(g.v); Call(g, "b"); TestLogger.Log(g.v); } { TestLogger.Log("Testing generic struct of struct..."); var g = new GenericStruct <Struct>(); g.v = new Struct(1); TestLogger.Log(g.v.ToString()); g.v.Modify(); TestLogger.Log(g.v.ToString()); Call(g, new Struct(9)); TestLogger.Log(g.v.ToString()); } { TestLogger.Log("Testing generic method on struct..."); var arr = new Struct[2] { new Struct(1), new Struct(3) }; GenericMethod.TestLoop(arr); } { TestLogger.Log("Testing generic method on ref type..."); var arr = new Class[2] { new Class(1), new Class(3) }; GenericMethod.TestLoop(arr); } { TestLogger.Log("Testing generic boxing..."); var i = 3; GenericBoxer(i); var str = "test"; GenericBoxer(str); var s = new GenericStruct <int>() { v = 7 }; GenericBoxer(s); var c = new GenericClass <int>() { v = 9 }; GenericBoxer(c); } { TestLogger.Log("Testing generic return..."); var i = 3; var i2 = GenericCopier(i, a => a + 1); TestLogger.Log(i2.ToString()); var str = "test"; var str2 = GenericCopier(str, a => a + "done"); TestLogger.Log(str2.ToString()); var s = new GenericStruct <int>() { v = 7 }; var s2 = GenericCopier(s, a => new GenericStruct <int>() { v = a.v + 1 }); TestLogger.Log(s2.ToString()); var c = new GenericClass <int>() { v = 9 }; var c2 = GenericCopier(c, a => new GenericClass <int>() { v = a.v + 1 }); TestLogger.Log(c2.ToString()); } { TestLogger.Log("Testing generic modification..."); var i = 3; GenericModifier(i, a => a++); TestLogger.Log(i.ToString()); var str = "test"; GenericModifier(str, a => a = "done"); TestLogger.Log(str.ToString()); var s = new GenericStruct <int>() { v = 7 }; GenericModifier(s, a => a.v++); TestLogger.Log(s.ToString()); GenericCallToGenericModifier(s, a => a.v++); TestLogger.Log(s.ToString()); var c = new GenericClass <int>() { v = 9 }; GenericModifier(c, a => a.v++); TestLogger.Log(c.ToString()); GenericCallToGenericModifier(c, a => a.v++); TestLogger.Log(c.ToString()); } { TestLogger.Log("Testing stack non-interferance..."); var a = 3; var b = 7; var c = 10; var x = true; var y = true; TestLogger.Log(String.Format("a = {0}, b = {1}, c = {2}", a, b, c)); TestLogger.Log(AddArgs(a, x ? a++ : b++, y ? a++ : c++).ToString()); TestLogger.Log(String.Format("a = {0}, b = {1}, c = {2}", a, b, c)); } { TestLogger.Log("Testing integer equalities..."); var one = 1; var a = 1; var two = 2; TestLogger.Log(one.Equals(one)); TestLogger.Log(one.Equals(a)); TestLogger.Log(one.Equals(two)); TestLogger.Log(a.Equals(one)); TestLogger.Log(two.Equals(one)); var boxedOne = (object)one; var boxedA = (object)a; var boxedTwo = (object)two; TestLogger.Log("Testing boxed integer equalities..."); TestLogger.Log(boxedOne.Equals(boxedOne)); TestLogger.Log(boxedOne.Equals(boxedA)); TestLogger.Log(boxedOne.Equals(boxedTwo)); TestLogger.Log(boxedA.Equals(boxedOne)); TestLogger.Log(boxedTwo.Equals(boxedOne)); TestLogger.Log("Testing reference equalities..."); var five = new Class(5); Class six = new Class(6); Class fiveAsWell = new Class(5); Class sixAsWell = six; TestLogger.Log(five.Equals(five)); TestLogger.Log(five.Equals(six)); TestLogger.Log(five.Equals(fiveAsWell)); TestLogger.Log(six.Equals(sixAsWell)); TestLogger.Log(six.Equals(five)); TestLogger.Log(fiveAsWell.Equals(five)); TestLogger.Log(sixAsWell.Equals(six)); } }
private static void Run() { { TestLogger.Log("Testing basic interop..."); var fso = new FileSystemObject(); var drive1 = fso.GetDrive("C:"); var drive2 = fso.GetDrive("C:"); TestLogger.Log(drive1.FreeSpace == drive2.FreeSpace); } { TestLogger.Log("Tesing getters..."); var prop = new PropertyTest(); prop.Setup(); TestLogger.Log(prop.X); } { TestLogger.Log("Testing virtuals..."); var b = new VirtualsBase(); TestLogger.Log(b.V()); TestLogger.Log(b.CallV()); TestLogger.Log(b.U()); var d = (VirtualsBase) new VirtualsDerived(); TestLogger.Log(d.V()); TestLogger.Log(d.CallV()); TestLogger.Log(d.U()); } { TestLogger.Log("Testing JSObject..."); var obj = new JSObject { { "int", 1 }, { "string", "two" }, { "object", new JSObject { { "inner", 3 }, { "null", null } } } }; TestLogger.Log(obj.GetField <int>("int")); TestLogger.Log(obj.GetField <string>("string")); TestLogger.Log(obj.GetField <JSObject>("object").GetField <int>("inner")); } { TestLogger.Log("Testing exceptions..."); var obj = new JSObject { { "int", 1 }, { "string", "two" } }; try { // Invalid cast var dummy = obj.GetField <int[]>("int"); TestLogger.Log(dummy.ToString()); } catch (Exception e) { TestLogger.LogException(e); } try { // User exception TestException.ThrowFromUnmanaged(); } catch (Exception e) { TestLogger.LogException(e); } // Managed -> unmanaged exception TestException.CatchFromManagedInUnmanaged(); try { // Managed -> unmanaged -> managed exception TestException.ThrowViaUnmanaged(); } catch (Exception e) { TestLogger.LogException(e); } // Unmanaged -> managed -> unmanaged -> catch TestException.CatchViaManagedInUnmanaged(); try { // Unmanaged exception TestException.InvalidJavaScript(); } catch (Exception e) { TestLogger.LogException(e); } } { TestLogger.Log("Testing JSArray..."); var arr = JSArray.FromArray(0, 1, "two", new JSObject { { "value", 3 } }, new JSObject { { "value", "four" } }); TestLogger.Log(arr.Length); TestLogger.Log(arr[0].ToString()); TestLogger.Log(arr[1].ToString()); TestLogger.Log(arr[2].ToString()); TestLogger.Log(arr[3].GetField <int>("value")); TestLogger.Log(arr[4].GetField <string>("value")); } { TestLogger.Log("Testing polymorphic method of higher-kinded type..."); var t1 = new TestGeneric <int>(1); TestLogger.Log(t1.M <string>("two")); var obj = new JSObject(); obj.SetField("f", "field"); var t2 = new TestGeneric <JSObject>(obj); TestLogger.Log(t2.M <int>(3)); TestLogger.Log(t2.M <JSObject>(obj)); } { TestLogger.Log("Testing exported instance methods in base types..."); var d = new TestGenericDerived <int>(); d.Value = new int[] { 1, 2, 3 }; d.OtherValue = 4; TestLogger.Log(d.N()); } { TestLogger.Log("Testing delegates..."); TestLogger.Log(TestDelegate.TestWithDelegate()); TestLogger.Log (TestDelegate.WithManagedDelegate ((i, obj) => new JSObject { { "test", i.ToString() + " " + obj.GetField <int>("test").ToString() } }, new JSObject { { "test", 7 } })); } { TestLogger.Log("Testing param arrays..."); TestLogger.Log(TestParams.JoinA(3, 7, "a", "b", "c")); TestLogger.Log(TestParams.TestB()); ParamsDelegate f = TestParams.JoinA; TestLogger.Log(TestParams.Call(f)); var g = TestParams.GetTestB(); TestLogger.Log(g(3, 7, "a", "b", "c")); } { TestLogger.Log("Testing proxied object..."); var p = new ProxiedTest(); TestLogger.Log(ProxiedBase.TestGlobal); TestLogger.Log(p.One); TestLogger.Log(p.Two); TestLogger.Log(p.Three.GetField <int>("value")); TestLogger.Log(p.GetValue()); p.One = 11; p.Two = "twenty-two"; p.Three = new JSObject { { "value", 55 } }; #if true // BROKEN: Polymorphic delegates p.Delegate = i => TestLogger.Log(i); #endif TestLogger.Log(p.One); TestLogger.Log(p.Two); TestLogger.Log(p.Three.GetField <int>("value")); #if true // BROKEN: Polymorphic delegates p.Delegate(7); #endif TestLogger.Log(p.GetValue()); p.Morph(); // TODO: Managed Interop will not notice '2' is an int rather than a string #if false try { TestLogger.Log(p.Two); } catch (InvalidCastException e) { TestLogger.LogException(e); } #endif var obj = JSObject.From(p); TestLogger.Log(obj.GetField <int>("two")); obj.SetField <int>("one", 111); TestLogger.Log(p.One); p.One = 1111; TestLogger.Log(obj.GetField <int>("one")); } { TestLogger.Log("Testing keyed object..."); var k = new KeyedTest(1, "two", 3, "four"); TestLogger.Log(k.I); TestLogger.Log(k.S); TestLogger.Log(k.X); TestLogger.Log(k.Y); k.I = 11; k.X = 33; TestLogger.Log(k.I); TestLogger.Log(k.X); var k2 = k.Clone(); TestLogger.Log(k2.I); TestLogger.Log(k2.X); k.I = 111; k.X = 333; TestLogger.Log(k2.I); TestLogger.Log(k2.X); var k3 = k.PassThrough(); TestLogger.Log(k3.I); TestLogger.Log(k3.X); k3.I = 1111; k3.X = 3333; TestLogger.Log(k.I); TestLogger.Log(k.X); k.Morph(); try { TestLogger.Log(k.X); } catch (Exception e) { TestLogger.LogException(e); } var obj = JSObject.From(k); TestLogger.Log(obj.GetField <string>("x")); obj.SetField <int>("x", 1); TestLogger.Log(k.X); } { TestLogger.Log("Testing nullable..."); var ni = new int?(3); TestLogger.Log(ni.Value); ni = NullableTest.Incr(ni); TestLogger.Log(ni.Value); var ni2 = default(int?); TestLogger.Log(ni2.HasValue); ni2 = NullableTest.Incr(ni2); TestLogger.Log(ni2.HasValue); } { TestLogger.Log("Testing primitive arrays..."); var arr = new int[] { 0, 1, 2, 3, 4, 5 }; var arr2 = TestArray.WithArray(arr); TestLogger.Log(arr[3]); TestLogger.Log(arr2.Length); TestLogger.Log(arr2[3]); } { TestLogger.Log("Testing normal object..."); { var l = "left"; var r = new Normal { I = 7, S = "nine" }; var o = TestNormal.Right(l, r); var r2 = (Normal)o; TestLogger.Log(r2.I); TestLogger.Log(r2.S); } { var l = new Normal { I = 7, S = "nine" }; var r = "right"; var o = TestNormal.Right(l, r); var r2 = (string)o; TestLogger.Log(r2); } { var l = "left"; var r = 2; var o = TestNormal.Right(l, r); var r2 = (int)o; TestLogger.Log(r2); } { var l = new KeyedTest(1, "two", 3, "four"); var r = new ProxiedTest(); try { var o = TestNormal.Right(l, r); var r2 = (ProxiedTest)o; TestLogger.Log(r2.One); } catch (Exception e) { TestLogger.LogException(e); } } } { TestLogger.Log("Testing default instances bug..."); var t = new TestDefaultInstance(); TestLogger.Log(t.X.ToString()); t.X = 3; TestLogger.Log(t.X.ToString()); } TestLogger.Log("Done."); }