summaryrefslogtreecommitdiff
path: root/src/System.Private.CoreLib/src/System
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2019-01-03 11:51:17 +0100
committerJan Kotas <jkotas@microsoft.com>2019-01-03 07:19:04 -1000
commit6eecaafdeb8d5870f06f99905b57f260b3c09131 (patch)
tree1471717dea36f7ccc4a8fb3c5fc6ba45f2a6085a /src/System.Private.CoreLib/src/System
parent8e36b4aba1d63fda1597c365adf9b7b440cf1370 (diff)
downloadcoreclr-6eecaafdeb8d5870f06f99905b57f260b3c09131.tar.gz
coreclr-6eecaafdeb8d5870f06f99905b57f260b3c09131.tar.bz2
coreclr-6eecaafdeb8d5870f06f99905b57f260b3c09131.zip
Removes the code moved to shared partition
Diffstat (limited to 'src/System.Private.CoreLib/src/System')
-rw-r--r--src/System.Private.CoreLib/src/System/Attribute.cs138
1 files changed, 1 insertions, 137 deletions
diff --git a/src/System.Private.CoreLib/src/System/Attribute.cs b/src/System.Private.CoreLib/src/System/Attribute.cs
index f1224c21f3..94143f7005 100644
--- a/src/System.Private.CoreLib/src/System/Attribute.cs
+++ b/src/System.Private.CoreLib/src/System/Attribute.cs
@@ -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
}
}