From 8b7a2b519420bbc4529ed96c44612651bd9cb086 Mon Sep 17 00:00:00 2001 From: Atsushi Kanamori Date: Thu, 19 Jan 2017 08:16:20 -0800 Subject: Make two System.Type methods virtual to conform with 4.2.0.0. System.Runtime 4.2.0.0 finally brings IsEnum in line with the other "Is" predicates.... --- src/System.Private.CoreLib/src/System/Type.cs | 4 ++-- .../System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.cs | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/System.Private.CoreLib/src/System/Type.cs b/src/System.Private.CoreLib/src/System/Type.cs index 8a9197464..4c54744a6 100644 --- a/src/System.Private.CoreLib/src/System/Type.cs +++ b/src/System.Private.CoreLib/src/System/Type.cs @@ -105,7 +105,7 @@ namespace System public bool IsContextful => IsContextfulImpl(); protected virtual bool IsContextfulImpl() => typeof(ContextBoundObject).IsAssignableFrom(this); - public bool IsEnum => IsSubclassOf(typeof(Enum)); + public virtual bool IsEnum => IsSubclassOf(typeof(Enum)); public bool IsMarshalByRef => IsMarshalByRefImpl(); protected virtual bool IsMarshalByRefImpl() => typeof(MarshalByRefObject).IsAssignableFrom(this); public bool IsPrimitive => IsPrimitiveImpl(); @@ -351,7 +351,7 @@ namespace System return systemType.GetHashCode(); return base.GetHashCode(); } - public bool Equals(Type o) => o == null ? false : object.ReferenceEquals(this.UnderlyingSystemType, o.UnderlyingSystemType); + public virtual bool Equals(Type o) => o == null ? false : object.ReferenceEquals(this.UnderlyingSystemType, o.UnderlyingSystemType); public static bool operator ==(Type left, Type right) { diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.cs index 83cd7a4fc..58635acca 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.cs @@ -141,6 +141,11 @@ namespace System.Reflection.Runtime.TypeInfos return object.ReferenceEquals(this, obj); } + public sealed override bool Equals(Type o) + { + return object.ReferenceEquals(this, o); + } + public sealed override int GetHashCode() { return InternalGetHashCode(); @@ -302,6 +307,14 @@ namespace System.Reflection.Runtime.TypeInfos } } + public sealed override bool IsEnum + { + get + { + return 0 != (Classification & TypeClassification.IsEnum); + } + } + // // Left unsealed as generic parameter types must override. // -- cgit v1.2.3