Imported Upstream version 5.20.0.180

Former-commit-id: ff953ca879339fe1e1211f7220f563e1342e66cb
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-02-04 20:11:37 +00:00
parent 0e2d47d1c8
commit 0510252385
3360 changed files with 83827 additions and 39243 deletions

View File

@@ -1,38 +0,0 @@
//
// CustomQueryInterfaceMode.cs
//
// Authors:
// Alexander Köplinger <alexander.koeplinger@xamarin.com>
//
// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Runtime.InteropServices
{
public enum CustomQueryInterfaceMode
{
Allow = 1,
Ignore = 0
}
}

View File

@@ -1,46 +0,0 @@
// GCHandleType.cs
//
// This code was automatically generated from
// ECMA CLI XML Library Specification.
// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
// Created: Fri, 7 Sep 2001 16:33:42 UTC
// Source file: AllTypes.xml
// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Runtime.InteropServices {
[ComVisible(true)]
[Serializable]
public enum GCHandleType {
Weak = 0,
WeakTrackResurrection = 1,
Normal = 2,
Pinned = 3,
}
}

View File

@@ -1897,5 +1897,72 @@ namespace System.Runtime.InteropServices
throw new NotSupportedException();
}
#endif
internal class MarshalerInstanceKeyComparer : IEqualityComparer<(Type, string)> {
public bool Equals ((Type, string) lhs, (Type, string) rhs) {
return lhs.CompareTo(rhs) == 0;
}
public int GetHashCode ((Type, string) key) {
return key.GetHashCode ();
}
}
internal static Dictionary<(Type, string), ICustomMarshaler> MarshalerInstanceCache;
internal static readonly object MarshalerInstanceCacheLock = new object ();
internal static ICustomMarshaler GetCustomMarshalerInstance (Type type, string cookie) {
var key = (type, cookie);
LazyInitializer.EnsureInitialized (
ref MarshalerInstanceCache,
() => new Dictionary<(Type, string), ICustomMarshaler> (new MarshalerInstanceKeyComparer ())
);
ICustomMarshaler result;
bool gotExistingInstance;
lock (MarshalerInstanceCacheLock)
gotExistingInstance = MarshalerInstanceCache.TryGetValue (key, out result);
if (!gotExistingInstance) {
MonoMethod getInstanceMethod;
try {
getInstanceMethod = (MonoMethod)type.GetMethod (
"GetInstance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod,
null, new Type[] { typeof(string) }, null
);
} catch (AmbiguousMatchException) {
throw new ApplicationException ($"Custom marshaler '{type.FullName}' implements multiple static GetInstance methods that take a single string parameter.");
}
if ((getInstanceMethod == null) ||
(getInstanceMethod.ReturnType != typeof (ICustomMarshaler))) {
throw new ApplicationException ($"Custom marshaler '{type.FullName}' does not implement a static GetInstance method that takes a single string parameter and returns an ICustomMarshaler.");
}
Exception exc;
try {
result = (ICustomMarshaler)getInstanceMethod.InternalInvoke (null, new object[] { cookie }, out exc);
} catch (Exception e) {
// FIXME: mscorlib's legacyUnhandledExceptionPolicy is apparently 1,
// so exceptions are thrown instead of being passed through the outparam
exc = e;
result = null;
}
if (exc != null) {
var edi = System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture (exc);
edi.Throw ();
}
if (result == null)
throw new ApplicationException ($"A call to GetInstance() for custom marshaler '{type.FullName}' returned null, which is not allowed.");
lock (MarshalerInstanceCacheLock)
MarshalerInstanceCache[key] = result;
}
return result;
}
}
}

View File

@@ -29,6 +29,7 @@
//
using System;
using System.Runtime.CompilerServices;
namespace System.Runtime.InteropServices {
@@ -44,6 +45,7 @@ namespace System.Runtime.InteropServices {
public string MarshalType;
[ComVisible(true)]
[PreserveDependency ("GetCustomMarshalerInstance", "System.Runtime.InteropServices.Marshal")]
public Type MarshalTypeRef;
public Type SafeArrayUserDefinedSubType;