Browse Source

Fix stack overflow on equality operators

git-svn-id: https://mono-soc-2010.googlecode.com/svn/trunk/cppinterop@118 a470b8cb-0e6f-1642-1b45-71e107334c4b
pull/1/head
shana.ufie@gmail.com 15 years ago
parent
commit
8e4d95df5f
  1. 15
      Mono.VisualC.Interop/CppModifiers.cs

15
Mono.VisualC.Interop/CppModifiers.cs

@ -47,10 +47,7 @@ namespace Mono.VisualC.Interop {
public override bool Equals (object obj) public override bool Equals (object obj)
{ {
if (obj == null) return this == obj as CppModifiers;
return false;
return GetType ().Equals (obj.GetType ());
} }
public override int GetHashCode () public override int GetHashCode ()
{ {
@ -59,13 +56,13 @@ namespace Mono.VisualC.Interop {
public static bool operator == (CppModifiers a, CppModifiers b) public static bool operator == (CppModifiers a, CppModifiers b)
{ {
if (a != null && b != null) if ((object)a == (object)b)
return a.Equals (b);
if (a == null && b == null)
return true; return true;
return false; if ((object)a == null || (object)b == null)
return false;
return a.GetHashCode () == b.GetHashCode ();
} }
public static bool operator != (CppModifiers a, CppModifiers b) public static bool operator != (CppModifiers a, CppModifiers b)
{ {

Loading…
Cancel
Save