static void TestMovedGenericVirtualMethod() { var o = new MyChildGeneric <Object>(); Assert.AreEqual(o.MovedToBaseClass <WeakReference>(), typeof(List <WeakReference>).ToString()); Assert.AreEqual(o.ChangedToVirtual <WeakReference>(), typeof(List <WeakReference>).ToString()); if (!LLILCJitEnabled) { o = null; try { o.MovedToBaseClass <WeakReference>(); } catch (NullReferenceException) { try { o.ChangedToVirtual <WeakReference>(); } catch (NullReferenceException) { return; } } Assert.AreEqual("NullReferenceException", "thrown"); } }
static void TestMovedGenericVirtualMethod() { var o = new MyChildGeneric <Object>(); Assert.AreEqual(o.MovedToBaseClass <WeakReference>(), typeof(List <WeakReference>).ToString()); Assert.AreEqual(o.ChangedToVirtual <WeakReference>(), typeof(List <WeakReference>).ToString()); }
static void TestGenericOverStruct() { var o1 = new MyGeneric <String, MyGrowingStruct>(); Assert.AreEqual(o1.GenericVirtualMethod <MyChangingStruct, IEnumerable <Program> >(), "System.StringMyGrowingStructMyChangingStructSystem.Collections.Generic.IEnumerable`1[Program]"); var o2 = new MyChildGeneric <MyChangingStruct>(); Assert.AreEqual(o2.MovedToBaseClass <MyGrowingStruct>(), typeof(List <MyGrowingStruct>).ToString()); Assert.AreEqual(o2.ChangedToVirtual <MyGrowingStruct>(), typeof(List <MyGrowingStruct>).ToString()); }
static void TestMovedGenericVirtualMethodOnNullReference() { MyChildGeneric <Object> o = null; try { o.MovedToBaseClass <WeakReference>(); } catch (NullReferenceException) { try { o.ChangedToVirtual <WeakReference>(); } catch (NullReferenceException) { return; } } Assert.AreEqual("NullReferenceException", "thrown"); }
static void TestMovedGenericVirtualMethod() { var o = new MyChildGeneric<Object>(); Assert.AreEqual(o.MovedToBaseClass<WeakReference>(), typeof(List<WeakReference>).ToString()); Assert.AreEqual(o.ChangedToVirtual<WeakReference>(), typeof(List<WeakReference>).ToString()); o = null; try { o.MovedToBaseClass<WeakReference>(); } catch (NullReferenceException) { try { o.ChangedToVirtual<WeakReference>(); } catch (NullReferenceException) { return; } } Assert.AreEqual("NullReferenceException", "thrown"); }