1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 using System
.Reflection
;
6 using System
.Runtime
.CompilerServices
;
7 using System
.Runtime
.Serialization
;
12 public struct RuntimeFieldHandle
: ISerializable
14 readonly IntPtr
value;
16 internal RuntimeFieldHandle (IntPtr v
)
21 RuntimeFieldHandle (SerializationInfo info
, StreamingContext context
)
23 throw new PlatformNotSupportedException ();
26 public void GetObjectData (SerializationInfo info
, StreamingContext context
)
28 throw new PlatformNotSupportedException ();
37 internal bool IsNullHandle ()
39 return value == IntPtr
.Zero
;
42 public override bool Equals (object? obj
)
44 if (obj
== null || GetType () != obj
.GetType ())
47 return value == ((RuntimeFieldHandle
)obj
).Value
;
50 public bool Equals (RuntimeFieldHandle handle
)
52 return value == handle
.Value
;
55 public override int GetHashCode ()
57 return value.GetHashCode ();
60 public static bool operator == (RuntimeFieldHandle left
, RuntimeFieldHandle right
)
62 return left
.Equals (right
);
65 public static bool operator != (RuntimeFieldHandle left
, RuntimeFieldHandle right
)
67 return !left
.Equals (right
);
70 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
71 static extern void SetValueInternal (FieldInfo fi
, object obj
, object value);
73 internal static void SetValue (RuntimeFieldInfo field
, Object obj
, Object
value, RuntimeType fieldType
, FieldAttributes fieldAttr
, RuntimeType declaringType
, ref bool domainInitialized
)
75 SetValueInternal (field
, obj
, value);
78 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
79 static unsafe extern internal Object
GetValueDirect (RuntimeFieldInfo field
, RuntimeType fieldType
, void *pTypedRef
, RuntimeType contextType
);
81 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
82 static unsafe extern internal void SetValueDirect (RuntimeFieldInfo field
, RuntimeType fieldType
, void* pTypedRef
, Object
value, RuntimeType contextType
);