Removes the code moved to shared partition
authorMarek Safar <marek.safar@gmail.com>
Thu, 3 Jan 2019 10:51:17 +0000 (11:51 +0100)
committerJan Kotas <jkotas@microsoft.com>
Thu, 3 Jan 2019 17:19:04 +0000 (07:19 -1000)
src/System.Private.CoreLib/src/System/Attribute.cs

index f1224c2..94143f7 100644 (file)
@@ -4,7 +4,6 @@
 
 
 
-using System;
 using System.Reflection;
 using System.Collections.Generic;
 using System.Runtime.InteropServices;
@@ -14,10 +13,7 @@ using System.Security;
 
 namespace System
 {
-    [Serializable]
-    [AttributeUsageAttribute(AttributeTargets.All, Inherited = true, AllowMultiple = false)]
-    [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
-    public abstract class Attribute
+    public abstract partial class Attribute
     {
         #region Private Statics
 
@@ -808,137 +804,5 @@ namespace System
         #endregion
 
         #endregion
-
-        #region Constructor
-        protected Attribute() { }
-        #endregion
-
-        #region Object Overrides
-        public override bool Equals(object obj)
-        {
-            if (obj == null)
-                return false;
-
-            Type thisType = this.GetType();
-            Type thatType = obj.GetType();
-
-            if (thatType != thisType)
-                return false;
-
-            object thisObj = this;
-            object thisResult, thatResult;
-
-            while (thisType != typeof(Attribute))
-            {
-                FieldInfo[] thisFields = thisType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
-
-                for (int i = 0; i < thisFields.Length; i++)
-                {
-                    // Visibility check and consistency check are not necessary.
-                    thisResult = ((RtFieldInfo)thisFields[i]).UnsafeGetValue(thisObj);
-                    thatResult = ((RtFieldInfo)thisFields[i]).UnsafeGetValue(obj);
-
-                    if (!AreFieldValuesEqual(thisResult, thatResult))
-                    {
-                        return false;
-                    }
-                }
-                thisType = thisType.BaseType;
-            }
-
-            return true;
-        }
-
-        // Compares values of custom-attribute fields.    
-        private static bool AreFieldValuesEqual(object thisValue, object thatValue)
-        {
-            if (thisValue == null && thatValue == null)
-                return true;
-            if (thisValue == null || thatValue == null)
-                return false;
-
-            if (thisValue.GetType().IsArray)
-            {
-                // Ensure both are arrays of the same type.
-                if (!thisValue.GetType().Equals(thatValue.GetType()))
-                {
-                    return false;
-                }
-
-                Array thisValueArray = thisValue as Array;
-                Array thatValueArray = thatValue as Array;
-                if (thisValueArray.Length != thatValueArray.Length)
-                {
-                    return false;
-                }
-
-                // Attributes can only contain single-dimension arrays, so we don't need to worry about 
-                // multidimensional arrays.
-                Debug.Assert(thisValueArray.Rank == 1 && thatValueArray.Rank == 1);
-                for (int j = 0; j < thisValueArray.Length; j++)
-                {
-                    if (!AreFieldValuesEqual(thisValueArray.GetValue(j), thatValueArray.GetValue(j)))
-                    {
-                        return false;
-                    }
-                }
-            }
-            else
-            {
-                // An object of type Attribute will cause a stack overflow. 
-                // However, this should never happen because custom attributes cannot contain values other than
-                // constants, single-dimensional arrays and typeof expressions.
-                Debug.Assert(!(thisValue is Attribute));
-                if (!thisValue.Equals(thatValue))
-                    return false;
-            }
-
-            return true;
-        }
-
-        public override int GetHashCode()
-        {
-            Type type = GetType();
-
-            while (type != typeof(Attribute))
-            {
-                FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
-                object vThis = null;
-
-                for (int i = 0; i < fields.Length; i++)
-                {
-                    // Visibility check and consistency check are not necessary.
-                    object fieldValue = ((RtFieldInfo)fields[i]).UnsafeGetValue(this);
-
-                    // The hashcode of an array ignores the contents of the array, so it can produce 
-                    // different hashcodes for arrays with the same contents.
-                    // Since we do deep comparisons of arrays in Equals(), this means Equals and GetHashCode will
-                    // be inconsistent for arrays. Therefore, we ignore hashes of arrays.
-                    if (fieldValue != null && !fieldValue.GetType().IsArray)
-                        vThis = fieldValue;
-
-                    if (vThis != null)
-                        break;
-                }
-
-                if (vThis != null)
-                    return vThis.GetHashCode();
-
-                type = type.BaseType;
-            }
-
-            return type.GetHashCode();
-        }
-        #endregion
-
-        #region Public Virtual Members
-        public virtual object TypeId { get { return GetType(); } }
-
-        public virtual bool Match(object obj) { return Equals(obj); }
-        #endregion
-
-        #region Public Members
-        public virtual bool IsDefaultAttribute() { return false; }
-        #endregion
     }
 }