Make TypeNameParser consistently use tabs
[mono-project.git] / netcore / System.Private.CoreLib / src / System / ValueType.cs
blob86c86625a6e5dfff7b9d502d9f769035bcac4e38
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 using System.Reflection;
6 using System.Runtime.CompilerServices;
8 namespace System
10 [Serializable]
11 [System.Runtime.CompilerServices.TypeForwardedFrom ("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
12 public abstract class ValueType
14 // This is also used by RuntimeHelpers
15 internal static bool DefaultEquals (object o1, object o2)
17 RuntimeType o1_type = (RuntimeType) o1.GetType ();
18 RuntimeType o2_type = (RuntimeType) o2.GetType ();
20 if (o1_type != o2_type)
21 return false;
23 object[] fields;
24 bool res = InternalEquals (o1, o2, out fields);
25 if (fields == null)
26 return res;
28 for (int i = 0; i < fields.Length; i += 2) {
29 object meVal = fields [i];
30 object youVal = fields [i + 1];
31 if (meVal == null) {
32 if (youVal == null)
33 continue;
35 return false;
38 if (!meVal.Equals (youVal))
39 return false;
42 return true;
45 public override bool Equals (object? obj)
47 if (obj == null)
48 return false;
50 return DefaultEquals (this, obj);
53 public override int GetHashCode ()
55 int result = InternalGetHashCode (this, out var fields);
57 if (fields != null)
58 for (int i = 0; i < fields.Length; ++i)
59 if (fields [i] != null)
60 result ^= fields [i].GetHashCode ();
62 return result;
65 public override string ToString ()
67 return GetType ().ToString ();
71 [MethodImplAttribute (MethodImplOptions.InternalCall)]
72 extern static int InternalGetHashCode (object o, out object[]? fields);
74 [MethodImplAttribute (MethodImplOptions.InternalCall)]
75 extern static bool InternalEquals (object o1, object o2, out object[] fields);