using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
using System.Security.Permissions;
-
-#if NET_2_0
using System.Runtime.ConstrainedExecution;
-#endif
+using System.Text;
namespace System
{
- [MonoTODO ("Serialization needs tests")]
+ [ComVisible (true)]
[Serializable]
public struct RuntimeMethodHandle : ISerializable
{
if (info == null)
throw new ArgumentNullException ("info");
+ if (value == IntPtr.Zero)
+ throw new SerializationException ("Object fields may not be properly initialized");
+
info.AddValue ("MethodObj", (MonoMethod) MethodBase.GetMethodFromHandle (this), typeof (MonoMethod));
}
return GetFunctionPointer (value);
}
-#if NET_2_0
[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
-#endif
public override bool Equals (object obj)
{
if (obj == null || GetType () != obj.GetType ())
return value == ((RuntimeMethodHandle)obj).Value;
}
-#if NET_2_0
[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
-#endif
public bool Equals (RuntimeMethodHandle handle)
{
return value == handle.Value;
{
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;
+ }
}
}