diff options
author | Atsushi Kanamori <AtsushiKan@users.noreply.github.com> | 2017-10-04 01:22:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-04 01:22:38 +0300 |
commit | 672c543d12cc24f19ecdc55fe9338eefbb659777 (patch) | |
tree | 5285c3cad52d3e7459a2aec8ba905968231bef6b /src/System.Private.Reflection.Core | |
parent | eabdf9f64ad5a29153c6a0d37389b3b333f6813c (diff) |
Implement IsGenericTypeParameter and IsGenericMethodParameter on CoreRT (#4662)
Api approved here:
https://github.com/dotnet/corefx/issues/23883
Diffstat (limited to 'src/System.Private.Reflection.Core')
10 files changed, 28 insertions, 10 deletions
diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/BindingFlagSupport/MemberPolicies.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/BindingFlagSupport/MemberPolicies.cs index d807aa383..62177be3f 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/BindingFlagSupport/MemberPolicies.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/BindingFlagSupport/MemberPolicies.cs @@ -172,19 +172,15 @@ namespace System.Reflection.Runtime.BindingFlagSupport return true; } - if (t1.IsGenericParameter && t2.IsGenericParameter) + if (t1.IsGenericMethodParameter && t2.IsGenericMethodParameter) { - if (t1.DeclaringMethod != null && t2.DeclaringMethod != null) - { - // A generic method parameter. The DeclaringMethods will be different but we don't care about that - we can assume that - // the declaring method will be the method that declared the parameter's whose type we're testing. We only need to - // compare the positions. - return t1.GenericParameterPosition == t2.GenericParameterPosition; - } - return false; + // A generic method parameter. The DeclaringMethods will be different but we don't care about that - we can assume that + // the declaring method will be the method that declared the parameter's whose type we're testing. We only need to + // compare the positions. + return t1.GenericParameterPosition == t2.GenericParameterPosition; } - // If we got here, either t1 and t2 are different flavors of types or they are both simple named types. + // If we got here, either t1 and t2 are different flavors of types or they are both simple named types or both generic type parameters. // Either way, we can trust Reflection's result here. return false; } diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/EcmaFormat/EcmaFormatRuntimeGenericParameterTypeInfoForMethods.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/EcmaFormat/EcmaFormatRuntimeGenericParameterTypeInfoForMethods.cs index ec58e970e..08f497311 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/EcmaFormat/EcmaFormatRuntimeGenericParameterTypeInfoForMethods.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/EcmaFormat/EcmaFormatRuntimeGenericParameterTypeInfoForMethods.cs @@ -27,6 +27,9 @@ namespace System.Reflection.Runtime.TypeInfos.EcmaFormat _declaringRuntimeNamedMethodInfo = declaringRuntimeNamedMethodInfo; } + public sealed override bool IsGenericTypeParameter => false; + public sealed override bool IsGenericMethodParameter => true; + public sealed override MethodBase DeclaringMethod { get diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/EcmaFormat/EcmaFormatRuntimeGenericParameterTypeInfoForTypes.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/EcmaFormat/EcmaFormatRuntimeGenericParameterTypeInfoForTypes.cs index 2f14f6e27..d4d540cd9 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/EcmaFormat/EcmaFormatRuntimeGenericParameterTypeInfoForTypes.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/EcmaFormat/EcmaFormatRuntimeGenericParameterTypeInfoForTypes.cs @@ -23,6 +23,9 @@ namespace System.Reflection.Runtime.TypeInfos.EcmaFormat _declaringType = declaringType; } + public sealed override bool IsGenericTypeParameter => true; + public sealed override bool IsGenericMethodParameter => false; + public sealed override MethodBase DeclaringMethod { get diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeGenericParameterTypeInfoForMethods.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeGenericParameterTypeInfoForMethods.cs index f237f5565..42640f7af 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeGenericParameterTypeInfoForMethods.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeGenericParameterTypeInfoForMethods.cs @@ -27,6 +27,9 @@ namespace System.Reflection.Runtime.TypeInfos.NativeFormat _declaringRuntimeNamedMethodInfo = declaringRuntimeNamedMethodInfo; } + public sealed override bool IsGenericTypeParameter => false; + public sealed override bool IsGenericMethodParameter => true; + public sealed override MethodBase DeclaringMethod { get diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeGenericParameterTypeInfoForTypes.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeGenericParameterTypeInfoForTypes.cs index 2cbe72943..3cc9ab957 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeGenericParameterTypeInfoForTypes.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeGenericParameterTypeInfoForTypes.cs @@ -23,6 +23,9 @@ namespace System.Reflection.Runtime.TypeInfos.NativeFormat _declaringType = declaringType; } + public sealed override bool IsGenericTypeParameter => true; + public sealed override bool IsGenericMethodParameter => false; + public sealed override MethodBase DeclaringMethod { get diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeConstructedGenericTypeInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeConstructedGenericTypeInfo.cs index e96e36238..9740554ec 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeConstructedGenericTypeInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeConstructedGenericTypeInfo.cs @@ -39,6 +39,8 @@ namespace System.Reflection.Runtime.TypeInfos protected sealed override bool IsPointerImpl() => false; public sealed override bool IsConstructedGenericType => true; public sealed override bool IsGenericParameter => false; + public sealed override bool IsGenericTypeParameter => false; + public sealed override bool IsGenericMethodParameter => false; public sealed override bool IsByRefLike => GenericTypeDefinitionTypeInfo.IsByRefLike; // diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeGenericParameterTypeInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeGenericParameterTypeInfo.cs index 241878768..c5cae14b4 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeGenericParameterTypeInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeGenericParameterTypeInfo.cs @@ -35,6 +35,8 @@ namespace System.Reflection.Runtime.TypeInfos protected sealed override bool IsPointerImpl() => false; public sealed override bool IsConstructedGenericType => false; public sealed override bool IsGenericParameter => true; + public abstract override bool IsGenericTypeParameter { get; } + public abstract override bool IsGenericMethodParameter { get; } public sealed override bool IsByRefLike => false; public sealed override Assembly Assembly diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeHasElementTypeInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeHasElementTypeInfo.cs index 88ee72d35..be466e7e4 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeHasElementTypeInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeHasElementTypeInfo.cs @@ -36,6 +36,8 @@ namespace System.Reflection.Runtime.TypeInfos protected abstract override bool IsPointerImpl(); public sealed override bool IsConstructedGenericType => false; public sealed override bool IsGenericParameter => false; + public sealed override bool IsGenericTypeParameter => false; + public sealed override bool IsGenericMethodParameter => false; public sealed override bool IsByRefLike => false; // diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeDefinitionTypeInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeDefinitionTypeInfo.cs index 5fc2676eb..d1d33416e 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeDefinitionTypeInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeDefinitionTypeInfo.cs @@ -24,6 +24,8 @@ namespace System.Reflection.Runtime.TypeInfos protected sealed override bool IsPointerImpl() => false; public sealed override bool IsConstructedGenericType => false; public sealed override bool IsGenericParameter => false; + public sealed override bool IsGenericTypeParameter => false; + public sealed override bool IsGenericMethodParameter => false; public sealed override bool IsByRefLike { 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 1e3cd5be5..66f0850c1 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 @@ -51,6 +51,8 @@ namespace System.Reflection.Runtime.TypeInfos protected abstract override bool IsByRefImpl(); protected abstract override bool IsPointerImpl(); public abstract override bool IsGenericParameter { get; } + public abstract override bool IsGenericTypeParameter { get; } + public abstract override bool IsGenericMethodParameter { get; } public abstract override bool IsConstructedGenericType { get; } public abstract override bool IsByRefLike { get; } |