1 // System.Runtime.CompilerServices.RuntimeHelpers
3 // Sean MacIsaac (macisaac@ximian.com)
4 // Paolo Molaro (lupus@ximian.com)
6 // (C) Ximian, Inc. 2001
9 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Runtime.ConstrainedExecution;
35 namespace System.Runtime.CompilerServices
40 public sealed class RuntimeHelpers
43 public delegate void TryCode (Object userData);
45 public delegate void CleanupCode (Object userData, bool exceptionThrown);
47 private RuntimeHelpers () {}
49 [MethodImplAttribute(MethodImplOptions.InternalCall)]
50 static extern void InitializeArray (Array array, IntPtr fldHandle);
52 public static void InitializeArray (Array array, RuntimeFieldHandle fldHandle)
54 InitializeArray (array, fldHandle.Value);
57 public static extern int OffsetToStringData {
58 [MethodImpl (MethodImplOptions.InternalCall)]
63 public static int GetHashCode (object o) {
64 return Object.InternalGetHashCode (o);
67 public static new bool Equals (object o1, object o2) {
68 // LAMESPEC: According to MSDN, this is equivalent to
69 // Object::Equals (). But the MS version of Object::Equals()
70 // includes the functionality of ValueType::Equals(), while
71 // our version does not.
74 if ((o1 == null) || (o2 == null))
77 return ValueType.DefaultEquals (o1, o2);
79 return Object.Equals (o1, o2);
83 [MethodImplAttribute(MethodImplOptions.InternalCall)]
84 public static extern object GetObjectValue (object obj);
86 [MethodImplAttribute(MethodImplOptions.InternalCall)]
87 static extern void RunClassConstructor (IntPtr type);
89 public static void RunClassConstructor (RuntimeTypeHandle type)
91 RunClassConstructor (type.Value);
96 public static void ExecuteCodeWithGuaranteedCleanup (TryCode code, CleanupCode backoutCode, Object userData) {
97 throw new NotImplementedException ();
101 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
102 public static void PrepareConstrainedRegions () {
103 throw new NotImplementedException ();
107 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
108 public static void PrepareConstrainedRegionsNoOP () {
109 throw new NotImplementedException ();
113 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
114 public static void ProbeForSufficientStack() {
115 throw new NotImplementedException ();
119 public static void PrepareDelegate (Delegate d) {
121 throw new ArgumentNullException ("d");
122 throw new NotImplementedException ();
126 public static void PrepareMethod (RuntimeMethodHandle method) {
127 throw new NotImplementedException ();
131 public static void PrepareMethod (RuntimeMethodHandle method, RuntimeTypeHandle[] instantiation) {
132 throw new NotImplementedException ();
136 public static void RunModuleConstructor (ModuleHandle module) {
137 throw new NotImplementedException ();