diff options
Diffstat (limited to 'src/System.Private.CoreLib/src/System/RtType.cs')
-rw-r--r-- | src/System.Private.CoreLib/src/System/RtType.cs | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/System.Private.CoreLib/src/System/RtType.cs b/src/System.Private.CoreLib/src/System/RtType.cs index 921c15e25b..e423b45718 100644 --- a/src/System.Private.CoreLib/src/System/RtType.cs +++ b/src/System.Private.CoreLib/src/System/RtType.cs @@ -4097,8 +4097,7 @@ namespace System if (results != null) { Debug.Assert(results.Count > 1); - finalists = new MethodInfo[results.Count]; - results.CopyTo(finalists); + finalists = results.ToArray(); } } @@ -4149,8 +4148,7 @@ namespace System if (results != null) { Debug.Assert(results.Count > 1); - finalists = new MethodInfo[results.Count]; - results.CopyTo(finalists); + finalists = results.ToArray(); } } @@ -4342,8 +4340,6 @@ namespace System if (args == null) args = Array.Empty<object>(); - int argCnt = args.Length; - // Without a binder we need to do use the default binder... if (binder == null) binder = DefaultBinder; @@ -4352,7 +4348,7 @@ namespace System // so a call to GetMemberCons would fail bool publicOnly = (bindingAttr & BindingFlags.NonPublic) == 0; bool wrapExceptions = (bindingAttr & BindingFlags.DoNotWrapExceptions) == 0; - if (argCnt == 0 && (bindingAttr & BindingFlags.Public) != 0 && (bindingAttr & BindingFlags.Instance) != 0 + if (args.Length == 0 && (bindingAttr & BindingFlags.Public) != 0 && (bindingAttr & BindingFlags.Instance) != 0 && (IsGenericCOMObjectImpl() || IsValueType)) { server = CreateInstanceDefaultCtor(publicOnly, false, true, wrapExceptions); @@ -4363,8 +4359,8 @@ namespace System List<MethodBase> matches = new List<MethodBase>(candidates.Length); // We cannot use Type.GetTypeArray here because some of the args might be null - Type[] argsType = new Type[argCnt]; - for (int i = 0; i < argCnt; i++) + Type[] argsType = new Type[args.Length]; + for (int i = 0; i < args.Length; i++) { if (args[i] != null) { @@ -4378,16 +4374,13 @@ namespace System matches.Add(candidates[i]); } - MethodBase[] cons = new MethodBase[matches.Count]; - matches.CopyTo(cons); - if (cons != null && cons.Length == 0) - cons = null; - - if (cons == null) + if (matches.Count == 0) { throw new MissingMethodException(SR.Format(SR.MissingConstructor_Name, FullName)); } + MethodBase[] cons = matches.ToArray(); + MethodBase invokeMethod; object state = null; |