diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextHdcScope.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextHdcScope.cs index d5d95a10521..cbac0de403c 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextHdcScope.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextHdcScope.cs @@ -146,8 +146,10 @@ public unsafe DeviceContextHdcScope( bool applyTransform = applyGraphicsState.HasFlag(ApplyGraphicsProperties.TranslateTransform); bool applyClipping = applyGraphicsState.HasFlag(ApplyGraphicsProperties.Clipping); +#pragma warning disable SYSLIB0016 // Type or member is obsolete // This API is very expensive and cannot be called after GetHdc() object[]? data = applyTransform || applyClipping ? (object[])graphics.GetContextInfo() : null; +#pragma warning restore SYSLIB0016 // Type or member is obsolete using Region? clipRegion = (Region?)data?[0]; using Matrix? worldTransform = (Matrix?)data?[1]; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/DrawingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/DrawingEventArgs.cs index fe1868bf8a6..779b6e5b3d1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/DrawingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/DrawingEventArgs.cs @@ -156,8 +156,10 @@ internal static void CheckGraphicsForState(Graphics? graphics, DrawingEventFlags return; } +#pragma warning disable SYSLIB0016 // Type or member is obsolete // Check to see if we've actually corrupted the state object[] data = (object[])graphics.GetContextInfo(); +#pragma warning restore SYSLIB0016 // Type or member is obsolete using Region clipRegion = (Region)data[0]; using Matrix worldTransform = (Matrix)data[1];