Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -0,0 +1,86 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace System {
partial class RuntimeType {
private const int GenericParameterCountAny = -1;
protected override MethodInfo GetMethodImpl (
String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv,
Type [] types, ParameterModifier [] modifiers)
{
return GetMethodImplCommon (name, GenericParameterCountAny, bindingAttr, binder, callConv, types, modifiers);
}
protected override MethodInfo GetMethodImpl (
String name, int genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv,
Type [] types, ParameterModifier [] modifiers)
{
return GetMethodImplCommon (name, genericParameterCount, bindingAttr, binder, callConv, types, modifiers);
}
private MethodInfo GetMethodImplCommon (
String name, int genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv,
Type [] types, ParameterModifier [] modifiers)
{
ListBuilder<MethodInfo> candidates = GetMethodCandidates (name, genericParameterCount, bindingAttr, callConv, types, false);
if (candidates.Count == 0)
return null;
if (types == null || types.Length == 0) {
MethodInfo firstCandidate = candidates[0];
if (candidates.Count == 1) {
return firstCandidate;
} else if (types == null) {
for (int j = 1; j < candidates.Count; j++) {
MethodInfo methodInfo = candidates [j];
if (!System.DefaultBinder.CompareMethodSig (methodInfo, firstCandidate))
throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException);
}
// All the methods have the exact same name and sig so return the most derived one.
return System.DefaultBinder.FindMostDerivedNewSlotMeth(candidates.ToArray(), candidates.Count) as MethodInfo;
}
}
if (binder == null)
binder = DefaultBinder;
return binder.SelectMethod (bindingAttr, candidates.ToArray(), types, modifiers) as MethodInfo;
}
private ListBuilder<MethodInfo> GetMethodCandidates(
String name, int genericParameterCount, BindingFlags bindingAttr, CallingConventions callConv,
Type[] types, bool allowPrefixLookup)
{
bool prefixLookup, ignoreCase;
MemberListType listType;
RuntimeType.FilterHelper(bindingAttr, ref name, allowPrefixLookup, out prefixLookup, out ignoreCase, out listType);
#if MONO
RuntimeMethodInfo[] cache = GetMethodsByName (name, bindingAttr, listType, this);
#else
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 (genericParameterCount != GenericParameterCountAny && genericParameterCount != methodInfo.GenericParameterCount)
continue;
if (FilterApplyMethodInfo(methodInfo, bindingAttr, callConv, types) &&
(!prefixLookup || RuntimeType.FilterApplyPrefixLookup(methodInfo, name, ignoreCase)))
{
candidates.Add(methodInfo);
}
}
return candidates;
}
}
}

View File

@@ -1,35 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace System.IO
{
partial class Stream
{
public virtual int Read (Span<byte> destination)
{
throw new NotImplementedException ();
}
public virtual void Write (ReadOnlySpan<byte> source)
{
throw new NotImplementedException ();
}
public virtual ValueTask<int> ReadAsync (Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken))
{
if (MemoryMarshal.TryGetArray (destination, out ArraySegment<byte> array))
return new ValueTask<int> (ReadAsync (array.Array, array.Offset, array.Count, cancellationToken));
throw new NotImplementedException ();
}
public virtual ValueTask WriteAsync (ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
{
if (MemoryMarshal.TryGetArray (source, out ArraySegment<byte> array))
return new ValueTask (WriteAsync (array.Array, array.Offset, array.Count, cancellationToken));
throw new NotImplementedException ();
}
}
}

View File

@@ -2,7 +2,10 @@ using System.Reflection;
namespace System {
partial class Type {
internal const string DefaultTypeNameWhenMissingMetadata = "UnknownType";
public static Type GetTypeFromCLSID (Guid clsid, string server, bool throwOnError) => RuntimeType.GetTypeFromCLSIDImpl (clsid, server, throwOnError);
public static Type GetTypeFromProgID (string progID, string server, bool throwOnError) => RuntimeType.GetTypeFromProgID (progID, server, throwOnError);
internal const string DefaultTypeNameWhenMissingMetadata = "UnknownType";
internal string FullNameOrDefault {
get {
@@ -10,7 +13,6 @@ namespace System {
// We'll still wrap the call in a try-catch as a failsafe.
if (InternalNameIfAvailable == null)
return DefaultTypeNameWhenMissingMetadata;
try {
return FullName;
} catch (MissingMetadataException) {
@@ -19,21 +21,21 @@ namespace System {
}
}
internal bool IsRuntimeImplemented () => true;
internal virtual string InternalGetNameIfAvailable (ref Type rootCauseForFailure) => Name;
internal bool IsRuntimeImplemented () => this.UnderlyingSystemType is RuntimeType;
internal virtual string InternalGetNameIfAvailable (ref Type rootCauseForFailure) => Name;
internal string InternalNameIfAvailable {
get {
Type ignore = null;
return InternalGetNameIfAvailable (ref ignore);
}
}
internal string NameOrDefault {
internal string NameOrDefault {
get {
return InternalNameIfAvailable ?? DefaultTypeNameWhenMissingMetadata;
}
}
}
}
}