diff options
Diffstat (limited to 'src/mscorlib/src/System/StubHelpers.cs')
-rw-r--r-- | src/mscorlib/src/System/StubHelpers.cs | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/src/mscorlib/src/System/StubHelpers.cs b/src/mscorlib/src/System/StubHelpers.cs index 26a227628a..2d5926b923 100644 --- a/src/mscorlib/src/System/StubHelpers.cs +++ b/src/mscorlib/src/System/StubHelpers.cs @@ -19,7 +19,6 @@ namespace System.StubHelpers { 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 @@ -27,7 +26,8 @@ namespace System.StubHelpers { unsafe static internal byte[] DoAnsiConversion(string str, bool fBestFit, bool fThrowOnUnmappableChar, out int cbLength) { byte[] buffer = new byte[(str.Length + 1) * Marshal.SystemMaxDBCSCharSize]; - fixed (byte *bufferPtr = buffer) + BCLDebug.Assert(buffer.Length != 0); + fixed (byte *bufferPtr = &buffer[0]) { cbLength = str.ConvertToAnsi(bufferPtr, buffer.Length, fBestFit, fThrowOnUnmappableChar); } @@ -53,7 +53,6 @@ namespace System.StubHelpers { } } // class AnsiCharMarshaler - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class CSTRMarshaler { static internal unsafe IntPtr ConvertToNative(int flags, string strManaged, IntPtr pNativeBuffer) @@ -121,7 +120,6 @@ namespace System.StubHelpers { } } // class CSTRMarshaler - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class UTF8Marshaler { const int MAX_UTF8_CHAR_SIZE = 3; @@ -178,7 +176,6 @@ namespace System.StubHelpers { } } - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class UTF8BufferMarshaler { static internal unsafe IntPtr ConvertToNative(StringBuilder sb, IntPtr pNativeBuffer, int flags) @@ -218,7 +215,7 @@ namespace System.StubHelpers { // null argument. char[] cCharBuffer = new char[numChar + 1]; cCharBuffer[numChar] = '\0'; - fixed (char* pBuffer = cCharBuffer) + fixed (char* pBuffer = &cCharBuffer[0]) { numChar = Encoding.UTF8.GetChars((byte*)pNative, nbBytes, pBuffer, numChar); // replace string builder internal buffer @@ -229,7 +226,6 @@ namespace System.StubHelpers { #if FEATURE_COMINTEROP - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class BSTRMarshaler { static internal unsafe IntPtr ConvertToNative(string strManaged, IntPtr pNativeBuffer) @@ -357,7 +353,6 @@ namespace System.StubHelpers { #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) @@ -423,7 +418,6 @@ namespace System.StubHelpers { #if FEATURE_COMINTEROP - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class AnsiBSTRMarshaler { static internal unsafe IntPtr ConvertToNative(int flags, string strManaged) @@ -475,7 +469,6 @@ namespace System.StubHelpers { #endif // FEATURE_COMINTEROP - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class WSTRBufferMarshaler { static internal IntPtr ConvertToNative(string strManaged) @@ -506,7 +499,6 @@ namespace System.StubHelpers { 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. @@ -534,7 +526,6 @@ namespace System.StubHelpers { #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 @@ -597,7 +588,6 @@ namespace System.StubHelpers { } } // class HStringMarshaler - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class ObjectMarshaler { [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -612,7 +602,6 @@ namespace System.StubHelpers { #endif // FEATURE_COMINTEROP - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class ValueClassMarshaler { [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -625,7 +614,6 @@ namespace System.StubHelpers { static internal extern void ClearNative(IntPtr dst, IntPtr pMT); } // class ValueClassMarshaler - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class DateMarshaler { [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -637,7 +625,6 @@ namespace System.StubHelpers { } // class DateMarshaler #if FEATURE_COMINTEROP - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] [FriendAccessAllowed] internal static class InterfaceMarshaler { @@ -657,7 +644,6 @@ namespace System.StubHelpers { #endif // FEATURE_COMINTEROP #if FEATURE_COMINTEROP - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class UriMarshaler { [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -713,7 +699,6 @@ namespace System.StubHelpers { } #endif // FEATURE_COMINTEROP - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class MngdNativeArrayMarshaler { [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -740,7 +725,6 @@ namespace System.StubHelpers { } // class MngdNativeArrayMarshaler #if FEATURE_COMINTEROP - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class MngdSafeArrayMarshaler { [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -762,7 +746,6 @@ namespace System.StubHelpers { 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)] @@ -923,7 +906,6 @@ namespace System.StubHelpers { #endif // FEATURE_COMINTEROP - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class MngdRefCustomMarshaler { [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -942,7 +924,6 @@ namespace System.StubHelpers { 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; @@ -1282,7 +1263,6 @@ namespace System.StubHelpers { } // 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 @@ -1344,7 +1324,6 @@ namespace System.StubHelpers { 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) @@ -1431,7 +1410,6 @@ namespace System.StubHelpers { } // 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) @@ -1469,7 +1447,6 @@ namespace System.StubHelpers { } } // class HResultExceptionMarshaler - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal static class KeyValuePairMarshaler { internal static IntPtr ConvertToNative<K, V>([In] ref KeyValuePair<K, V> pair) @@ -1534,7 +1511,6 @@ namespace System.StubHelpers { public bool m_owned; } // class CleanupWorkListElement - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal sealed class CleanupWorkList { private List<CleanupWorkListElement> m_list = new List<CleanupWorkListElement>(); @@ -1545,7 +1521,6 @@ namespace System.StubHelpers { m_list.Add(elem); } - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public void Destroy() { for (int i = m_list.Count - 1; i >= 0; i--) @@ -1556,7 +1531,6 @@ namespace System.StubHelpers { } } // class CleanupWorkList - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] [SuppressUnmanagedCodeSecurityAttribute()] internal static class StubHelpers { @@ -1593,7 +1567,6 @@ namespace System.StubHelpers { return SafeHandleAddRef(handle, ref element.m_owned); } - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] static internal void DestroyCleanupList(ref CleanupWorkList pCleanupWorkList) { if (pCleanupWorkList != null) @@ -1655,7 +1628,6 @@ namespace System.StubHelpers { } // Releases the SH (to be called from finally block). - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] static internal void SafeHandleRelease(SafeHandle pHandle) { if (pHandle == null) |