[Mono-bugs] [Bug 33183][Nor] Changed - GetHashCode artifacts.

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
2 Nov 2002 18:15:54 -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 miguel@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=33183

--- shadow/33183	Sat Nov  2 13:09:28 2002
+++ shadow/33183.tmp.29901	Sat Nov  2 13:15:54 2002
@@ -43,6 +43,54 @@
 ------- Additional Comments From miguel@ximian.com  2002-11-02 13:09 -------
 <dietmar> who defines whats correct? 
 <dietmar> MS? 
 <dietmar> we just need to delete the String GetHashCode implementation 
 <dietmar> to get the MS behaviour 
 
+
+------- Additional Comments From miguel@ximian.com  2002-11-02 13:15 -------
+> Ok, lemme add those comments ;)
+> But shouldnt they all end up calling the String GetHashCode
+implementation?
+<dietmar> you are right 
+> ie, the problem will happen with different objects
+<dietmar> strange, 
+<dietmar> typeof(object).GetMethod("GetHashCode") 
+<dietmar> typeof(string).GetMethod("GetHashCode") 
+<dietmar> i thougth these are different methods? 
+*** You have new email.
+> Mhm
+<dietmar> or does this denote the same virtual function? 
+> Wow, that is a very good question
+> Like, the compiler uses a feature similar to that for implementing
+"base" calls
+<dietmar> type.method is a specific method IMO 
+> yeah, lemme do a little experiment
+> Yep, so with a different class we get:
+> 1
+> 653047312
+> 1
+> i think our behavior is right, and the MS runtime only removed the
+GetHashCode implementation from string
+
+Here is the new sample program:
+
+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));	
+	}
+}
+
+class Y {
+	public override int GetHashCode ()
+	{
+		return 1;
+	}
+	
+}
+