2008-07-22 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / support.cs
index 2adfc9ca4ca41cb5c0111eb88a2ff60dc3243675..d70fddb234ffb7e9a3c7b0a01a5ae5db21935c45 100644 (file)
@@ -5,7 +5,8 @@
 // Author:
 //   Miguel de Icaza (miguel@ximian.com)
 //
-// (C) 2001 Ximian, Inc (http://www.ximian.com)
+// Copyright 2001 Ximian, Inc (http://www.ximian.com)
+// Copyright 2003-2008 Novell, Inc
 //
 
 using System;
@@ -349,6 +350,20 @@ namespace Mono.CSharp {
                {
                        comparer = PtrComparer.Instance;
                }
+
+#if MS_COMPATIBLE
+               //
+               // Workaround System.InvalidOperationException for enums
+               //
+               protected override int GetHash (object key)
+               {
+                       TypeBuilder tb = key as TypeBuilder;
+                       if (tb != null && tb.BaseType == TypeManager.enum_type)
+                               key = tb.BaseType;
+
+                       return base.GetHash (key);
+               }
+#endif
        }
 
        /*