From: Atsushi Kanamori Date: Wed, 15 Mar 2017 13:40:24 +0000 (-0700) Subject: Replace MemberInfo.cs with the CoreRt version and move to shared partition. (dotnet... X-Git-Tag: submit/tizen/20210909.063632~11030^2~7726 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4350362ca4fca0d6ae5ff3a5edf0cae7e3081d85;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Replace MemberInfo.cs with the CoreRt version and move to shared partition. (dotnet/coreclr#10167) * Move file verbatim. * Port over CoreRT style sans reordering. * Final replacement with CoreRt file. Commit migrated from https://github.com/dotnet/coreclr/commit/44df0f37ce9e4e4ea63718ba0b4e74d53970037a --- diff --git a/src/coreclr/src/mscorlib/Common/NotImplemented.cs b/src/coreclr/src/mscorlib/Common/NotImplemented.cs new file mode 100644 index 0000000..82f4e18 --- /dev/null +++ b/src/coreclr/src/mscorlib/Common/NotImplemented.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System +{ + // + // This simple class enables one to throw a NotImplementedException using the following + // idiom: + // + // throw NotImplemented.ByDesign; + // + // Used by methods whose intended implementation is to throw a NotImplementedException (typically + // virtual methods in public abstract classes that intended to be subclassed by third parties.) + // + // This makes it distinguishable both from human eyes and CCI from NYI's that truly represent undone work. + // + internal static class NotImplemented + { + internal static Exception ByDesign + { + get + { + return new NotImplementedException(); + } + } + + internal static Exception ByDesignWithMessage(string message) + { + return new NotImplementedException(message); + } + } +} + diff --git a/src/coreclr/src/mscorlib/System.Private.CoreLib.csproj b/src/coreclr/src/mscorlib/System.Private.CoreLib.csproj index 8789ca8..cf14056 100644 --- a/src/coreclr/src/mscorlib/System.Private.CoreLib.csproj +++ b/src/coreclr/src/mscorlib/System.Private.CoreLib.csproj @@ -479,7 +479,7 @@ - + @@ -976,6 +976,7 @@ + diff --git a/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems b/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems index 8e211d4..5955180 100644 --- a/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems @@ -153,6 +153,7 @@ + diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/MemberInfo.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/MemberInfo.cs similarity index 62% rename from src/coreclr/src/mscorlib/src/System/Reflection/MemberInfo.cs rename to src/coreclr/src/mscorlib/shared/System/Reflection/MemberInfo.cs index dd9d20e5..1275cc1 100644 --- a/src/coreclr/src/mscorlib/src/System/Reflection/MemberInfo.cs +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/MemberInfo.cs @@ -2,74 +2,49 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -// - -using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; -using System.Runtime; -using System.Runtime.InteropServices; namespace System.Reflection { - [Serializable] - public abstract class MemberInfo : ICustomAttributeProvider + public abstract partial class MemberInfo : ICustomAttributeProvider { - #region Constructor protected MemberInfo() { } - #endregion - - #region Internal Methods - internal virtual bool CacheEquals(object o) { throw new NotImplementedException(); } - #endregion - #region Public Abstract\Virtual Members public abstract MemberTypes MemberType { get; } - - public abstract String Name { get; } - + public abstract string Name { get; } public abstract Type DeclaringType { get; } - public abstract Type ReflectedType { get; } - public virtual IEnumerable CustomAttributes + public virtual Module Module { get { - return GetCustomAttributesData(); + // This check is necessary because for some reason, Type adds a new "Module" property that hides the inherited one instead + // of overriding. + + Type type = this as Type; + if (type != null) + return type.Module; + + throw NotImplemented.ByDesign; } } - public abstract Object[] GetCustomAttributes(bool inherit); - - public abstract Object[] GetCustomAttributes(Type attributeType, bool inherit); public abstract bool IsDefined(Type attributeType, bool inherit); + public abstract object[] GetCustomAttributes(bool inherit); + public abstract object[] GetCustomAttributes(Type attributeType, bool inherit); - public virtual IList GetCustomAttributesData() - { - throw new NotImplementedException(); - } + public virtual IEnumerable CustomAttributes => GetCustomAttributesData(); + public virtual IList GetCustomAttributesData() { throw NotImplemented.ByDesign; } public virtual int MetadataToken { get { throw new InvalidOperationException(); } } - public virtual Module Module - { - get - { - if (this is Type) - return ((Type)this).Module; - - throw new NotImplementedException(); - } - } - - - - #endregion + public override bool Equals(object obj) => base.Equals(obj); + public override int GetHashCode() => base.GetHashCode(); public static bool operator ==(MemberInfo left, MemberInfo right) { - if (ReferenceEquals(left, right)) + if (object.ReferenceEquals(left, right)) return true; if ((object)left == null || (object)right == null) @@ -95,19 +70,6 @@ namespace System.Reflection return false; } - public static bool operator !=(MemberInfo left, MemberInfo right) - { - return !(left == right); - } - - public override bool Equals(object obj) - { - return base.Equals(obj); - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } + public static bool operator !=(MemberInfo left, MemberInfo right) => !(left == right); } } diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/MemberInfo.Internal.cs b/src/coreclr/src/mscorlib/src/System/Reflection/MemberInfo.Internal.cs new file mode 100644 index 0000000..8e7be56 --- /dev/null +++ b/src/coreclr/src/mscorlib/src/System/Reflection/MemberInfo.Internal.cs @@ -0,0 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public abstract partial class MemberInfo + { + internal virtual bool CacheEquals(object o) { throw new NotImplementedException(); } + } +}