зеркало из https://github.com/mono/ikvm-fork.git
Added == and != operators to MemberInfo to mask the fact that we don't implement reference identity for various members (most notably the constructor wrappers, generic wrappers and events and properties).
Changed Type.Equals() to avoid infinite recursion, now that we overload the == operator.
This commit is contained in:
Родитель
855cc893ee
Коммит
860e0a148e
|
@ -28,6 +28,9 @@ using System.Text;
|
||||||
|
|
||||||
namespace IKVM.Reflection
|
namespace IKVM.Reflection
|
||||||
{
|
{
|
||||||
|
// disable warnings that complain about us having == and != operators without also overriding Equals/GetHashCode,
|
||||||
|
// this is intentional because most subtypes use reference equality
|
||||||
|
#pragma warning disable 660, 661
|
||||||
public abstract class MemberInfo
|
public abstract class MemberInfo
|
||||||
{
|
{
|
||||||
public abstract string Name { get; }
|
public abstract string Name { get; }
|
||||||
|
@ -49,6 +52,16 @@ namespace IKVM.Reflection
|
||||||
return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit).Count != 0;
|
return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit).Count != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(MemberInfo m1, MemberInfo m2)
|
||||||
|
{
|
||||||
|
return ReferenceEquals(m1, m2) || (!ReferenceEquals(m1, null) && m1.Equals(m2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(MemberInfo m1, MemberInfo m2)
|
||||||
|
{
|
||||||
|
return !(m1 == m2);
|
||||||
|
}
|
||||||
|
|
||||||
internal virtual IList<CustomAttributeData> GetCustomAttributesData()
|
internal virtual IList<CustomAttributeData> GetCustomAttributesData()
|
||||||
{
|
{
|
||||||
return this.Module.GetCustomAttributes(this.MetadataToken);
|
return this.Module.GetCustomAttributes(this.MetadataToken);
|
||||||
|
|
|
@ -211,7 +211,7 @@ namespace IKVM.Reflection
|
||||||
|
|
||||||
public bool Equals(Type type)
|
public bool Equals(Type type)
|
||||||
{
|
{
|
||||||
return type != null && type.UnderlyingSystemType == this.UnderlyingSystemType;
|
return !ReferenceEquals(type, null) && ReferenceEquals(type.UnderlyingSystemType, this.UnderlyingSystemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче