Fix break from moving to new Cpp toolset: Constrained Execution Region feature, Assembly.GlobalAssemblyCache, BinaryFormatter, etc.

This commit is contained in:
Ryland Alaniz 2020-08-14 14:30:30 -07:00
Родитель a57b4fa8b3
Коммит dc7669ed16
27 изменённых файлов: 93 добавлений и 0 удалений

Просмотреть файл

@ -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 @@ namespace MS.Win32.Recognizer
// 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 @@ namespace MS.Win32.Recognizer
// 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 @@ namespace MS.Win32.Recognizer
}
#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 @@ namespace MS.Win32.PresentationCore
[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 @@ namespace System.Windows
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 @@ namespace System.Windows
}
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 @@ namespace MS.Internal
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 @@ namespace MS.Internal.AppModel
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 @@ namespace MS.Internal.AppModel
// 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 @@ namespace MS.Internal.AppModel
{
// 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 @@ namespace MS.Internal.AppModel
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 @@ namespace MS.Internal.Navigation
/// Overridden InitializeLifetimeService method
/// </summary>
/// <returns></returns>
[ObsoleteAttribute("InitializeLifetimeService is obsolete.", false)]
public override object InitializeLifetimeService()
{
return _stream.InitializeLifetimeService();

Просмотреть файл

@ -229,7 +229,9 @@ namespace System.Windows.Markup
// 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 @@ namespace Standard
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 @@ namespace Standard
{
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 @@ namespace Standard
{
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 @@ namespace Standard
}
[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 @@ namespace Standard
[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 @@ namespace MS.Internal.Printing.Configuration
/// <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 @@ namespace MS.Internal
/// <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 @@ namespace MS.Win32
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 @@ namespace MS.Win32
{
}
#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 @@ namespace MS.Win32
{
}
#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 @@ namespace MS.Win32
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 @@ namespace MS.Win32
/// </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 @@ namespace MS.Win32
}
}
[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 @@ namespace MS.Win32
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

Просмотреть файл

@ -1,6 +1,9 @@
// 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 @@ using System.Windows.Markup;
[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 @@ namespace MS.Internal.Automation
}
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 @@ namespace System.Windows.Automation
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 @@ namespace System.Windows.Automation
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 @@ namespace MS.Internal.AutomationProxies
}
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 @@ using System.Windows.Markup;
[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 @@ using System.Windows.Markup;
[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 @@ namespace System.Windows.Threading
/// <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 @@ namespace System.Windows.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 @@ namespace MS.Win32
}
[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);
}