public void InterfaceProxyGetTypeOkay() { // Regression test for #17325 // Check that GetType () for a proxy of an interface // returns the interface. var prox = new ExampleInterfaceProxy(); var tprox = prox.GetTransparentProxy(); Assert.IsNotNull(tprox, "#1"); var tproxType = tprox.GetType(); Assert.IsFalse(prox.Called, "#2"); // this is true on .NET Framework, but false on Mono. Assert.IsNotNull(tproxType, "#3"); Assert.IsTrue(tproxType.IsAssignableFrom(typeof(IComparable)), "#4"); }
public void InterfaceProxyGetTypeViaReflectionOkay() { // Regression test for #17325 // Check that GetType () for a proxy of an interface // returns the interface. // // This versions calls GetType using reflection, which // avoids the fast path in the JIT. var prox = new ExampleInterfaceProxy(); var tprox = prox.GetTransparentProxy(); Assert.IsNotNull(tprox, "#1"); var m = typeof(object).GetMethod("GetType"); var tproxType = m.Invoke(tprox, null); Assert.IsTrue(prox.Called, "#2"); Assert.IsNotNull(tproxType, "#3"); Assert.IsTrue(tproxType is Type, "#4"); Assert.IsTrue((tproxType as Type).IsAssignableFrom(typeof(IComparable)), "#5"); }