[Mono-bugs] [Bug 74933][Blo] New - IsInstanceOf failure (?)
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Fri, 13 May 2005 05:21:09 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by michael@ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=74933
--- shadow/74933 2005-05-13 05:21:08.000000000 -0400
+++ shadow/74933.tmp.14018 2005-05-13 05:21:09.000000000 -0400
@@ -0,0 +1,105 @@
+Bug#: 74933
+Product: Mono: Runtime
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Blocker
+Component: misc
+AssignedTo: martin@ximian.com
+ReportedBy: michael@ximian.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: IsInstanceOf failure (?)
+
+So - this bug is quite curious - and it's possible that this is a
+regression - certainly something like this stopped working from 1.1.5 to
+HEAD. Anyhow:
+
+I have an object which is of type:
+
+public unsafe class UnoInterfaceProxy: RealProxy, IRemotingTypeInfo
+{
+...
+}
+
+It is proxying an object implementing the 'XEventListener' interface:
+
+ .class interface public auto ansi abstract XEventListener
+ {
+
+ // method line 91
+ .method public virtual hidebysig newslot abstract
+ instance default void disposing ([in] class
+unoidl.com.sun.star.lang.EventObject Source) cil managed
+ {
+ // Method begins at RVA 0x0
+ } // end of method XEventListener::instance default void disposing
+([in] class unoidl.com.sun.star.lang.EventObject Source)
+
+ } // end of class unoidl.com.sun.star.lang.XEventListener
+}
+
+ie. it's some newfangled remoting object thing;
+
+I then have this code - which I run post-instantiation of this object:
+
+if (typeof(XEventListener).IsInstanceOfType(result) && result != null)
+{
+ Type t = result.GetType();
+ System.Console.WriteLine( "FOO: Is Event Listener " + result.ToString() +
+" type: " + t );
+ if (!t.IsAssignableFrom (typeof(XEventListener)))
+ System.Console.WriteLine( "FOO: Serious brokenness" );
+ else
+ System.Console.WriteLine( "FOO: assignment fine" );
+ if (typeof(XEventListener).IsAssignableFrom (t))
+ System.Console.WriteLine( "FOO: 2nd serious brokenness" );
+ else
+ System.Console.WriteLine( "FOO: reverse assignment fine" );
+}
+else
+ System.Console.WriteLine( "FOO: Is NOT Event Listener" );
+}
+
+So - the output I get from this fragment of code:
+
+FOO: Is Event Listener Uno object proxy. OID:
+4112ef80;gcc3[0];759ebb91c38d11d9bdd7fdd792f2e7fa type:
+System.MarshalByRefObject
+FOO: Serious brokenness
+FOO: reverse assignment fine
+
+ie. tracing it through:
+
+'result' IsInstanceOfType XEventListener
+'result.GetType' == 'System.MarshalByRefObject'
+however: 'System.MarshalByRefObject' IsAssignableFrom (XEventListener) is
+not (always) true - although, it clearly is for this instance.
+
+I'm guessing this is because System.MarshalByRefObject is some clever
+wrapping proxy that can wrap any number of other types.
+
+So far so good; the problem of course is; that in:
+
+System.Reflection/Binder.cs (ChangeType) we have this code:
+
+ if (value == null)
+ return null;
+ Type vtype = value.GetType ();
+ if (type.IsByRef)
+ type = type.GetElementType ();
+******* if (vtype == type || type.IsAssignableFrom (vtype))
+ return value;
+
+Which _I assume_ is the problem; of course - the more advanced checks below
+may be the issue - but ...
+The problem here is that we try to see if it is assignable, but we do a
+generic type comparison - (not always true) - instead of a per instance
+comparison.
+
+At least - that's my guess so far ;-)