Skip to content

Remove Obsolete APIs #4968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ 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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface { n
NativePointerCriticalHandle(void* pNativePointer);

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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,13 @@ private RecognizerSafeHandle(bool ownHandle)
// Do not provide a finalizer - SafeHandle's critical finalizer will
// 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);
Expand Down Expand Up @@ -126,19 +120,12 @@ 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;
}
}


#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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,7 @@ 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.
[DllImport(DllImport.MilCore, EntryPoint = "MILRelease")]

internal static extern int Release(IntPtr pIUnkown);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,7 @@ static AssemblyFilter()

internal void FilterCallback(Object sender, AssemblyLoadEventArgs args)
{
// This code is reentrant
lock (_lock)
{
// Extract assembly
Assembly a = args.LoadedAssembly;
// xmlns cache loads assemblies as reflection only and we cannot inspect these using the code below
// so we ignore also keeping this first is super important because the first time cost is really high
// other wise also we cannot do any processing on a reflection only assembly aside from reflection based actions
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
if (AssemblyOnDisallowedList(assemblyName))
{
// Kill the application domain
UnsafeNativeMethods.ProcessUnhandledException_DLL(SR.Get(SRID.KillBitEnforcedShutdown) + assemblyName);
// I want to ensure that the process really dies
try
{
System.Environment.Exit(-1);
}
finally
{
Debug.Fail("Environment.Exit() failed.");
}
}
}
}
}
/* This method no longer applies to .NET Core and should be removed. */
}

//appends assembly name with file version to generate a unique entry for the assembly lookup process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,7 @@ 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.
if ((!assembly.ReflectionOnly))
{
AssemblyName assemblyInfo = new AssemblyName(assembly.FullName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,11 @@ public void SetAssemblyPath(
// 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.
if (assem != null
#if NETFX
&& !assem.GlobalAssemblyCache
#endif
)
{
ReflectionHelper.ResetCacheForAssembly(asmName);
// No way to reset SchemaContext at assembly granularity, so just reset the whole context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1389,9 +1389,6 @@ 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)
Expand Down Expand Up @@ -1514,9 +1511,6 @@ 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);
Expand All @@ -1527,9 +1521,6 @@ 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);
Expand Down Expand Up @@ -1598,9 +1589,7 @@ 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
Expand Down Expand Up @@ -2665,9 +2654,7 @@ 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ public static uint PTOpenProviderEx(
/// <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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,7 @@ private string OemDriverNamespace
CultureInfo.InvariantCulture,
DeviceNamespaceFormat,
BuildInfo.WCP_VERSION_SUFFIX,
#pragma warning disable SYSLIB0013
Uri.EscapeUriString(this._driverName),
#pragma warning restore SYSLIB0013
Uri.EscapeDataString(this._driverName),
this._driverVersion);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,7 @@ 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ 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);
Expand All @@ -285,10 +283,7 @@ internal sealed class IconHandle : WpfSafeHandle
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);
Expand All @@ -314,9 +309,6 @@ 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 );
Expand Down Expand Up @@ -594,9 +586,6 @@ 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ unsafe void QueryCustomPolicy(
/// </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.
[DllImport(ExternDll.Kernel32, SetLastError = true)]
internal static extern IntPtr LocalFree(IntPtr hMem);

#if BASE_NATIVEMETHODS
Expand Down Expand Up @@ -638,9 +636,7 @@ 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)]
Expand All @@ -664,9 +660,6 @@ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// 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

#define GDIEXPORTER
Expand Down Expand Up @@ -101,12 +98,10 @@ ref class GdiSafeHandle : public InteropServices::SafeHandle

property bool IsInvalid
{
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
bool virtual get() override { return IsClosed || (handle == IntPtr::Zero); }
}

protected:
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
bool virtual ReleaseHandle() override
{
IntPtr tempHandle = handle;
Expand Down Expand Up @@ -140,7 +135,6 @@ ref class GdiSafeDCHandle : public GdiSafeHandle
#endif

protected:
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
bool virtual ReleaseHandle() override
{
IntPtr tempHandle = handle;
Expand Down Expand Up @@ -168,7 +162,6 @@ ref class GdiFontResourceSafeHandle : public System::Runtime::InteropServices::S

property bool IsInvalid
{
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
bool virtual get() override { return IsClosed || (handle == IntPtr::Zero); }
}

Expand All @@ -181,7 +174,6 @@ ref class GdiFontResourceSafeHandle : public System::Runtime::InteropServices::S
}

protected:
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
bool virtual ReleaseHandle() override
{
IntPtr tempHandle = handle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,6 @@ 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
{
Expand Down
Loading