Xamarin Public Jenkins (auto-signing) ef583813eb Imported Upstream version 6.4.0.137
Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
2019-07-26 19:53:28 +00:00

87 lines
1.9 KiB
C#

using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace System
{
[Serializable]
public readonly struct RuntimeMethodHandle : ISerializable
{
readonly IntPtr value;
internal RuntimeMethodHandle (IntPtr v)
{
value = v;
}
RuntimeMethodHandle (SerializationInfo info, StreamingContext context)
{
throw new PlatformNotSupportedException ();
}
public IntPtr Value => value;
public void GetObjectData (SerializationInfo info, StreamingContext context)
{
throw new PlatformNotSupportedException ();
}
[MethodImpl (MethodImplOptions.InternalCall)]
static extern IntPtr GetFunctionPointer (IntPtr m);
public IntPtr GetFunctionPointer ()
{
return GetFunctionPointer (value);
}
public override bool Equals (object? obj)
{
if (obj == null || GetType () != obj.GetType ())
return false;
return value == ((RuntimeMethodHandle)obj).Value;
}
public bool Equals (RuntimeMethodHandle handle)
{
return value == handle.Value;
}
public override int GetHashCode ()
{
return value.GetHashCode ();
}
public static bool operator == (RuntimeMethodHandle left, RuntimeMethodHandle right)
{
return left.Equals (right);
}
public static bool operator != (RuntimeMethodHandle left, RuntimeMethodHandle right)
{
return !left.Equals (right);
}
internal static string ConstructInstantiation (RuntimeMethodInfo method, TypeNameFormatFlags format)
{
var sb = new StringBuilder ();
var gen_params = method.GetGenericArguments ();
sb.Append ("[");
for (int j = 0; j < gen_params.Length; j++) {
if (j > 0)
sb.Append (",");
sb.Append (gen_params [j].Name);
}
sb.Append ("]");
return sb.ToString ();
}
internal bool IsNullHandle ()
{
return value == IntPtr.Zero;
}
}
}