Skip to content

Commit 07edfec

Browse files
Remove Obsolete APIs (#4968)
* remove SYSLIB0004 warnings by removing obsolete API calls * Remove SYSLIB0005 warnings by removing calls to GAC * Remove SYSLIB0028 warning by replacing call to privatekey by GetRSAPrivateKey * Remove warning SYSLIB0005 for file common with NETFX * Removing SYSLIB0003 warnings * Revert "Removing SYSLIB0003 warnings" This reverts commit e1cd499. * Reverting because of build fail * Fixing build failure due to CER * Fixing as per review comments * Fix as per review comments to throw exception. * Throwing exception when privatekey is null. * Modify C++/CLI files for warnings. * PR feedback * Undo replacement of x509Certificate2.PrivateKey until RC2
1 parent 5555985 commit 07edfec

File tree

20 files changed

+21
-140
lines changed

20 files changed

+21
-140
lines changed

src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/Factory.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
9292
_pFactory = (IDWriteFactory*)factoryTemp;
9393
}
9494

95-
#pragma warning (disable : 4950) // The Constrained Execution Region (CER) feature is not supported.
96-
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
97-
#pragma warning (default : 4950) // The Constrained Execution Region (CER) feature is not supported.
9895
__declspec(noinline) bool Factory::ReleaseHandle()
9996
{
10097
if (_wpfFontCollectionLoader != nullptr)

src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/Factory.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface
7979

8080
protected:
8181

82-
#pragma warning (disable : 4950) // The Constrained Execution Region (CER) feature is not supported.
83-
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
84-
#pragma warning (default : 4950) // The Constrained Execution Region (CER) feature is not supported.
8582
virtual bool ReleaseHandle() override;
8683

8784
internal:

src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/NativePointerWrapper.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface { n
1919
NativePointerCriticalHandle(void* pNativePointer);
2020

2121
virtual property bool IsInvalid
22-
{
23-
#pragma warning (disable : 4950) // The Constrained Execution Region (CER) feature is not supported.
24-
[ReliabilityContract(Consistency::WillNotCorruptState, Cer::Success)]
25-
#pragma warning (default : 4950) // The Constrained Execution Region (CER) feature is not supported.
22+
{
2623
bool get() override;
2724
}
2825

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/Win32/UnsafeNativeMethodsTablet.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,13 @@ private RecognizerSafeHandle(bool ownHandle)
8484
// Do not provide a finalizer - SafeHandle's critical finalizer will
8585
// call ReleaseHandle for you.
8686
public override bool IsInvalid
87-
{
88-
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
89-
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
90-
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
87+
{
9188
get
9289
{
9390
return IsClosed || handle == IntPtr.Zero;
9491
}
9592
}
9693

97-
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
98-
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
99-
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
10094
override protected bool ReleaseHandle()
10195
{
10296
Debug.Assert(handle != IntPtr.Zero);
@@ -126,19 +120,12 @@ private ContextSafeHandle(bool ownHandle)
126120
// call ReleaseHandle for you.
127121
public override bool IsInvalid
128122
{
129-
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
130-
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
131-
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
132123
get
133124
{
134125
return IsClosed || handle == IntPtr.Zero;
135126
}
136127
}
137-
138-
139-
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
140-
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
141-
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
128+
142129
override protected bool ReleaseHandle()
143130
{
144131
//Note: It is not an error to have already called DestroyRecognizer

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/UnsafeNativeMethodsMilCoreApi.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,7 @@ internal static class MILUnknown
524524
[DllImport(DllImport.MilCore, EntryPoint = "MILAddRef")]
525525
internal static extern UInt32 AddRef(SafeReversePInvokeWrapper pIUnknown);
526526

527-
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
528-
[DllImport(DllImport.MilCore, EntryPoint = "MILRelease"), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
529-
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
527+
[DllImport(DllImport.MilCore, EntryPoint = "MILRelease")]
530528

531529
internal static extern int Release(IntPtr pIUnkown);
532530

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AssemblyFilter.cs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,40 +37,7 @@ static AssemblyFilter()
3737

3838
internal void FilterCallback(Object sender, AssemblyLoadEventArgs args)
3939
{
40-
// This code is reentrant
41-
lock (_lock)
42-
{
43-
// Extract assembly
44-
Assembly a = args.LoadedAssembly;
45-
// xmlns cache loads assemblies as reflection only and we cannot inspect these using the code below
46-
// so we ignore also keeping this first is super important because the first time cost is really high
47-
// other wise also we cannot do any processing on a reflection only assembly aside from reflection based actions
48-
if (!a.ReflectionOnly)
49-
{
50-
// check if it is in the Gac , this ensures that we eliminate any non GAC assembly which are of no risk
51-
#pragma warning disable SYSLIB0005 // 'Assembly.GlobalAssemblyCache' is obsolete.
52-
if (a.GlobalAssemblyCache)
53-
#pragma warning restore SYSLIB0005 // 'Assembly.GlobalAssemblyCache' is obsolete.
54-
{
55-
string assemblyName = AssemblyNameWithFileVersion(a);
56-
// If we are on the disallowed list kill the application domain
57-
if (AssemblyOnDisallowedList(assemblyName))
58-
{
59-
// Kill the application domain
60-
UnsafeNativeMethods.ProcessUnhandledException_DLL(SR.Get(SRID.KillBitEnforcedShutdown) + assemblyName);
61-
// I want to ensure that the process really dies
62-
try
63-
{
64-
System.Environment.Exit(-1);
65-
}
66-
finally
67-
{
68-
Debug.Fail("Environment.Exit() failed.");
69-
}
70-
}
71-
}
72-
}
73-
}
40+
/* This method no longer applies to .NET Core and should be removed. */
7441
}
7542

7643
//appends assembly name with file version to generate a unique entry for the assembly lookup process

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourceContainer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,7 @@ private void OnAssemblyLoadEventHandler(object sender, AssemblyLoadEventArgs arg
252252
// We do not care about assemblies loaded into the reflection-only context or the Gaced assemblies.
253253
// For example, in Sparkle whenever a project is built all dependent assemblies will be loaded reflection only.
254254
// We do no care about those. Only when a assembly is loaded into the execution context, we will need to update the cache.
255-
#pragma warning disable SYSLIB0005 // 'Assembly.GlobalAssemblyCache' is obsolete.
256-
if ((!assembly.ReflectionOnly) && (!assembly.GlobalAssemblyCache))
257-
#pragma warning restore SYSLIB0005 // 'Assembly.GlobalAssemblyCache' is obsolete.
255+
if ((!assembly.ReflectionOnly))
258256
{
259257
AssemblyName assemblyInfo = new AssemblyName(assembly.FullName);
260258

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlTypeMapper.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,11 @@ public void SetAssemblyPath(
229229
// so they can be loaded again. The is the Dev build/load/build/load
230230
// Designer scenario. (Don't mess with GACed assemblies)
231231
Assembly assem = ReflectionHelper.GetAlreadyLoadedAssembly(asmName);
232-
#pragma warning disable SYSLIB0005 // 'Assembly.GlobalAssemblyCache' is obsolete.
233-
if (assem != null && !assem.GlobalAssemblyCache)
234-
#pragma warning restore SYSLIB0005 // 'Assembly.GlobalAssemblyCache' is obsolete.
232+
if (assem != null
233+
#if NETFX
234+
&& !assem.GlobalAssemblyCache
235+
#endif
236+
)
235237
{
236238
ReflectionHelper.ResetCacheForAssembly(asmName);
237239
// No way to reset SchemaContext at assembly granularity, so just reset the whole context

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/NativeMethods.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,9 +1389,6 @@ public IntPtr Hwnd
13891389

13901390
private SafeDC() : base(true) { }
13911391

1392-
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
1393-
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
1394-
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
13951392
protected override bool ReleaseHandle()
13961393
{
13971394
if (_created)
@@ -1514,9 +1511,6 @@ internal sealed class SafeHBITMAP : SafeHandleZeroOrMinusOneIsInvalid
15141511
{
15151512
private SafeHBITMAP() : base(true) { }
15161513

1517-
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
1518-
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
1519-
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
15201514
protected override bool ReleaseHandle()
15211515
{
15221516
return NativeMethods.DeleteObject(handle);
@@ -1527,9 +1521,6 @@ internal sealed class SafeGdiplusStartupToken : SafeHandleZeroOrMinusOneIsInvali
15271521
{
15281522
private SafeGdiplusStartupToken() : base(true) { }
15291523

1530-
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
1531-
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
1532-
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
15331524
protected override bool ReleaseHandle()
15341525
{
15351526
Status s = NativeMethods.GdiplusShutdown(this.handle);
@@ -1598,9 +1589,7 @@ public void Disconnect()
15981589
}
15991590

16001591
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
1601-
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
1602-
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
1603-
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
1592+
16041593
protected override bool ReleaseHandle()
16051594
{
16061595
try
@@ -2665,9 +2654,7 @@ public static void DrawMenuBar(IntPtr hWnd)
26652654

26662655
[SuppressMessage("Mricrosoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
26672656
[DllImport("kernel32.dll")]
2668-
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
2669-
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
2670-
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
2657+
26712658
[return: MarshalAs(UnmanagedType.Bool)]
26722659
public static extern bool FindClose(IntPtr handle);
26732660

src/Microsoft.DotNet.Wpf/src/ReachFramework/MS/Internal/Printing/Configuration/UnsafeNativeMethods.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ public static uint PTOpenProviderEx(
7575
/// <param name="handle">device handle proxy has been bound to</param>
7676
/// <returns>HRESULT code</returns>
7777
[DllImport(DllImport.PrntvPt, EntryPoint = "PTCloseProvider", CharSet = CharSet.Unicode, ExactSpelling = true)]
78-
#pragma warning disable SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
79-
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
80-
#pragma warning restore SYSLIB0004 // The Constrained Execution Region (CER) feature is not supported.
78+
8179
public static extern uint PTCloseProviderImpl(IntPtr handle);
8280

8381
/// <summary>

0 commit comments

Comments
 (0)