diff options
author | Zoltan Varga <vargaz@gmail.com> | 2019-03-09 13:26:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-09 13:26:40 +0300 |
commit | 0f798ae6cf631abed1f3440b2150c16533060d3d (patch) | |
tree | 447a7b23d48a4f6a2a3452f369e3c69e9e7c40d5 /mcs/class/referencesource | |
parent | dd0e9a8aa38ec45184b8d9c8e4bccda2e8ac54ed (diff) |
[netcore] Ongoing work. (#13357)
* [netcore] Implement MethodBody using internal Runtime* classes. Use the mono version for ModuleHandle.
* [netcore] Reflection fixes.
* Address review comments.
* [netcore] Implement RuntimeHelpers:GetUninitializedObject ().
* [netcore] Implement the Type::GetMethod () overload which has a genericParameterCount parameter.
* [netcore] Implement Thread.OptimalMaxSpinWaitsPerSpinIteration.
* Revert a change to fix a test failure.
* [netcore] Implement Marshal:GetExceptionForHRInternal ().
* [netcore] Implement GC:GetSegmentSize ().
* [runtime] Allow pointer type members in typed references.
Diffstat (limited to 'mcs/class/referencesource')
-rw-r--r-- | mcs/class/referencesource/mscorlib/system/rttype.cs | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/mcs/class/referencesource/mscorlib/system/rttype.cs b/mcs/class/referencesource/mscorlib/system/rttype.cs index 95a8462de28..da6c1d7927a 100644 --- a/mcs/class/referencesource/mscorlib/system/rttype.cs +++ b/mcs/class/referencesource/mscorlib/system/rttype.cs @@ -2822,7 +2822,7 @@ namespace System #region Get XXXInfo Candidates private ListBuilder<MethodInfo> GetMethodCandidates( String name, BindingFlags bindingAttr, CallingConventions callConv, - Type[] types, bool allowPrefixLookup) + Type[] types, int genericParamCount, bool allowPrefixLookup) { bool prefixLookup, ignoreCase; MemberListType listType; @@ -2834,9 +2834,20 @@ namespace System RuntimeMethodInfo[] cache = Cache.GetMethodList(listType, name); #endif ListBuilder<MethodInfo> candidates = new ListBuilder<MethodInfo>(cache.Length); + for (int i = 0; i < cache.Length; i++) { RuntimeMethodInfo methodInfo = cache[i]; + if (genericParamCount != -1) { + bool is_generic = methodInfo.IsGenericMethod; + if (genericParamCount == 0 && is_generic) + continue; + else if (genericParamCount > 0 && !is_generic) + continue; + var args = methodInfo.GetGenericArguments (); + if (args.Length != genericParamCount) + continue; + } if (FilterApplyMethodInfo(methodInfo, bindingAttr, callConv, types) && (!prefixLookup || RuntimeType.FilterApplyPrefixLookup(methodInfo, name, ignoreCase))) { @@ -3082,7 +3093,7 @@ namespace System #region Get All XXXInfos public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { - return GetMethodCandidates(null, bindingAttr, CallingConventions.Any, null, false).ToArray(); + return GetMethodCandidates(null, bindingAttr, CallingConventions.Any, null, -1, false).ToArray(); } [System.Runtime.InteropServices.ComVisible(true)] @@ -3124,7 +3135,7 @@ namespace System public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { - ListBuilder<MethodInfo> methods = GetMethodCandidates(null, bindingAttr, CallingConventions.Any, null, false); + ListBuilder<MethodInfo> methods = GetMethodCandidates(null, bindingAttr, CallingConventions.Any, null, -1, false); ListBuilder<ConstructorInfo> constructors = GetConstructorCandidates(null, bindingAttr, CallingConventions.Any, null, false); ListBuilder<PropertyInfo> properties = GetPropertyCandidates(null, bindingAttr, null, false); ListBuilder<EventInfo> events = GetEventCandidates(null, bindingAttr, false); @@ -3214,13 +3225,17 @@ namespace System #endif #endregion - #region Find XXXInfo -#if !MONO || NETCORE - protected override MethodInfo GetMethodImpl( - String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, +#if NETCORE + protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) + { + return GetMethodImpl (name, -1, bindingAttr, binder, callConvention, types, modifiers); + } + + protected override MethodInfo GetMethodImpl(String name, int genericParamCount, + BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers) { - ListBuilder<MethodInfo> candidates = GetMethodCandidates(name, bindingAttr, callConv, types, false); + ListBuilder<MethodInfo> candidates = GetMethodCandidates(name, bindingAttr, callConv, types, genericParamCount, false); if (candidates.Count == 0) return null; @@ -3237,14 +3252,8 @@ namespace System for (int j = 1; j < candidates.Count; j++) { MethodInfo methodInfo = candidates[j]; -#if NETCORE - throw new NotImplementedException (); -#else - if (!System.DefaultBinder.CompareMethodSigAndName(methodInfo, firstCandidate)) - { + if (!System.DefaultBinder.CompareMethodSig (methodInfo, firstCandidate)) throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); - } -#endif } // All the methods have the exact same name and sig so return the most derived one. @@ -3512,7 +3521,7 @@ namespace System // Methods if ((type & MemberTypes.Method) != 0) { - methods = GetMethodCandidates(name, bindingAttr, CallingConventions.Any, null, true); + methods = GetMethodCandidates(name, bindingAttr, CallingConventions.Any, null, -1, true); if (type == MemberTypes.Method) return methods.ToArray(); totalCount += methods.Count; @@ -5057,8 +5066,6 @@ namespace System } #endregion - #endregion - #region Object Overrides [Pure] public override bool Equals(object obj) @@ -5432,12 +5439,7 @@ namespace System } else { #endif // fast path?? -#if NETCORE - throw new NotImplementedException (); -#else server = Activator.CreateInstance(this, nonPublic: true, wrapExceptions: wrapExceptions); -#endif - #if MONO && FEATURE_REMOTING } #endif |