#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT
#if FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImpl(MethodImplOptions.InternalCall)]
public extern void DisableComObjectEagerCleanup();
#else // !FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void DisableComObjectEagerCleanup()
{
Debug.Assert(false); // the Thread class in CoreFX should have handled this case
[DllImport(Win32Native.ADVAPI32)]
[SuppressUnmanagedCodeSecurity]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern int RegCloseKey(IntPtr hKey);
}
}
{
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public SafeWaitHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle)
{
SetHandle(existingHandle);
// Class of safe handle which uses 0 or -1 as an invalid handle.
public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
{
}
// Class of safe handle which uses only -1 as an invalid handle.
public abstract class SafeHandleMinusOneIsInvalid : SafeHandle
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected SafeHandleMinusOneIsInvalid(bool ownsHandle) : base(new IntPtr(-1), ownsHandle)
{
}
// Class of critical handle which uses 0 or -1 as an invalid handle.
public abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalHandleZeroOrMinusOneIsInvalid() : base(IntPtr.Zero)
{
}
// Class of critical handle which uses only -1 as an invalid handle.
public abstract class CriticalHandleMinusOneIsInvalid : CriticalHandle
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalHandleMinusOneIsInvalid() : base(new IntPtr(-1))
{
}
[DllImport(Win32Native.KERNEL32, CharSet=System.Runtime.InteropServices.CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern bool FreeLibrary(IntPtr hModule);
}
[DllImport(KERNEL32, EntryPoint="LocalAlloc")]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern IntPtr LocalAlloc_NoSafeHandle(int uFlags, UIntPtr sizetdwBytes);
[DllImport(KERNEL32, SetLastError=true)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern IntPtr LocalFree(IntPtr handle);
// MSDN says the length is a SIZE_T.
[DllImport(NTDLL, EntryPoint = "RtlZeroMemory")]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern void ZeroMemory(IntPtr address, UIntPtr length);
internal static bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX buffer)
// the MemoryFailPoint implementation (within a CER) to increase the
// size of the page file, ignoring any host memory allocators.
[DllImport(KERNEL32, SetLastError=true)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
unsafe internal static extern void * VirtualAlloc(void* address, UIntPtr numBytes, int commitOrReserve, int pageProtectionMode);
[DllImport(KERNEL32, SetLastError=true)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
unsafe internal static extern bool VirtualFree(void* address, UIntPtr numBytes, int pageFreeMode);
[DllImport(KERNEL32, CharSet=CharSet.Ansi, ExactSpelling=true, EntryPoint="lstrlenA")]
internal static extern int lstrlenW(IntPtr ptr);
[DllImport(Win32Native.OLEAUT32, CharSet = CharSet.Unicode)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern IntPtr SysAllocStringLen(String src, int len); // BSTR
[DllImport(Win32Native.OLEAUT32)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern uint SysStringLen(IntPtr bstr);
[DllImport(Win32Native.OLEAUT32)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern void SysFreeString(IntPtr bstr);
#if FEATURE_COMINTEROP
[DllImport(Win32Native.OLEAUT32)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern IntPtr SysAllocStringByteLen(byte[] str, uint len); // BSTR
[DllImport(Win32Native.OLEAUT32)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern uint SysStringByteLen(IntPtr bstr);
#endif
internal static extern SafeWaitHandle OpenEvent(/* DWORD */ int desiredAccess, bool inheritHandle, String name);
[DllImport(KERNEL32, SetLastError=true, CharSet=CharSet.Auto, BestFitMapping=false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern SafeWaitHandle CreateMutex(SECURITY_ATTRIBUTES lpSecurityAttributes, bool initialOwner, String name);
[DllImport(KERNEL32, SetLastError=true, CharSet=CharSet.Auto, BestFitMapping=false)]
internal static extern SafeWaitHandle OpenMutex(/* DWORD */ int desiredAccess, bool inheritHandle, String name);
[DllImport(KERNEL32, SetLastError=true)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern bool ReleaseMutex(SafeWaitHandle handle);
[DllImport(KERNEL32, SetLastError=true)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern bool CloseHandle(IntPtr handle);
[DllImport(KERNEL32, SetLastError=true)]
internal static extern SafeWaitHandle CreateSemaphore(SECURITY_ATTRIBUTES lpSecurityAttributes, int initialCount, int maximumCount, String name);
[DllImport(KERNEL32, SetLastError = true)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool ReleaseSemaphore(SafeWaitHandle handle, int releaseCount, out int previousCount);
WIN32_FIND_DATA lpFindFileData);
[DllImport(KERNEL32)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern bool FindClose(IntPtr handle);
[DllImport(KERNEL32, SetLastError = true, ExactSpelling = true)]
public Int32 Id
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get {
return GetId();
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal extern Int32 GetId();
}
return new ReadOnlyCollection<T>(array);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static void Resize<T>(ref T[] array, int newSize) {
if (newSize < 0)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.newSize, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
// Copies length elements from sourceArray, starting at index 0, to
// destinationArray, starting at index 0.
//
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Copy(Array sourceArray, Array destinationArray, int length)
{
if (sourceArray == null)
// Copies length elements from sourceArray, starting at sourceIndex, to
// destinationArray, starting at destinationIndex.
//
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length)
{
Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length, false);
// instance & might fail when called from within a CER, or if the
// reliable flag is true, it will either always succeed or always
// throw an exception with no side effects.
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable);
// compatible array types based on the array element type - this
// method does not support casting, boxing, or primitive widening.
// It will up-cast, assuming the array types are correct.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length)
{
Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length, true);
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Copy(Array sourceArray, Array destinationArray, long length)
{
if (length > Int32.MaxValue || length < Int32.MinValue)
Array.Copy(sourceArray, destinationArray, (int) length);
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Copy(Array sourceArray, long sourceIndex, Array destinationArray, long destinationIndex, long length)
{
if (sourceIndex > Int32.MaxValue || sourceIndex < Int32.MinValue)
// at index.
//
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern void Clear(Array array, int index, int length);
// The various Get values...
public extern int Length {
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static int GetMedian(int low, int hi) {
// Note both may be negative, if we are dealing with arrays w/ negative lower bounds.
Contract.Requires(low <= hi);
public extern long LongLength {
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
public extern int Rank {
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
get;
}
[Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public extern int GetUpperBound(int dimension);
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int GetLowerBound(int dimension);
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern int GetDataPtrOffsetInternal();
// is larger than the given search value.
//
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int BinarySearch(Array array, Object value) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
// is larger than the given search value.
//
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int BinarySearch(Array array, int index, int length, Object value) {
return BinarySearch(array, index, length, value, null);
}
// is larger than the given search value.
//
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int BinarySearch(Array array, Object value, IComparer comparer) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
// is larger than the given search value.
//
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int BinarySearch(Array array, int index, int length, Object value, IComparer comparer) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private static extern bool TrySZBinarySearch(Array sourceArray, int sourceIndex, int count, Object value, out int retVal);
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int BinarySearch<T>(T[] array, T value) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int BinarySearch<T>(T[] array, T value, System.Collections.Generic.IComparer<T> comparer) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int BinarySearch<T>(T[] array, int index, int length, T value) {
return BinarySearch<T>(array, index, length, value, null);
}
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int BinarySearch<T>(T[] array, int index, int length, T value, System.Collections.Generic.IComparer<T> comparer) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static T[] Empty<T>()
{
Contract.Ensures(Contract.Result<T[]>() != null);
// The array is searched forwards, and the elements of the array are
// compared to the given value using the Object.Equals method.
//
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int IndexOf(Array array, Object value) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
// elements of the array are compared to the given value using the
// Object.Equals method.
//
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int IndexOf(Array array, Object value, int startIndex) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
// elements of the array are compared to the given value using the
// Object.Equals method.
//
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int IndexOf(Array array, Object value, int startIndex, int count) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private static extern bool TrySZIndexOf(Array sourceArray, int sourceIndex, int count, Object value, out int retVal);
// The array is searched backwards, and the elements of the array are
// compared to the given value using the Object.Equals method.
//
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int LastIndexOf(Array array, Object value) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
// startIndex and ending at index 0. The elements of the array are
// compared to the given value using the Object.Equals method.
//
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int LastIndexOf(Array array, Object value, int startIndex) {
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
// the array are compared to the given value using the Object.Equals
// method.
//
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int LastIndexOf(Array array, Object value, int startIndex, int count) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private static extern bool TrySZLastIndexOf(Array sourceArray, int sourceIndex, int count, Object value, out int retVal);
// located at index length - i - 1, where length is the
// length of the array.
//
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Reverse(Array array) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
// index index + (index + count - i - 1).
// Reliability note: This may fail because it may have to box objects.
//
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Reverse(Array array, int index, int length) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
private static extern bool TrySZReverse(Array array, int index, int count);
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Reverse<T>(T[] array)
{
if (array == null)
Reverse(array, 0, array.Length);
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Reverse<T>(T[] array, int index, int length)
{
if (array == null)
// other using the IComparable interface, which must be implemented
// by all elements of the array.
//
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort(Array array) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
// keys to each other using the IComparable interface, which must be
// implemented by all elements of the keys array.
//
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort(Array keys, Array items) {
if (keys==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys);
// elements to each other using the IComparable interface, which
// must be implemented by all elements in the given section of the array.
//
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort(Array array, int index, int length) {
Sort(array, null, index, length, null);
}
// keys to each other using the IComparable interface, which must be
// implemented by all elements of the keys array.
//
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort(Array keys, Array items, int index, int length) {
Sort(keys, items, index, length, null);
}
// IComparable interface, which in that case must be implemented by
// all elements of the array.
//
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort(Array array, IComparer comparer) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
// the IComparable interface, which in that case must be implemented
// by all elements of the keys array.
//
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort(Array keys, Array items, IComparer comparer) {
if (keys==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys);
// the IComparable interface, which in that case must be implemented
// by all elements in the given section of the array.
//
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort(Array array, int index, int length, IComparer comparer) {
Sort(array, null, index, length, comparer);
}
// the IComparable interface, which in that case must be implemented
// by all elements of the given section of the keys array.
//
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort(Array keys, Array items, int index, int length, IComparer comparer) {
if (keys==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
private static extern bool TrySZSort(Array keys, Array items, int left, int right);
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort<T>(T[] array) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
Sort<T>(array, 0, array.Length, null);
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort<TKey, TValue>(TKey[] keys, TValue[] items) {
if (keys==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys);
Sort<TKey, TValue>(keys, items, 0, keys.Length, null);
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort<T>(T[] array, int index, int length) {
Sort<T>(array, index, length, null);
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort<TKey, TValue>(TKey[] keys, TValue[] items, int index, int length) {
Sort<TKey, TValue>(keys, items, index, length, null);
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort<T>(T[] array, System.Collections.Generic.IComparer<T> comparer) {
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
Sort<T>(array, 0, array.Length, comparer);
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort<TKey, TValue>(TKey[] keys, TValue[] items, System.Collections.Generic.IComparer<TKey> comparer) {
if (keys==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys);
Sort<TKey, TValue>(keys, items, 0, keys.Length, comparer);
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort<T>(T[] array, int index, int length, System.Collections.Generic.IComparer<T> comparer) {
if (array==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
}
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort<TKey, TValue>(TKey[] keys, TValue[] items, int index, int length, System.Collections.Generic.IComparer<TKey> comparer) {
if (keys==null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys);
*(src + len) = 0;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal unsafe static void Memcpy(byte[] dest, int destIndex, byte* src, int srcIndex, int len) {
Debug.Assert( (srcIndex >= 0) && (destIndex >= 0) && (len >= 0), "Index and length must be non-negative!");
Debug.Assert(dest.Length - destIndex >= len, "not enough bytes in dest");
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal unsafe static void Memcpy(byte* pDest, int destIndex, byte[] src, int srcIndex, int len)
{
Debug.Assert( (srcIndex >= 0) && (destIndex >= 0) && (len >= 0), "Index and length must be non-negative!");
// 1. This method is given access to other internal dlls and this close to release we do not want to change it.
// 2. It is difficult to get this right for arm and again due to release dates we would like to visit it later.
[FriendAccessAllowed]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#if ARM
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal unsafe static extern void Memcpy(byte* dest, byte* src, int len);
#endif // ARM
// This method has different signature for x64 and other platforms and is done for performance reasons.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal unsafe static void Memmove(byte* dest, byte* src, nuint len)
{
// P/Invoke into the native version when the buffers are overlapping and the copy needs to be performed backwards
// Non-inlinable wrapper around the QCall that avoids poluting the fast path
// with P/Invoke prolog/epilog.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.NoInlining)]
private unsafe static void _Memmove(byte* dest, byte* src, nuint len)
{
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
extern private unsafe static void __Memmove(byte* dest, byte* src, nuint len);
// The attributes on this method are chosen for best JIT performance.
}
// Removes all entries from this hashtable.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public virtual void Clear() {
Debug.Assert(!isWriterInProgress, "Race condition detected in usages of Hashtable - multiple threads appear to be writing to a Hashtable instance simultaneously! Don't do that - use Hashtable.Synchronized.");
version++;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private void rehash( int newsize, bool forceNewHashCode ) {
// reset occupancy
// Inserts an entry into this hashtable. This method is called from the Set
// and Add methods. If the add parameter is true and the given key already
// exists in the hashtable, an exception is thrown.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private void Insert (Object key, Object nvalue, bool add) {
if (key == null) {
throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key"));
// key exists in the hashtable, it is removed. An ArgumentException is
// thrown if the key is null.
//
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public virtual void Remove(Object key) {
if (key == null) {
throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key"));
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static bool IsPrime(int candidate)
{
if ((candidate & 1) != 0)
return (candidate == 2);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static int GetPrime(int min)
{
if (min < 0)
// Compares two Decimal values, returning an integer that indicates their
// relationship.
//
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static int Compare(Decimal d1, Decimal d2) {
return FCallCompare(ref d1, ref d2);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern int FCallCompare(ref Decimal d1, ref Decimal d2);
// Compares this object to another object, returning an integer that
// Returns the larger of two Decimal values.
//
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static Decimal Max(Decimal d1, Decimal d2) {
return FCallCompare(ref d1, ref d2) >= 0? d1: d2;
}
// Returns the smaller of two Decimal values.
//
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static Decimal Min(Decimal d1, Decimal d2) {
return FCallCompare(ref d1, ref d2) < 0? d1: d2;
}
[Conditional("DEBUG")]
[Conditional("CONTRACTS_FULL")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void Assume(bool condition)
{
[Conditional("DEBUG")]
[Conditional("CONTRACTS_FULL")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void Assume(bool condition, String userMessage)
{
[Conditional("DEBUG")]
[Conditional("CONTRACTS_FULL")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void Assert(bool condition)
{
[Conditional("DEBUG")]
[Conditional("CONTRACTS_FULL")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void Assert(bool condition, String userMessage)
{
[Pure]
[Conditional("CONTRACTS_FULL")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void Requires(bool condition)
{
[Pure]
[Conditional("CONTRACTS_FULL")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void Requires(bool condition, String userMessage)
{
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
[Pure]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void Requires<TException>(bool condition) where TException : Exception
{
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
[Pure]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void Requires<TException>(bool condition, String userMessage) where TException : Exception
{
[Pure]
[Conditional("CONTRACTS_FULL")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void Ensures(bool condition)
{
[Pure]
[Conditional("CONTRACTS_FULL")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void Ensures(bool condition, String userMessage)
{
[Conditional("CONTRACTS_FULL")]
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Exception type used in tools.")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void EnsuresOnThrow<TException>(bool condition) where TException : Exception
{
[Conditional("CONTRACTS_FULL")]
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Exception type used in tools.")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void EnsuresOnThrow<TException>(bool condition, String userMessage) where TException : Exception
{
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Not intended to be called at runtime.")]
[Pure]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#endif
public static T Result<T>() { return default(T); }
[SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#", Justification = "Not intended to be called at runtime.")]
[Pure]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#endif
public static T ValueAtReturn<T>(out T value) { value = default(T); return value; }
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
[Pure]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#endif
public static T OldValue<T>(T value) { return default(T); }
[Pure]
[Conditional("CONTRACTS_FULL")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void Invariant(bool condition)
{
[Pure]
[Conditional("CONTRACTS_FULL")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static void Invariant(bool condition, String userMessage)
{
/// <seealso cref="System.Collections.Generic.List<T>.TrueForAll"/>
[Pure]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] // Assumes predicate obeys CER rules.
#endif
public static bool ForAll(int fromInclusive, int toExclusive, Predicate<int> predicate)
{
/// <seealso cref="System.Collections.Generic.List<T>.TrueForAll"/>
[Pure]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] // Assumes predicate & collection enumerator obey CER rules.
#endif
public static bool ForAll<T>(IEnumerable<T> collection, Predicate<T> predicate)
{
/// <seealso cref="System.Collections.Generic.List<T>.Exists"/>
[Pure]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] // Assumes predicate obeys CER rules.
#endif
public static bool Exists(int fromInclusive, int toExclusive, Predicate<int> predicate)
{
/// <seealso cref="System.Collections.Generic.List<T>.Exists"/>
[Pure]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] // Assumes predicate & collection enumerator obey CER rules.
#endif
public static bool Exists<T>(IEnumerable<T> collection, Predicate<T> predicate)
{
/// </summary>
[Conditional("CONTRACTS_FULL")]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#endif
public static void EndContractBlock() { }
[SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")]
[System.Diagnostics.DebuggerNonUserCode]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static string RaiseContractFailedEvent(ContractFailureKind failureKind, String userMessage, String conditionText, Exception innerException)
{
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#endif
public static void TriggerFailure(ContractFailureKind kind, String displayMessage, String userMessage, String conditionText, Exception innerException)
{
[SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")]
[System.Diagnostics.DebuggerNonUserCode]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public static string RaiseContractFailedEvent(ContractFailureKind failureKind, String userMessage, String conditionText, Exception innerException)
{
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#endif
public static void TriggerFailure(ContractFailureKind kind, String displayMessage, String userMessage, String conditionText, Exception innerException)
{
[SuppressMessage("Microsoft.Portability", "CA1903:UseOnlyApiFromTargetedFramework", MessageId = "System.Security.SecuritySafeCriticalAttribute")]
[System.Diagnostics.DebuggerNonUserCode]
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
static partial void ReportFailure(ContractFailureKind failureKind, String userMessage, String conditionText, Exception innerException)
{
internal Exception thrownDuringHandler;
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public ContractFailedEventArgs(ContractFailureKind failureKind, String message, String condition, Exception originalException)
{
}
#if FEATURE_RELIABILITY_CONTRACTS
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
private static String GetDisplayMessage(ContractFailureKind failureKind, String userMessage, String conditionText)
{
}
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public unsafe static bool IsNaN(double d)
{
// Is this thread currently doing infinite resource lookups?
private int infinitelyRecursingCount;
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal String GetResourceString(String key) {
if (key == null || key.Length == 0) {
Debug.Assert(false, "Environment::GetResourceString with null or empty key. Bug in caller, or weird recursive loading problem?");
// Private object for locking instead of locking on a public type for SQL reliability work.
private static Object s_InternalSyncObject;
private static Object InternalSyncObject {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
get {
if (s_InternalSyncObject == null) {
Object o = new Object();
}
public static int CurrentManagedThreadId
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get
{
return Thread.CurrentThread.ManagedThreadId;
private static extern int GetMaxGeneration();
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern int _CollectionCount (int generation, int getSpecialGCCount);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
_Collect(generation, iInternalModes);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static int CollectionCount (int generation)
{
if (generation<0)
// If we insert a call to GC.KeepAlive(this) at the end of Problem(), then
// Foo doesn't get finalized and the stream stays open.
[MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static void KeepAlive(Object obj)
{
}
// Indicates that the system should not call the Finalize() method on
// an object that would normally require this call.
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern void _SuppressFinalize(Object o);
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static void SuppressFinalize(Object obj) {
if (obj == null)
throw new ArgumentNullException(nameof(obj));
// fast way to compare IntPtr to (IntPtr)0 while IntPtr.Zero doesn't work due to slow statics access
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal unsafe bool IsNull()
{
return (this.m_value == null);
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
[System.Runtime.Versioning.NonVersionable]
public unsafe IntPtr(int value)
{
#endif
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
[System.Runtime.Versioning.NonVersionable]
public unsafe IntPtr(long value)
{
}
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
[System.Runtime.Versioning.NonVersionable]
public unsafe IntPtr(void* value)
{
#endif
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public unsafe int ToInt32() {
#if BIT64
#endif
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public unsafe long ToInt64() {
#if BIT64
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
[System.Runtime.Versioning.NonVersionable]
public static explicit operator IntPtr (int value)
{
return new IntPtr(value);
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
[System.Runtime.Versioning.NonVersionable]
public static explicit operator IntPtr (long value)
{
#endif
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public unsafe static bool operator == (IntPtr value1, IntPtr value2)
{
return value1.m_value == value2.m_value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public unsafe static bool operator != (IntPtr value1, IntPtr value2)
{
return value1.m_value != value2.m_value;
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
[System.Runtime.Versioning.NonVersionable]
public static IntPtr Add(IntPtr pointer, int offset)
{
return pointer + offset;
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
[System.Runtime.Versioning.NonVersionable]
public static IntPtr operator +(IntPtr pointer, int offset)
{
#endif
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
[System.Runtime.Versioning.NonVersionable]
public static IntPtr Subtract(IntPtr pointer, int offset) {
return pointer - offset;
}
- [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
[System.Runtime.Versioning.NonVersionable]
public static IntPtr operator -(IntPtr pointer, int offset) {
#if BIT64
public static int Size
{
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
get
{
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public unsafe void* ToPointer()
{
return InternalTruncate(d);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern double Sqrt(double d);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
**Returns the larger of val1 and val2
============================================================================*/
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static sbyte Max(sbyte val1, sbyte val2) {
return (val1>=val2)?val1:val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static byte Max(byte val1, byte val2) {
return (val1>=val2)?val1:val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static short Max(short val1, short val2) {
return (val1>=val2)?val1:val2;
}
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static ushort Max(ushort val1, ushort val2) {
return (val1>=val2)?val1:val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static int Max(int val1, int val2) {
return (val1>=val2)?val1:val2;
}
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static uint Max(uint val1, uint val2) {
return (val1>=val2)?val1:val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static long Max(long val1, long val2) {
return (val1>=val2)?val1:val2;
}
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static ulong Max(ulong val1, ulong val2) {
return (val1>=val2)?val1:val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static float Max(float val1, float val2) {
if (val1 > val2)
return val1;
return val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static double Max(double val1, double val2) {
if (val1 > val2)
return val1;
return val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static Decimal Max(Decimal val1, Decimal val2) {
return Decimal.Max(val1,val2);
}
**Returns the smaller of val1 and val2.
============================================================================*/
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static sbyte Min(sbyte val1, sbyte val2) {
return (val1<=val2)?val1:val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static byte Min(byte val1, byte val2) {
return (val1<=val2)?val1:val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static short Min(short val1, short val2) {
return (val1<=val2)?val1:val2;
}
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static ushort Min(ushort val1, ushort val2) {
return (val1<=val2)?val1:val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static int Min(int val1, int val2) {
return (val1<=val2)?val1:val2;
}
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static uint Min(uint val1, uint val2) {
return (val1<=val2)?val1:val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static long Min(long val1, long val2) {
return (val1<=val2)?val1:val2;
}
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static ulong Min(ulong val1, ulong val2) {
return (val1<=val2)?val1:val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static float Min(float val1, float val2) {
if (val1 < val2)
return val1;
return val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static double Min(double val1, double val2) {
if (val1 < val2)
return val1;
return val2;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static Decimal Min(Decimal val1, Decimal val2) {
return Decimal.Min(val1,val2);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern float Log10(float x);
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static float Max(float x, float y) => Math.Max(x, y);
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static float Min(float x, float y) => Math.Min(x, y);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern float Sinh(float x);
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern float Sqrt(float x);
public class Object
{
// Creates a new instance of an Object.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
[System.Runtime.Versioning.NonVersionable]
public Object()
{
return objA.Equals(objB);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static bool ReferenceEquals (Object objA, Object objB) {
return objA == objB;
// Allow an object to free resources before the object is reclaimed by the GC.
//
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
~Object()
{
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
RuntimeConstructorInfo m = o as RuntimeConstructorInfo;
#endregion
#region Internal Members
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
RuntimeEventInfo m = o as RuntimeEventInfo;
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
RtFieldInfo m = o as RtFieldInfo;
#endregion
#region Internal Members
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
MdFieldInfo m = o as MdFieldInfo;
return sbName.ToString();
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
RuntimeMethodInfo m = o as RuntimeMethodInfo;
#endregion
#region Internal Members
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
RuntimePropertyInfo m = o as RuntimePropertyInfo;
// May replace the list with a new one if certain cache
// lookups succeed. Also, may modify the contents of the list
// after merging these new data structures with cached ones.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal void Insert(ref T[] list, string name, MemberListType listType)
{
bool lockTaken = false;
}
// Modifies the existing list.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private void MergeWithGlobalList(T[] list)
{
T[] cachedMembers = m_allMembers;
internal bool IsGlobal
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get { return m_isGlobal; }
}
#endregion
#region Private\Internal Members
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
RuntimeType m = o as RuntimeType;
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal sealed override RuntimeTypeHandle GetTypeHandleInternal()
{
return new RuntimeTypeHandle(this);
// Note: this method is not part of the CER support, and is not to be confused with ProbeForSufficientStack
// below.
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern void EnsureSufficientExecutionStack();
// This method ensures that there is sufficient stack to execute the average Framework function.
// Note: this method is not part of the CER support, and is not to be confused with ProbeForSufficientStack
// below.
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern bool TryEnsureSufficientExecutionStack();
public static void ProbeForSufficientStack()
// This method is a marker placed immediately before a try clause to mark the corresponding catch and finally blocks as
// constrained. There's no code here other than the probe because most of the work is done at JIT time when we spot a call to this routine.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static void PrepareConstrainedRegions()
{
ProbeForSufficientStack();
// When we detect a CER with no calls, we can point the JIT to this non-probing version instead
// as we don't need to probe.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static void PrepareConstrainedRegionsNoOP()
{
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData);
- [PrePrepareMethod]
internal static void ExecuteBackoutCodeHelper(Object backoutCode, Object userData, bool exceptionThrown)
{
((CleanupCode)backoutCode)(userData, exceptionThrown);
// Returns the exception object pertaining to the first chance exception
public Exception Exception
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get { return m_Exception; }
}
public static GCLatencyMode LatencyMode
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get
{
return (GCLatencyMode)(GC.GetGCLatencyMode());
}
// We don't want to allow this API when hosted.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
set
{
if ((value < GCLatencyMode.Batch) || (value > GCLatencyMode.SustainedLowLatency))
public static GCLargeObjectHeapCompactionMode LargeObjectHeapCompactionMode
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get
{
return (GCLargeObjectHeapCompactionMode)(GC.GetLOHCompactionMode());
}
// We don't want to allow this API when hosted.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
set
{
if ((value < GCLargeObjectHeapCompactionMode.Default) ||
private bool _isClosed; // Set by SetHandleAsInvalid or Close/Dispose/finalization.
// Creates a CriticalHandle class. Users must then set the Handle property or allow P/Invoke marshaling to set it implicitly.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalHandle(IntPtr invalidHandleValue)
{
handle = invalidHandleValue;
// Adding an empty default constructor for annotation purposes
private CriticalHandle(){}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
~CriticalHandle()
{
Dispose(false);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private void Cleanup()
{
if (IsClosed)
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private extern void FireCustomerDebugProbe();
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected void SetHandle(IntPtr handle) {
this.handle = handle;
}
// Returns whether the handle has been explicitly marked as closed
// (Close/Dispose) or invalid (SetHandleAsInvalid).
public bool IsClosed {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get { return _isClosed; }
}
// know what an invalid handle looks like, so this method is abstract and
// must be provided by a derived type.
public abstract bool IsInvalid {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void Close() {
Dispose(true);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void Dispose()
{
Dispose(true);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected virtual void Dispose(bool disposing)
{
Cleanup();
// your handle is invalid and you want to record that information.
// An example is calling a syscall and getting back ERROR_INVALID_HANDLE.
// This method will normally leak handles!
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void SetHandleAsInvalid()
{
_isClosed = true;
// The boolean returned should be true for success and false if a
// catastrophic error occurred and you wish to trigger a diagnostic for
// debugging purposes (the SafeHandleCriticalFailure MDA).
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected abstract bool ReleaseHandle();
}
#endif
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static bool IsNotWin32Atom(IntPtr ptr)
{
#if FEATURE_PAL
/// </summary>
/// <typeparam name="T">Provide a value type to figure out its size</typeparam>
/// <returns>The aligned size of T in bytes.</returns>
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static uint AlignedSizeOf<T>() where T : struct
{
uint size = SizeOfType(typeof(T));
// Type must be a value type with no object reference fields. We only
// assert this, due to the lack of a suitable generic constraint.
[MethodImpl(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern uint SizeOfType(Type type);
// Type must be a value type with no object reference fields. We only
// assert this, due to the lack of a suitable generic constraint.
[MethodImpl(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern uint AlignedSizeOfType(Type type);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
throw new PlatformNotSupportedException();
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static unsafe int ReadInt32(IntPtr ptr, int ofs)
{
try
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static int ReadInt32(IntPtr ptr)
{
return ReadInt32(ptr,0);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static IntPtr ReadIntPtr([MarshalAs(UnmanagedType.AsAny),In] Object ptr, int ofs)
{
#if BIT64
#endif
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static IntPtr ReadIntPtr(IntPtr ptr, int ofs)
{
#if BIT64
#endif
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static IntPtr ReadIntPtr(IntPtr ptr)
{
#if BIT64
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static long ReadInt64(IntPtr ptr)
{
return ReadInt64(ptr,0);
// GetLastWin32Error
//====================================================================
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern int GetLastWin32Error();
// SetLastWin32Error
//====================================================================
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern void SetLastWin32Error(int error);
//====================================================================
// GetHRForLastWin32Error
//====================================================================
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static int GetHRForLastWin32Error()
{
int dwLastError = GetLastWin32Error();
//====================================================================
// Memory allocation and deallocation.
//====================================================================
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static IntPtr AllocHGlobal(IntPtr cb)
{
// For backwards compatibility on 32 bit platforms, ensure we pass values between
return pNewMem;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static IntPtr AllocHGlobal(int cb)
{
return AllocHGlobal((IntPtr)cb);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static void FreeHGlobal(IntPtr hglobal)
{
if (IsNotWin32Atom(hglobal)) {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern int /* ULONG */ AddRef(IntPtr /* IUnknown */ pUnk );
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern int /* ULONG */ Release(IntPtr /* IUnknown */ pUnk );
[MethodImplAttribute(MethodImplOptions.InternalCall)]
/// the pointer from within the SafeBuffer. You must set
/// pointer to null before calling this method.</param>
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public void AcquirePointer(ref byte* pointer)
{
if (_numBytes == Uninitialized)
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void ReleasePointer()
{
if (_numBytes == Uninitialized)
/// may have to consider alignment.</param>
/// <returns>An instance of T read from memory.</returns>
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public T Read<T>(ulong byteOffset) where T : struct {
if (_numBytes == Uninitialized)
throw NotInitialized();
}
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public void ReadArray<T>(ulong byteOffset, T[] array, int index, int count)
where T : struct
{
/// may have to consider alignment.</param>
/// <param name="value">The value type to write to memory.</param>
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public void Write<T>(ulong byteOffset, T value) where T : struct {
if (_numBytes == Uninitialized)
throw NotInitialized();
}
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public void WriteArray<T>(ulong byteOffset, T[] array, int index, int count)
where T : struct
{
/// </summary>
[CLSCompliant(false)]
public ulong ByteLength {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get {
if (_numBytes == Uninitialized)
throw NotInitialized();
/* No indexer. The perf would be misleadingly bad. People should use
* AcquirePointer and ReleasePointer instead. */
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private void SpaceCheck(byte* ptr, ulong sizeInBytes)
{
if ((ulong)_numBytes < sizeInBytes)
NotEnoughRoom();
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static void NotEnoughRoom()
{
throw new ArgumentException(Environment.GetResourceString("Arg_BufferTooSmall"));
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static InvalidOperationException NotInitialized()
{
Debug.Assert(false, "Uninitialized SafeBuffer! Someone needs to call Initialize before using this instance!");
// FCALL limitations mean we can't have generic FCALL methods. However, we can pass
// TypedReferences to FCALL methods.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static void GenericPtrToStructure<T>(byte* ptr, out T structure, uint sizeofT) where T : struct
{
structure = default(T); // Dummy assignment to silence the compiler
}
[MethodImpl(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern void PtrToStructureNative(byte* ptr, /*out T*/ TypedReference structure, uint sizeofT);
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static void GenericStructureToPtr<T>(ref T structure, byte* ptr, uint sizeofT) where T : struct
{
StructureToPtrNative(__makeref(structure), ptr, sizeofT);
}
[MethodImpl(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern void StructureToPtrNative(/*ref T*/ TypedReference structure, byte* ptr, uint sizeofT);
}
}
// Creates a SafeHandle class. Users must then set the Handle property.
// To prevent the SafeHandle from being freed, write a subclass that
// doesn't define a finalizer.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected SafeHandle(IntPtr invalidHandleValue, bool ownsHandle)
{
handle = invalidHandleValue;
Dispose(false);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern void InternalFinalize();
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected void SetHandle(IntPtr handle) {
this.handle = handle;
}
// any way, this can lead to a handle recycling security attack (i.e. an
// untrusted caller can query data on the handle you've just returned
// and get back information for an entirely unrelated resource).
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public IntPtr DangerousGetHandle()
{
return handle;
}
public bool IsClosed {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get { return (_state & 1) == 1; }
}
public abstract bool IsInvalid {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void Close() {
Dispose(true);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void Dispose() {
Dispose(true);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected virtual void Dispose(bool disposing)
{
if (disposing)
InternalFinalize();
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void InternalDispose();
// your handle is invalid and you want to record that information.
// An example is calling a syscall and getting back ERROR_INVALID_HANDLE.
// This method will normally leak handles!
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern void SetHandleAsInvalid();
// The boolean returned should be true for success and false if the runtime
// should fire a SafeHandleCriticalFailure MDA (CustomerDebugProbe) if that
// MDA is enabled.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected abstract bool ReleaseHandle();
// Add a reason why this handle should not be relinquished (i.e. have
// when the method is interrupted prior to processing by a thread abort or
// when the handle has already been (or is in the process of being)
// released.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern void DangerousAddRef(ref bool success);
// constitutes a potential security hole (via handle recycling) as well as a
// correctness problem -- so don't ever expose Dangerous* calls out to
// untrusted code.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern void DangerousRelease();
}
[DllImport(JitHelpers.QCall)]
[SuppressUnmanagedCodeSecurity]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private unsafe extern static void StoreOverlappedPtrInCCW(ObjectHandleOnStack windowsRuntimeBuffer, NativeOverlapped* overlapped);
[FriendAccessAllowed]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal unsafe static void StoreOverlappedInCCW(Object windowsRuntimeBuffer, NativeOverlapped* overlapped) {
StoreOverlappedPtrInCCW(JitHelpers.GetObjectHandleOnStack(ref windowsRuntimeBuffer), overlapped);
GC.SuppressFinalize(this);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private void Dispose(bool disposing)
{
// This is just bookkeeping to ensure multiple threads can really
{
public abstract class CriticalFinalizerObject
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalFinalizerObject()
{
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
~CriticalFinalizerObject()
{
}
return m_type != null ? m_type.GetHashCode() : 0;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public override bool Equals(object obj)
{
if(!(obj is RuntimeTypeHandle))
return handle.m_type == m_type;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public bool Equals(RuntimeTypeHandle handle)
{
return handle.m_type == m_type;
internal extern static RuntimeAssembly GetAssembly(RuntimeType type);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal extern static RuntimeModule GetModule(RuntimeType type);
[CLSCompliant(false)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public ModuleHandle GetModuleHandle()
{
return new ModuleHandle(RuntimeTypeHandle.GetModule(m_type));
return ValueType.GetHashCodeOfPtr(Value);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public override bool Equals(object obj)
{
if (!(obj is RuntimeMethodHandle))
return !left.Equals(right);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public bool Equals(RuntimeMethodHandle handle)
{
return handle.Value == Value;
return ValueType.GetHashCodeOfPtr(Value);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public override bool Equals(object obj)
{
if (!(obj is RuntimeFieldHandle))
return handle.Value == Value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public unsafe bool Equals(RuntimeFieldHandle handle)
{
return handle.Value == Value;
return m_ptr != null ? m_ptr.GetHashCode() : 0;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public override bool Equals(object obj)
{
if (!(obj is ModuleHandle))
return handle.m_ptr == m_ptr;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public unsafe bool Equals(ModuleHandle handle)
{
return handle.m_ptr == m_ptr;
// Stored as a long because we need to use Interlocked.Add.
private long _memFailPointReservedMemory;
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static long AddMemoryFailPointReservation(long size)
{
// Size can legitimately be negative - see Dispose.
}
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public unsafe static bool IsNaN(float f) {
return (*(int*)(&f) & 0x7FFFFFFF) > 0x7F800000;
// Search/Query methods
//
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private unsafe static bool EqualsHelper(String strA, String strB)
{
Contract.Requires(strA != null);
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private unsafe static bool StartsWithOrdinalHelper(String str, String startsWith)
{
Contract.Requires(str != null);
}
// Determines whether two strings match.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public override bool Equals(Object obj)
{
if (this == null) // this is necessary to guard against reverse-pinvokes and
// Determines whether two strings match.
[Pure]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public bool Equals(String value)
{
if (this == null) // this is necessary to guard against reverse-pinvokes and
// Gets a hash code for this string. If strings A and B are such that A.Equals(B), then
// they will return the same hash code.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public override int GetHashCode()
{
#if FEATURE_RANDOMIZED_STRING_HASHING
// Gets a hash code for this string and this comparison. If strings A and B and comparition C are such
// that String.Equals(A, B, C), then they will return the same hash code with this comparison C.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public int GetHashCode(StringComparison comparisonType) => StringComparer.FromComparison(comparisonType).GetHashCode(this);
// Use this if and only if you need the hashcode to not change across app domains (e.g. you have an app domain agile
// hash table).
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal int GetLegacyNonRandomizedHashCode() {
unsafe {
fixed (char* src = &m_firstChar) {
using System.Diagnostics;
using System.Diagnostics.Contracts;
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class AnsiCharMarshaler
{
// The length of the returned array is an approximation based on the length of the input string and the system
}
} // class AnsiCharMarshaler
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class CSTRMarshaler
{
static internal unsafe IntPtr ConvertToNative(int flags, string strManaged, IntPtr pNativeBuffer)
}
} // class CSTRMarshaler
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class UTF8Marshaler
{
const int MAX_UTF8_CHAR_SIZE = 3;
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class UTF8BufferMarshaler
{
static internal unsafe IntPtr ConvertToNative(StringBuilder sb, IntPtr pNativeBuffer, int flags)
#if FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class BSTRMarshaler
{
static internal unsafe IntPtr ConvertToNative(string strManaged, IntPtr pNativeBuffer)
#endif // FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class VBByValStrMarshaler
{
static internal unsafe IntPtr ConvertToNative(string strManaged, bool fBestFit, bool fThrowOnUnmappableChar, ref int cch)
#if FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class AnsiBSTRMarshaler
{
static internal unsafe IntPtr ConvertToNative(int flags, string strManaged)
#endif // FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class WSTRBufferMarshaler
{
static internal IntPtr ConvertToNative(string strManaged)
public Int64 UniversalTime;
};
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class DateTimeOffsetMarshaler {
// Numer of ticks counted between 0001-01-01, 00:00:00 and 1601-01-01, 00:00:00.
#if FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class HStringMarshaler
{
// Slow-path, which requires making a copy of the managed string into the resulting HSTRING
}
} // class HStringMarshaler
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class ObjectMarshaler
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
#endif // FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class ValueClassMarshaler
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static internal extern void ClearNative(IntPtr dst, IntPtr pMT);
} // class ValueClassMarshaler
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class DateMarshaler
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
} // class DateMarshaler
#if FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
[FriendAccessAllowed]
internal static class InterfaceMarshaler
{
#endif // FEATURE_COMINTEROP
#if FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class UriMarshaler
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
}
#endif // FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class MngdNativeArrayMarshaler
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
} // class MngdNativeArrayMarshaler
#if FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class MngdSafeArrayMarshaler
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static internal extern void ClearNative(IntPtr pMarshalState, ref object pManagedHome, IntPtr pNativeHome);
} // class MngdSafeArrayMarshaler
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class MngdHiddenLengthArrayMarshaler
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
#endif // FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class MngdRefCustomMarshaler
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static internal extern void ClearManaged(IntPtr pMarshalState, ref object pManagedHome, IntPtr pNativeHome);
} // class MngdRefCustomMarshaler
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal struct AsAnyMarshaler
{
private const ushort VTHACK_ANSICHAR = 253;
} // struct AsAnyMarshaler
#if FEATURE_COMINTEROP
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class NullableMarshaler
{
static internal IntPtr ConvertToNative<T>(ref Nullable<T> pManaged) where T : struct
internal static extern System.Type GetTypeFromWinRTTypeName(string typeName, out bool isPrimitive);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class SystemTypeMarshaler
{
internal static unsafe void ConvertToNative(System.Type managedType, TypeNameNative *pNativeType)
} // class SystemTypeMarshaler
// For converting WinRT's Windows.Foundation.HResult into System.Exception and vice versa.
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class HResultExceptionMarshaler
{
static internal unsafe int ConvertToNative(Exception ex)
}
} // class HResultExceptionMarshaler
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static class KeyValuePairMarshaler
{
internal static IntPtr ConvertToNative<K, V>([In] ref KeyValuePair<K, V> pair)
public bool m_owned;
} // class CleanupWorkListElement
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal sealed class CleanupWorkList
{
private List<CleanupWorkListElement> m_list = new List<CleanupWorkListElement>();
m_list.Add(elem);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void Destroy()
{
for (int i = m_list.Count - 1; i >= 0; i--)
}
} // class CleanupWorkList
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
[SuppressUnmanagedCodeSecurityAttribute()]
internal static class StubHelpers
{
return SafeHandleAddRef(handle, ref element.m_owned);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
static internal void DestroyCleanupList(ref CleanupWorkList pCleanupWorkList)
{
if (pCleanupWorkList != null)
}
// Releases the SH (to be called from finally block).
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
static internal void SafeHandleRelease(SafeHandle pHandle)
{
if (pHandle == null)
* long
*****************************/
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static int Increment(ref int location)
{
return Add(ref location, 1);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static long Increment(ref long location)
{
return Add(ref location, 1);
* long
*****************************/
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static int Decrement(ref int location)
{
return Add(ref location, -1);
*****************************/
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern int Exchange(ref int location1, int value);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern double Exchange(ref double location1, double value);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern Object Exchange(ref Object location1, Object value);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern IntPtr Exchange(ref IntPtr location1, IntPtr value);
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static T Exchange<T>(ref T location1, T value) where T : class
{
_Exchange(__makeref(location1), __makeref(value));
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern void _Exchange(TypedReference location1, TypedReference value);
/******************************
*****************************/
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern int CompareExchange(ref int location1, int value, int comparand);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern double CompareExchange(ref double location1, double value, double comparand);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern Object CompareExchange(ref Object location1, Object value, Object comparand);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern IntPtr CompareExchange(ref IntPtr location1, IntPtr value, IntPtr comparand);
/*****************************************************************
* for details.
*****************************************************************/
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static T CompareExchange<T>(ref T location1, T value, T comparand) where T : class
{
// _CompareExchange() passes back the value read from location1 via local named 'value'
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern void _CompareExchange(TypedReference location1, TypedReference value, Object comparand);
// BCL-internal overload that returns success via a ref bool param, useful for reliable spin locks.
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern int CompareExchange(ref int location1, int value, int comparand, ref bool succeeded);
/******************************
*****************************/
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern int ExchangeAdd(ref int location1, int value);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern long ExchangeAdd(ref long location1, long value);
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static int Add(ref int location1, int value)
{
return ExchangeAdd(ref location1, value) + value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static long Add(ref long location1, long value)
{
return ExchangeAdd(ref location1, value) + value;
** own the lock.
=========================================================================*/
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern void Exit(Object obj);
/*=========================================================================
{
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public Mutex(bool initiallyOwned, String name, out bool createdNew)
: this(initiallyOwned, name, out createdNew, (MutexSecurity)null)
{
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal unsafe Mutex(bool initiallyOwned, String name, out bool createdNew, MutexSecurity mutexSecurity)
{
if (name == string.Empty)
CreateMutexWithGuaranteedCleanup(initiallyOwned, name, out createdNew, secAttrs);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal void CreateMutexWithGuaranteedCleanup(bool initiallyOwned, String name, out bool createdNew, Win32Native.SECURITY_ATTRIBUTES secAttrs)
{
RuntimeHelpers.CleanupCode cleanupCode = new RuntimeHelpers.CleanupCode(MutexCleanupCode);
Win32Native.SECURITY_ATTRIBUTES m_secAttrs;
Mutex m_mutex;
- [PrePrepareMethod]
internal MutexTryCodeHelper(bool initiallyOwned,MutexCleanupInfo cleanupInfo, String name, Win32Native.SECURITY_ATTRIBUTES secAttrs, Mutex mutex)
{
Debug.Assert(name == null || name.Length != 0);
m_mutex = mutex;
}
- [PrePrepareMethod]
internal void MutexTryCode(object userData)
{
SafeWaitHandle mutexHandle = null;
}
}
- [PrePrepareMethod]
private void MutexCleanupCode(Object userData, bool exceptionThrown)
{
MutexCleanupInfo cleanupInfo = (MutexCleanupInfo) userData;
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public Mutex(bool initiallyOwned, String name) : this(initiallyOwned, name, out dummyBool) {
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public Mutex(bool initiallyOwned) : this(initiallyOwned, null, out dummyBool)
{
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public Mutex() : this(false, null, out dummyBool)
{
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private Mutex(SafeWaitHandle handle)
{
SetHandleInternal(handle);
// Note: To call ReleaseMutex, you must have an ACL granting you
// MUTEX_MODIFY_STATE rights (0x0001). The other interesting value
// in a Mutex's ACL is MUTEX_ALL_ACCESS (0x1F0001).
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public void ReleaseMutex()
{
if (Win32Native.ReleaseMutex(safeWaitHandle))
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
static int CreateMutexHandle(bool initiallyOwned, String name, Win32Native.SECURITY_ATTRIBUTES securityAttribute, out SafeWaitHandle mutexHandle)
{
int errorCode;
// Method called when the CLR does a wait operation
[CLSCompliant(false)]
- [PrePrepareMethod]
public virtual int Wait(IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout)
{
return WaitHelper(waitHandles, waitAll, millisecondsTimeout);
// Method that can be called by Wait overrides
[CLSCompliant(false)]
- [PrePrepareMethod]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected static int WaitHelper(IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout)
{
if (waitHandles == null)
// Static helper to which the above method can delegate to in order to get the default
// COM behavior.
[CLSCompliant(false)]
- [PrePrepareMethod]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private static extern int WaitHelperNative(IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout);
public static void SetSynchronizationContext(SynchronizationContext syncContext)
extern public new int ManagedThreadId
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
get;
}
a explict busy loop because the hardware can be informed that it is busy waiting. */
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern void SpinWaitInternal(int iterations);
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static new void SpinWait(int iterations)
{
SpinWaitInternal(iterations);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern bool YieldInternal();
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static new bool Yield()
{
return YieldInternal();
}
public static new Thread CurrentThread {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
get {
Contract.Ensures(Contract.Result<Thread>() != null);
return GetCurrentThreadNative();
/*=========================================================================
** Clean up the thread when it goes away.
=========================================================================*/
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
~Thread()
{
// Delegate to the unmanaged portion.
InternalFinalize();
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void InternalFinalize();
registeredWaitHandle = handle;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal void SetWaitObject(WaitHandle waitObject)
{
// needed for DangerousAddRef
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal bool Unregister(
WaitHandle waitObject // object to be notified when all callbacks to delegates have completed
)
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private static extern bool BindIOCompletionCallbackNative(IntPtr fileHandle);
}
}
{
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected override bool ReleaseHandle()
{
return DeleteAppDomainTimer(handle);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
static extern bool DeleteAppDomainTimer(IntPtr handle);
#endregion
//
public static class Volatile
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static bool Read(ref bool location)
{
return value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[CLSCompliant(false)]
[System.Runtime.Versioning.NonVersionable]
public static sbyte Read(ref sbyte location)
return value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static byte Read(ref byte location)
{
return value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static short Read(ref short location)
{
return value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[CLSCompliant(false)]
[System.Runtime.Versioning.NonVersionable]
public static ushort Read(ref ushort location)
return value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static int Read(ref int location)
{
return value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[CLSCompliant(false)]
[System.Runtime.Versioning.NonVersionable]
public static uint Read(ref uint location)
}
#if BIT64
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static long Read(ref long location)
{
return value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[CLSCompliant(false)]
[System.Runtime.Versioning.NonVersionable]
public static ulong Read(ref ulong location)
return value;
}
#else
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static long Read(ref long location)
{
//
return Interlocked.CompareExchange(ref location, 0, 0);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[CLSCompliant(false)]
public static ulong Read(ref ulong location)
{
}
#endif
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static IntPtr Read(ref IntPtr location)
{
return value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[CLSCompliant(false)]
[System.Runtime.Versioning.NonVersionable]
public static UIntPtr Read(ref UIntPtr location)
return value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static float Read(ref float location)
{
return value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static double Read(ref double location)
{
return Interlocked.CompareExchange(ref location, 0, 0);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static T Read<T>(ref T location) where T : class
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref bool location, bool value)
{
location = value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[CLSCompliant(false)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref sbyte location, sbyte value)
location = value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref byte location, byte value)
{
location = value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref short location, short value)
{
location = value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[CLSCompliant(false)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref ushort location, ushort value)
location = value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref int location, int value)
{
location = value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[CLSCompliant(false)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref uint location, uint value)
}
#if BIT64
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref long location, long value)
{
location = value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[CLSCompliant(false)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref ulong location, ulong value)
location = value;
}
#else
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static void Write(ref long location, long value)
{
//
Interlocked.Exchange(ref location, value);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[CLSCompliant(false)]
public static void Write(ref ulong location, ulong value)
{
}
#endif
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref IntPtr location, IntPtr value)
{
location = value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[CLSCompliant(false)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref UIntPtr location, UIntPtr value)
location = value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref float location, float value)
{
location = value;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static void Write(ref double location, double value)
{
Interlocked.Exchange(ref location, value);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[System.Runtime.Versioning.NonVersionable]
public static void Write<T>(ref T location, T value) where T : class
{
public SafeWaitHandle SafeWaitHandle
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
get
{
if (safeWaitHandle == null)
return safeWaitHandle;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
set
{
// Set safeWaitHandle and waitHandle in a CER so we won't take
========================================================================*/
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private static extern int WaitMultiple(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext, bool WaitAll);
public static bool WaitAll(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
** (if in a synchronized context) is exited before the wait and reacquired
========================================================================*/
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
{
if (waitHandles==null)
return ret;
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int WaitAny(
WaitHandle[] waitHandles,
TimeSpan timeout,
}
return WaitAny(waitHandles,(int)tm, exitContext);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int WaitAny(WaitHandle[] waitHandles, TimeSpan timeout)
{
return WaitAny(waitHandles, timeout, true);
/*========================================================================
** Shorthand for WaitAny with timeout = Timeout.Infinite and exitContext = true
========================================================================*/
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int WaitAny(WaitHandle[] waitHandles)
{
return WaitAny(waitHandles, Timeout.Infinite, true);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout)
{
return WaitAny(waitHandles, millisecondsTimeout, true);