Skip to content

Commit f94d65e

Browse files
authored
[release/6.0] Move 2 Drawing APIs that are not implemented in netfx to netcoreapp3.1 or later (#60371)
1 parent 80b7531 commit f94d65e

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

src/libraries/System.Drawing.Common/ref/System.Drawing.Common.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,12 +596,16 @@ public void Flush(System.Drawing.Drawing2D.FlushIntention intention) { }
596596
public static System.Drawing.Graphics FromImage(System.Drawing.Image image) { throw null; }
597597
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
598598
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
599+
#if NETCOREAPP3_1_OR_GREATER
599600
[System.ObsoleteAttribute("Use the Graphics.GetContextInfo overloads that accept arguments for better performance and fewer allocations.", DiagnosticId = "SYSLIB0016", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
601+
#endif
600602
public object GetContextInfo() { throw null; }
603+
#if NETCOREAPP3_1_OR_GREATER
601604
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
602605
public void GetContextInfo(out PointF offset) { throw null; }
603606
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
604607
public void GetContextInfo(out PointF offset, out Region? clip) { throw null; }
608+
#endif
605609
public static System.IntPtr GetHalftonePalette() { throw null; }
606610
public System.IntPtr GetHdc() { throw null; }
607611
public System.Drawing.Color GetNearestColor(System.Drawing.Color color) { throw null; }

src/libraries/System.Drawing.Common/src/CompatibilitySuppressions.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3-
<Suppression>
4-
<DiagnosticId>CP0002</DiagnosticId>
5-
<Target>M:System.Drawing.Graphics.GetContextInfo(System.Drawing.PointF@)</Target>
6-
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
7-
<Right>lib/net461/System.Drawing.Common.dll</Right>
8-
</Suppression>
9-
<Suppression>
10-
<DiagnosticId>CP0002</DiagnosticId>
11-
<Target>M:System.Drawing.Graphics.GetContextInfo(System.Drawing.PointF@,System.Drawing.Region@)</Target>
12-
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
13-
<Right>lib/net461/System.Drawing.Common.dll</Right>
14-
</Suppression>
153
<Suppression>
164
<DiagnosticId>CP0001</DiagnosticId>
175
<Target>T:System.Drawing.FontConverter</Target>

src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Unix.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ public object GetContextInfo()
583583
throw new NotImplementedException();
584584
}
585585

586+
#if NETCOREAPP3_1_OR_GREATER
586587
[EditorBrowsable(EditorBrowsableState.Never)]
587588
[SupportedOSPlatform("windows")]
588589
public void GetContextInfo(out PointF offset)
@@ -596,6 +597,7 @@ public void GetContextInfo(out PointF offset, out Region? clip)
596597
{
597598
throw new PlatformNotSupportedException();
598599
}
600+
#endif
599601

600602
private void CheckErrorStatus(int status)
601603
{

src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Windows.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,9 @@ public unsafe void EnumerateMetafile(
684684
/// WARNING: This method is for internal FX support only.
685685
/// </summary>
686686
[EditorBrowsable(EditorBrowsableState.Never)]
687+
#if NETCOREAPP3_1_OR_GREATER
687688
[Obsolete(Obsoletions.GetContextInfoMessage, DiagnosticId = Obsoletions.GetContextInfoDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
689+
#endif
688690
[SupportedOSPlatform("windows")]
689691
public object GetContextInfo()
690692
{
@@ -763,6 +765,7 @@ private void GetContextInfo(out Matrix3x2 cumulativeTransform, bool calculateCli
763765
}
764766
}
765767

768+
#if NETCOREAPP3_1_OR_GREATER
766769
/// <summary>
767770
/// Gets the cumulative offset.
768771
/// </summary>
@@ -789,6 +792,7 @@ public void GetContextInfo(out PointF offset, out Region? clip)
789792
Vector2 translation = cumulativeTransform.Translation;
790793
offset = new PointF(translation.X, translation.Y);
791794
}
795+
#endif
792796

793797
public RectangleF VisibleClipBounds
794798
{

src/libraries/System.Drawing.Common/src/misc/GDI/WindowsGraphics.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public static WindowsGraphics FromGraphics(Graphics g, ApplyGraphicsProperties p
6161
{
6262
Region? clip = null;
6363

64+
#if NETCOREAPP3_1_OR_GREATER
6465
if (properties.HasFlag(ApplyGraphicsProperties.Clipping))
6566
{
6667
g.GetContextInfo(out offset, out clip);
@@ -69,6 +70,21 @@ public static WindowsGraphics FromGraphics(Graphics g, ApplyGraphicsProperties p
6970
{
7071
g.GetContextInfo(out offset);
7172
}
73+
#else
74+
Matrix? worldTransf = null;
75+
if (g.GetContextInfo() is object[] data && data.Length == 2)
76+
{
77+
if (properties.HasFlag(ApplyGraphicsProperties.Clipping))
78+
{
79+
clip = data[0] as Region;
80+
}
81+
worldTransf = data[1] as Matrix;
82+
if (worldTransf != null)
83+
{
84+
offset = worldTransf.Offset;
85+
}
86+
}
87+
#endif
7288

7389
if (clip is not null)
7490
{

0 commit comments

Comments
 (0)