From: Atsushi Kanamori Date: Wed, 15 Mar 2017 22:52:05 +0000 (-0700) Subject: Migrate MethodBase.cs over to the shared partition. (dotnet/coreclr#10202) X-Git-Tag: submit/tizen/20210909.063632~11030^2~7720 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8b2be32adf3879df0bfa05e72b445b7893e029f;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Migrate MethodBase.cs over to the shared partition. (dotnet/coreclr#10202) * Replace each member with CoreRt prose. * Lightup IsConstructedGenericMethod * Copy over CoreRt MethodBase.cs (this is now just a reordering) * Move MethodBase.cs verbative over to shared partition. * AAAAND.... it looks like this exercise exposed a bug in CoreRt. * Resolved merge conflict Commit migrated from https://github.com/dotnet/coreclr/commit/450ac8f965586c7b28488b6af16855a383da6278 --- diff --git a/src/coreclr/src/mscorlib/System.Private.CoreLib.csproj b/src/coreclr/src/mscorlib/System.Private.CoreLib.csproj index 4f60b11..530aedc 100644 --- a/src/coreclr/src/mscorlib/System.Private.CoreLib.csproj +++ b/src/coreclr/src/mscorlib/System.Private.CoreLib.csproj @@ -483,7 +483,6 @@ - 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 a648640..0ceaefd 100644 --- a/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems @@ -155,6 +155,7 @@ + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/MethodBase.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/MethodBase.cs new file mode 100644 index 0000000..0037c74 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/MethodBase.cs @@ -0,0 +1,86 @@ +// 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. + +using System.Globalization; +using System.Diagnostics; + +namespace System.Reflection +{ + public abstract partial class MethodBase : MemberInfo + { + protected MethodBase() { } + + public abstract ParameterInfo[] GetParameters(); + public abstract MethodAttributes Attributes { get; } + public virtual MethodImplAttributes MethodImplementationFlags => GetMethodImplementationFlags(); + public abstract MethodImplAttributes GetMethodImplementationFlags(); + public virtual MethodBody GetMethodBody() { throw new InvalidOperationException(); } + public virtual CallingConventions CallingConvention => CallingConventions.Standard; + + public bool IsAbstract => (Attributes & MethodAttributes.Abstract) != 0; + public bool IsConstructor + { + get + { + // To be backward compatible we only return true for instance RTSpecialName ctors. + return (this is ConstructorInfo && + !IsStatic && + ((Attributes & MethodAttributes.RTSpecialName) == MethodAttributes.RTSpecialName)); + } + } + public bool IsFinal => (Attributes & MethodAttributes.Final) != 0; + public bool IsHideBySig => (Attributes & MethodAttributes.HideBySig) != 0; + public bool IsSpecialName => (Attributes & MethodAttributes.SpecialName) != 0; + public bool IsStatic => (Attributes & MethodAttributes.Static) != 0; + public bool IsVirtual => (Attributes & MethodAttributes.Virtual) != 0; + + public bool IsAssembly => (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Assembly; + public bool IsFamily => (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Family; + public bool IsFamilyAndAssembly => (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamANDAssem; + public bool IsFamilyOrAssembly => (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamORAssem; + public bool IsPrivate => (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; + public bool IsPublic => (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public; + + public virtual bool IsConstructedGenericMethod => IsGenericMethod && !IsGenericMethodDefinition; + public virtual bool IsGenericMethod => false; + public virtual bool IsGenericMethodDefinition => false; + public virtual Type[] GetGenericArguments() { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } + public virtual bool ContainsGenericParameters => false; + + [DebuggerHidden] + [DebuggerStepThrough] + public object Invoke(object obj, object[] parameters) => Invoke(obj, BindingFlags.Default, binder: null, parameters: parameters, culture: null); + public abstract object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture); + + public abstract RuntimeMethodHandle MethodHandle { get; } + + public virtual bool IsSecurityCritical { get { throw NotImplemented.ByDesign; } } + public virtual bool IsSecuritySafeCritical { get { throw NotImplemented.ByDesign; } } + public virtual bool IsSecurityTransparent { get { throw NotImplemented.ByDesign; } } + + public override bool Equals(object obj) => base.Equals(obj); + public override int GetHashCode() => base.GetHashCode(); + + public static bool operator ==(MethodBase left, MethodBase right) + { + if (object.ReferenceEquals(left, right)) + return true; + + if ((object)left == null || (object)right == null) + return false; + + MethodInfo method1, method2; + ConstructorInfo constructor1, constructor2; + + if ((method1 = left as MethodInfo) != null && (method2 = right as MethodInfo) != null) + return method1 == method2; + else if ((constructor1 = left as ConstructorInfo) != null && (constructor2 = right as ConstructorInfo) != null) + return constructor1 == constructor2; + + return false; + } + + public static bool operator !=(MethodBase left, MethodBase right) => !(left == right); + } +} diff --git a/src/coreclr/src/mscorlib/src/SR.cs b/src/coreclr/src/mscorlib/src/SR.cs index 8607c35..17bc05e 100644 --- a/src/coreclr/src/mscorlib/src/SR.cs +++ b/src/coreclr/src/mscorlib/src/SR.cs @@ -877,6 +877,12 @@ internal static class SR get { return Environment.GetResourceString("Serialization_NonSerType"); } } + + internal static string NotSupported_SubclassOverride + { + get { return Environment.GetResourceString("NotSupported_SubclassOverride"); } + } + internal static string InvalidCast_IConvertible => Environment.GetResourceString("InvalidCast_IConvertible"); diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/MethodBase.cs b/src/coreclr/src/mscorlib/src/System/Reflection/MethodBase.cs deleted file mode 100644 index bf254b1..0000000 --- a/src/coreclr/src/mscorlib/src/System/Reflection/MethodBase.cs +++ /dev/null @@ -1,148 +0,0 @@ -// 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. - -using System.Diagnostics; -using System.Globalization; - -namespace System.Reflection -{ - [Serializable] - public abstract partial class MethodBase : MemberInfo - { - #region Constructor - protected MethodBase() { } - #endregion - - public static bool operator ==(MethodBase left, MethodBase right) - { - if (ReferenceEquals(left, right)) - return true; - - if ((object)left == null || (object)right == null) - return false; - - MethodInfo method1, method2; - ConstructorInfo constructor1, constructor2; - - if ((method1 = left as MethodInfo) != null && (method2 = right as MethodInfo) != null) - return method1 == method2; - else if ((constructor1 = left as ConstructorInfo) != null && (constructor2 = right as ConstructorInfo) != null) - return constructor1 == constructor2; - - return false; - } - - public static bool operator !=(MethodBase left, MethodBase right) - { - return !(left == right); - } - - public override bool Equals(object obj) - { - return base.Equals(obj); - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - - #region Public Abstract\Virtual Members - [System.Diagnostics.Contracts.Pure] - public abstract ParameterInfo[] GetParameters(); - - public virtual MethodImplAttributes MethodImplementationFlags - { - get - { - return GetMethodImplementationFlags(); - } - } - - public abstract MethodImplAttributes GetMethodImplementationFlags(); - - public abstract RuntimeMethodHandle MethodHandle { get; } - - public abstract MethodAttributes Attributes { get; } - - public abstract Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture); - - public virtual CallingConventions CallingConvention { get { return CallingConventions.Standard; } } - - public virtual Type[] GetGenericArguments() { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride")); } - - public virtual bool IsGenericMethodDefinition { get { return false; } } - - public virtual bool ContainsGenericParameters { get { return false; } } - - public virtual bool IsGenericMethod { get { return false; } } - - public virtual bool IsSecurityCritical { get { throw new NotImplementedException(); } } - - public virtual bool IsSecuritySafeCritical { get { throw new NotImplementedException(); } } - - public virtual bool IsSecurityTransparent { get { throw new NotImplementedException(); } } - - #endregion - - #region Public Members - [DebuggerStepThroughAttribute] - [Diagnostics.DebuggerHidden] - public Object Invoke(Object obj, Object[] parameters) - { - // Theoretically we should set up a LookForMyCaller stack mark here and pass that along. - // But to maintain backward compatibility we can't switch to calling an - // internal overload that takes a stack mark. - // Fortunately the stack walker skips all the reflection invocation frames including this one. - // So this method will never be returned by the stack walker as the caller. - // See SystemDomain::CallersMethodCallbackWithStackMark in AppDomain.cpp. - return Invoke(obj, BindingFlags.Default, null, parameters, null); - } - - public bool IsPublic { get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public; } } - - public bool IsPrivate { get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; } } - - public bool IsFamily { get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Family; } } - - public bool IsAssembly { get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Assembly; } } - - public bool IsFamilyAndAssembly { get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamANDAssem; } } - - public bool IsFamilyOrAssembly { get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamORAssem; } } - - public bool IsStatic { get { return (Attributes & MethodAttributes.Static) != 0; } } - - public bool IsFinal - { - get { return (Attributes & MethodAttributes.Final) != 0; } - } - public bool IsVirtual - { - get { return (Attributes & MethodAttributes.Virtual) != 0; } - } - public bool IsHideBySig { get { return (Attributes & MethodAttributes.HideBySig) != 0; } } - - public bool IsAbstract { get { return (Attributes & MethodAttributes.Abstract) != 0; } } - - public bool IsSpecialName { get { return (Attributes & MethodAttributes.SpecialName) != 0; } } - - public bool IsConstructor - { - get - { - // To be backward compatible we only return true for instance RTSpecialName ctors. - return (this is ConstructorInfo && - !IsStatic && - ((Attributes & MethodAttributes.RTSpecialName) == MethodAttributes.RTSpecialName)); - } - } - - public virtual MethodBody GetMethodBody() - { - throw new InvalidOperationException(); - } - #endregion - } -}