提交 dc7669ed 编写于 作者: R Ryland Alaniz

Fix break from moving to new Cpp toolset: Constrained Execution Region...

Fix break from moving to new Cpp toolset: Constrained Execution Region feature, Assembly.GlobalAssemblyCache, BinaryFormatter, etc.
上级 a57b4fa8
......@@ -92,7 +92,9 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
_pFactory = (IDWriteFactory*)factoryTemp;
}
#pragma warning (disable : 4950) // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
#pragma warning (default : 4950) // The Constrained Execution Region (CER) feature is not supported.
__declspec(noinline) bool Factory::ReleaseHandle()
{
if (_wpfFontCollectionLoader != nullptr)
......
......@@ -79,7 +79,9 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
protected:
#pragma warning (disable : 4950) // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
#pragma warning (default : 4950) // The Constrained Execution Region (CER) feature is not supported.
virtual bool ReleaseHandle() override;
internal:
......@@ -221,7 +223,9 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
virtual property bool IsInvalid
{
#pragma warning (disable : 4950) // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
#pragma warning (default : 4950) // The Constrained Execution Region (CER) feature is not supported.
bool get() override;
}
};
......
......@@ -20,7 +20,9 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface { n
virtual property bool IsInvalid
{
#pragma warning (disable : 4950) // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
#pragma warning (default : 4950) // The Constrained Execution Region (CER) feature is not supported.
bool get() override;
}
......@@ -35,7 +37,9 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface { n
{
protected:
#pragma warning (disable : 4950) // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
#pragma warning (default : 4950) // The Constrained Execution Region (CER) feature is not supported.
virtual bool ReleaseHandle() override;
public:
......@@ -47,7 +51,9 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface { n
{
protected:
#pragma warning (disable : 4950) // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
#pragma warning (default : 4950) // The Constrained Execution Region (CER) feature is not supported.
virtual bool ReleaseHandle() override;
public:
......
......@@ -85,14 +85,18 @@ private RecognizerSafeHandle(bool ownHandle)
// call ReleaseHandle for you.
public override bool IsInvalid
{
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
get
{
return IsClosed || handle == IntPtr.Zero;
}
}
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
override protected bool ReleaseHandle()
{
Debug.Assert(handle != IntPtr.Zero);
......@@ -122,7 +126,9 @@ private ContextSafeHandle(bool ownHandle)
// call ReleaseHandle for you.
public override bool IsInvalid
{
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
get
{
return IsClosed || handle == IntPtr.Zero;
......@@ -130,7 +136,9 @@ public override bool IsInvalid
}
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
override protected bool ReleaseHandle()
{
//Note: It is not an error to have already called DestroyRecognizer
......
......@@ -524,7 +524,10 @@ internal static class MILUnknown
[DllImport(DllImport.MilCore, EntryPoint = "MILAddRef")]
internal static extern UInt32 AddRef(SafeReversePInvokeWrapper pIUnknown);
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[DllImport(DllImport.MilCore, EntryPoint = "MILRelease"), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
internal static extern int Release(IntPtr pIUnkown);
internal static void ReleaseInterface(ref IntPtr ptr)
......
......@@ -1768,7 +1768,9 @@ private int SaveObjectToHandle(IntPtr handle, Object data, bool doNotReallocate)
formatter = new BinaryFormatter();
#pragma warning disable SYSLIB0011 // BinaryFormatter is obsolete
formatter.Serialize(stream, data);
#pragma warning restore SYSLIB0011 // BinaryFormatter is obsolete
return SaveStreamToHandle(handle, stream, doNotReallocate);
}
}
......@@ -3122,7 +3124,9 @@ private Object ReadObjectFromHandle(IntPtr handle, bool restrictDeserialization)
}
try
{
#pragma warning disable SYSLIB0011 // BinaryFormatter is obsolete
value = formatter.Deserialize(stream);
#pragma warning restore SYSLIB0011 // BinaryFormatter is obsolete
}
catch (RestrictedTypeDeserializationException)
{
......
......@@ -48,7 +48,9 @@ internal void FilterCallback(Object sender, AssemblyLoadEventArgs args)
if (!a.ReflectionOnly)
{
// check if it is in the Gac , this ensures that we eliminate any non GAC assembly which are of no risk
#pragma warning disable SYSLIB0005 // 'Assembly.GlobalAssemblyCache' is obsolete.
if (a.GlobalAssemblyCache)
#pragma warning restore SYSLIB0005 // 'Assembly.GlobalAssemblyCache' is obsolete.
{
string assemblyName = AssemblyNameWithFileVersion(a);
// If we are on the disallowed list kill the application domain
......
......@@ -109,7 +109,9 @@ private Uri GetEntryAssemblyLocation()
try
{
#pragma warning disable // Type or member is obsolete
entryLocation = new Uri(Application.ResourceAssembly.CodeBase);
#pragma warning restore // Type or member is obsolete
}
catch (Exception ex)
{
......
......@@ -252,7 +252,9 @@ private void OnAssemblyLoadEventHandler(object sender, AssemblyLoadEventArgs arg
// We do not care about assemblies loaded into the reflection-only context or the Gaced assemblies.
// For example, in Sparkle whenever a project is built all dependent assemblies will be loaded reflection only.
// We do no care about those. Only when a assembly is loaded into the execution context, we will need to update the cache.
#pragma warning disable SYSLIB0005 // 'Assembly.GlobalAssemblyCache' is obsolete.
if ((!assembly.ReflectionOnly) && (!assembly.GlobalAssemblyCache))
#pragma warning restore SYSLIB0005 // 'Assembly.GlobalAssemblyCache' is obsolete.
{
AssemblyName assemblyInfo = new AssemblyName(assembly.FullName);
......
......@@ -126,7 +126,9 @@ private ArrayList SaveSubStreams(UIElement element)
{
// Convert the value of the DP into a byte array
MemoryStream byteStream = new MemoryStream();
#pragma warning disable SYSLIB0011 // BinaryFormatter is obsolete
this.Formatter.Serialize(byteStream, currentValue);
#pragma warning restore SYSLIB0011 // BinaryFormatter is obsolete
bytes = byteStream.ToArray();
// Dispose the stream
......@@ -236,7 +238,9 @@ private void LoadSubStreams(UIElement element, ArrayList subStreams)
object newValue = null;
if (subStream._data != null)
{
#pragma warning disable SYSLIB0011 // BinaryFormatter is obsolete
newValue = this.Formatter.Deserialize(new MemoryStream(subStream._data));
#pragma warning restore SYSLIB0011 // BinaryFormatter is obsolete
}
element.SetValue(dp, newValue);
}
......
......@@ -291,6 +291,7 @@ public new Type GetType()
/// Overridden InitializeLifetimeService method
/// </summary>
/// <returns></returns>
[ObsoleteAttribute("InitializeLifetimeService is obsolete.", false)]
public override object InitializeLifetimeService()
{
return _stream.InitializeLifetimeService();
......
......@@ -229,7 +229,9 @@ public XamlTypeMapper(string[] assemblyNames)
// so they can be loaded again. The is the Dev build/load/build/load
// Designer scenario. (Don't mess with GACed assemblies)
Assembly assem = ReflectionHelper.GetAlreadyLoadedAssembly(asmName);
#pragma warning disable SYSLIB0005 // 'Assembly.GlobalAssemblyCache' is obsolete.
if (assem != null && !assem.GlobalAssemblyCache)
#pragma warning restore SYSLIB0005 // 'Assembly.GlobalAssemblyCache' is obsolete.
{
ReflectionHelper.ResetCacheForAssembly(asmName);
// No way to reset SchemaContext at assembly granularity, so just reset the whole context
......
......@@ -1389,7 +1389,9 @@ public IntPtr Hwnd
private SafeDC() : base(true) { }
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
protected override bool ReleaseHandle()
{
if (_created)
......@@ -1512,7 +1514,9 @@ internal sealed class SafeHBITMAP : SafeHandleZeroOrMinusOneIsInvalid
{
private SafeHBITMAP() : base(true) { }
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
protected override bool ReleaseHandle()
{
return NativeMethods.DeleteObject(handle);
......@@ -1523,7 +1527,9 @@ internal sealed class SafeGdiplusStartupToken : SafeHandleZeroOrMinusOneIsInvali
{
private SafeGdiplusStartupToken() : base(true) { }
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
protected override bool ReleaseHandle()
{
Status s = NativeMethods.GdiplusShutdown(this.handle);
......@@ -1592,7 +1598,9 @@ public void Disconnect()
}
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
protected override bool ReleaseHandle()
{
try
......@@ -2657,7 +2665,9 @@ public static void DrawMenuBar(IntPtr hWnd)
[SuppressMessage("Mricrosoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("kernel32.dll")]
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FindClose(IntPtr handle);
......
......@@ -76,7 +76,9 @@ internal static class UnsafeNativeMethods
/// <param name="handle">device handle proxy has been bound to</param>
/// <returns>HRESULT code</returns>
[DllImport(DllImport.PrntvPt, EntryPoint = "PTCloseProvider", CharSet = CharSet.Unicode, ExactSpelling = true)]
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
public static extern uint PTCloseProviderImpl(IntPtr handle);
/// <summary>
......
......@@ -299,7 +299,9 @@ public NonPumpingSynchronizationContext()
/// <summary>
/// Wait for a set of handles.
/// </summary>
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[PrePrepareMethod]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
public override int Wait(IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout)
{
return MS.Win32.UnsafeNativeMethods.WaitForMultipleObjectsEx(waitHandles.Length, waitHandles, waitAll, millisecondsTimeout, false);
......
......@@ -258,7 +258,9 @@ private BitmapHandle() : this(true)
private BitmapHandle(bool ownsHandle) : base(ownsHandle, NativeMethods.CommonHandles.GDI)
{
}
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
protected override bool ReleaseHandle()
{
return UnsafeNativeMethods.DeleteObject(handle);
......@@ -284,7 +286,9 @@ private IconHandle() : base(true, NativeMethods.CommonHandles.Icon)
{
}
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
protected override bool ReleaseHandle()
{
return UnsafeNativeMethods.DestroyIcon(handle);
......@@ -310,7 +314,9 @@ private CursorHandle() : base(true, NativeMethods.CommonHandles.Cursor)
{
}
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
protected override bool ReleaseHandle()
{
return UnsafeNativeMethods.DestroyCursor( handle );
......@@ -588,7 +594,9 @@ protected override bool ReleaseHandle()
return (LocalFree(base.handle) == IntPtr.Zero);
}
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[DllImport("kernel32.dll")]
private static extern IntPtr LocalFree(IntPtr hMem);
}
......
......@@ -170,7 +170,9 @@ internal interface IInternetSecurityManager
/// </summary>
/// <param name="hMem"></param>
/// <returns></returns>
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[DllImport(ExternDll.Kernel32, SetLastError = true), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
internal static extern IntPtr LocalFree(IntPtr hMem);
#if BASE_NATIVEMETHODS
......@@ -636,7 +638,9 @@ internal static void SetWindowText(HandleRef hWnd, string text)
}
}
[DllImport(ExternDll.User32, EntryPoint = "GetIconInfo", CharSet = CharSet.Auto, SetLastError = true)]
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
private static extern bool GetIconInfoImpl(HandleRef hIcon, [Out] ICONINFO_IMPL piconinfo);
[StructLayout(LayoutKind.Sequential)]
......@@ -660,7 +664,9 @@ internal static void GetIconInfo(HandleRef hIcon, out NativeMethods.ICONINFO pic
piconinfo = new NativeMethods.ICONINFO();
ICONINFO_IMPL iconInfoImpl = new ICONINFO_IMPL();
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
SRCS.RuntimeHelpers.PrepareConstrainedRegions(); // Mark the following as special
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
try
{
// Intentionally empty
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// Turn off CER warnings: The Constrained Execution Region (CER) feature is not supported.
#pragma warning (disable : 4950)
#ifndef GDIEXPORTER
......
......@@ -6,6 +6,10 @@
#ifndef __INTEROPPRINTERHANDLER_HPP__
#define __INTEROPPRINTERHANDLER_HPP__
// Turn off CER warnings: The Constrained Execution Region (CER) feature is not supported.
#pragma warning (disable : 4950)
/*++
Abstract:
......
......@@ -14,7 +14,9 @@
[assembly:Dependency("System.Xml,", LoadHint.Sometimes)]
[assembly: TypeForwardedTo(typeof(System.Xaml.Permissions.XamlAccessLevel))]
#pragma warning disable SYSLIB0003 // Type or member is obsolete
[assembly: TypeForwardedTo(typeof(System.Xaml.Permissions.XamlLoadPermission))]
#pragma warning restore SYSLIB0003 // Type or member is obsolete
[assembly: TypeForwardedTo(typeof(System.Windows.Markup.ValueSerializerAttribute))]
[assembly:XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", "System.Windows.Markup")]
......@@ -503,7 +503,9 @@ internal static int TryMsgWaitForMultipleObjects(SafeWaitHandle handle, bool wai
}
else
{
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
RuntimeHelpers.PrepareConstrainedRegions();
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
bool fRelease = false;
try
{
......
......@@ -44,7 +44,9 @@ internal static SafeConditionMemoryHandle AllocateConditionHandle(object uiaCond
SafeConditionMemoryHandle sh = new SafeConditionMemoryHandle();
int size = Marshal.SizeOf(uiaCondition);
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
RuntimeHelpers.PrepareConstrainedRegions(); // ensures that the following finally block is atomic
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
try { }
finally
{
......@@ -64,7 +66,9 @@ internal static SafeConditionMemoryHandle AllocateConditionArrayHandle(Condition
int intPtrSize = Marshal.SizeOf(typeof(IntPtr));
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
RuntimeHelpers.PrepareConstrainedRegions(); // ensures that the following finally block is atomic
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
try { }
finally
{
......
......@@ -995,7 +995,9 @@ internal static int MsgWaitForMultipleObjects(SafeWaitHandle handle, bool waitAl
}
else
{
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
RuntimeHelpers.PrepareConstrainedRegions();
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
bool fRelease = false;
try
{
......
......@@ -85,6 +85,7 @@
[assembly:TypeForwardedTo(typeof(System.IO.Packaging.PackageRelationshipSelector))]
[assembly:TypeForwardedTo(typeof(System.IO.Packaging.PackageRelationshipSelectorType))]
#pragma warning disable SYSLIB0003 // Type or member is obsolete
[assembly: TypeForwardedTo(typeof(System.Security.Permissions.MediaPermissionAudio))]
[assembly: TypeForwardedTo(typeof(System.Security.Permissions.MediaPermissionVideo))]
[assembly: TypeForwardedTo(typeof(System.Security.Permissions.MediaPermissionImage))]
......@@ -93,6 +94,7 @@
[assembly: TypeForwardedTo(typeof(System.Security.Permissions.WebBrowserPermissionLevel))]
[assembly: TypeForwardedTo(typeof(System.Security.Permissions.WebBrowserPermission))]
[assembly: TypeForwardedTo(typeof(System.Security.Permissions.WebBrowserPermissionAttribute))]
#pragma warning restore SYSLIB0003 // Type or member is obsolete
[assembly: TypeForwardedTo(typeof(System.Collections.ObjectModel.ReadOnlyObservableCollection<>))]
[assembly: TypeForwardedTo(typeof(System.Collections.ObjectModel.ObservableCollection<>))]
......
......@@ -89,7 +89,9 @@ public override void Post(SendOrPostCallback d, Object state)
/// <summary>
/// Wait for a set of handles.
/// </summary>
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[PrePrepareMethod]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
public override int Wait(IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout)
{
if(_dispatcher._disableProcessingCount > 0)
......
......@@ -1881,7 +1881,9 @@ public sealed partial class DispatcherSynchronizationContext : System.Threading.
public override System.Threading.SynchronizationContext CreateCopy() { throw null; }
public override void Post(System.Threading.SendOrPostCallback d, object state) { }
public override void Send(System.Threading.SendOrPostCallback d, object state) { }
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[System.Runtime.ConstrainedExecution.PrePrepareMethodAttribute]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
public override int Wait(System.IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout) { throw null; }
}
public partial class DispatcherTimer
......
......@@ -52,7 +52,9 @@ public static DCSafeHandle CreateDC(string lpszDriver)
}
[DllImport(ExternDll.Gdi32, ExactSpelling = true, CharSet = CharSet.Auto)]
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
[ResourceExposure(ResourceScope.None)]
public static extern bool DeleteDC(IntPtr hDC);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册