diff options
author | Atsushi Kanamori <AtsushiKan@users.noreply.github.com> | 2017-03-15 15:52:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-15 15:52:05 -0700 |
commit | 450ac8f965586c7b28488b6af16855a383da6278 (patch) | |
tree | f9b3762b718cce5464dcee62820ad85e5df3944e /src | |
parent | 65ca581afb6ad852e4533fcbaaa2f02269d8c2df (diff) | |
download | coreclr-450ac8f965586c7b28488b6af16855a383da6278.tar.gz coreclr-450ac8f965586c7b28488b6af16855a383da6278.tar.bz2 coreclr-450ac8f965586c7b28488b6af16855a383da6278.zip |
Migrate MethodBase.cs over to the shared partition. (#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
Diffstat (limited to 'src')
-rw-r--r-- | src/mscorlib/System.Private.CoreLib.csproj | 1 | ||||
-rw-r--r-- | src/mscorlib/shared/System.Private.CoreLib.Shared.projitems | 1 | ||||
-rw-r--r-- | src/mscorlib/shared/System/Reflection/MethodBase.cs | 86 | ||||
-rw-r--r-- | src/mscorlib/src/SR.cs | 6 | ||||
-rw-r--r-- | src/mscorlib/src/System/Reflection/MethodBase.cs | 148 |
5 files changed, 93 insertions, 149 deletions
diff --git a/src/mscorlib/System.Private.CoreLib.csproj b/src/mscorlib/System.Private.CoreLib.csproj index 4f60b11148..530aedcb41 100644 --- a/src/mscorlib/System.Private.CoreLib.csproj +++ b/src/mscorlib/System.Private.CoreLib.csproj @@ -483,7 +483,6 @@ <Compile Include="$(BclSourcesRoot)\System\Reflection\MemberInfoSerializationHolder.cs" /> <Compile Include="$(BclSourcesRoot)\System\Reflection\MemberTypes.cs" /> <Compile Include="$(BclSourcesRoot)\System\Reflection\MethodAttributes.cs" /> - <Compile Include="$(BclSourcesRoot)\System\Reflection\MethodBase.cs" /> <Compile Include="$(BclSourcesRoot)\System\Reflection\MethodBase.CoreCLR.cs" /> <Compile Include="$(BclSourcesRoot)\System\Reflection\MethodImplAttributes.cs" /> <Compile Include="$(BclSourcesRoot)\System\Reflection\MethodInfo.cs" /> diff --git a/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems b/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems index a648640f1c..0ceaefd15e 100644 --- a/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems @@ -155,6 +155,7 @@ <Compile Include="$(MSBuildThisFileDirectory)System\PlatformNotSupportedException.cs"/> <Compile Include="$(MSBuildThisFileDirectory)System\RankException.cs"/> <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\MemberInfo.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\MethodBase.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\ObfuscateAssemblyAttribute.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\ObfuscationAttribute.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\TypeDelegator.cs" /> diff --git a/src/mscorlib/shared/System/Reflection/MethodBase.cs b/src/mscorlib/shared/System/Reflection/MethodBase.cs new file mode 100644 index 0000000000..0037c74f4c --- /dev/null +++ b/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/mscorlib/src/SR.cs b/src/mscorlib/src/SR.cs index 8607c35235..17bc05e416 100644 --- a/src/mscorlib/src/SR.cs +++ b/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/mscorlib/src/System/Reflection/MethodBase.cs b/src/mscorlib/src/System/Reflection/MethodBase.cs deleted file mode 100644 index bf254b1285..0000000000 --- a/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 - } -} |