[Mono-bugs] [Bug 33183][Nor] Changed - GetHashCode artifacts.
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
3 Nov 2002 14:42:28 -0000
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 lupus@ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=33183
--- shadow/33183 Sat Nov 2 13:15:54 2002
+++ shadow/33183.tmp.20008 Sun Nov 3 09:42:28 2002
@@ -1,13 +1,13 @@
Bug#: 33183
Product: Mono/Runtime
Version: unspecified
OS: other
OS Details:
-Status: NEW
-Resolution:
+Status: RESOLVED
+Resolution: FIXED
Severity: Unknown
Priority: Normal
Component: misc
AssignedTo: mono-bugs@ximian.com
ReportedBy: miguel@ximian.com
QAContact: mono-bugs@ximian.com
@@ -87,10 +87,55 @@
}
class Y {
public override int GetHashCode ()
{
return 1;
+ }
+
+}
+
+
+------- Additional Comments From lupus@ximian.com 2002-11-03 09:42 -------
+You can't simply remove the GetHashCode() from string (and that's not
+what MS did for sure) or you'd get a lot of failures.
+The issue is: Invoke() on MethodInfo is supposed to always do a
+virtual call (yes, the API is stupid) and this has nothing to do with
+GetHashCode per se.
+Our implementation of Invoke() always calls the passed-in method,
+because that is the reasonable thing to do.
+I changed Invoke() to do a virtual call like the MS runtime does.
+They have the bug in 1.0 because they most likely special cased the
+virtual methods in the object class (if you introduce a new virtual
+method, Invoke() behaves as documented).
+Try this, for example:
+
+using System;
+class X {
+ static void Main ()
+ {
+ object o = new Y ();
+ Console.WriteLine(o.GetHashCode());
+ Console.WriteLine(typeof(object).GetMethod("GetHashCode").Invoke(o,
+null));
+ Console.WriteLine(typeof(Y).GetMethod("GetHashCode").Invoke(o, null));
+ Console.WriteLine("X.stuff(): {0}",
+typeof(X).GetMethod("stuff").Invoke(o, null));
+ Console.WriteLine("Y.stuff(): {0}",
+typeof(Y).GetMethod("stuff").Invoke(o, null));
+ }
+ public virtual string stuff () {
+ return "In X";
+ }
+}
+
+class Y : X {
+ public override int GetHashCode ()
+ {
+ return 1;
+ }
+ public override string stuff () {
+ return "In Y";
}
}