Skip to content

Commit

Permalink
Add type-forwarders for Xamarin.Android compatibility to System.Drawi…
Browse files Browse the repository at this point in the history
…ng.Common.dll (#82839)

The legacy Xamarin.Android version of System.Drawing.Common.dll contained these types, add forwarders so we don't get a TypeLoadException when using an assembly compiled against that in modern .NET Android.

Fixes #82829
  • Loading branch information
akoeplinger committed Mar 8, 2023
1 parent fbb3a12 commit e486f38
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 1 deletion.
147 changes: 146 additions & 1 deletion src/libraries/System.Drawing.Common/src/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,151 @@
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
<Right>lib/net462/System.Drawing.Common.dll</Right>
</Suppression>
<!-- the following suppression are for back-compatibility with legacy Xamarin which had these types in System.Drawing.Common.dll -->
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.Color</Target>
<Left>ref/net6.0/System.Drawing.Common.dll</Left>
<Right>lib/net6.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.KnownColor</Target>
<Left>ref/net6.0/System.Drawing.Common.dll</Left>
<Right>lib/net6.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.Point</Target>
<Left>ref/net6.0/System.Drawing.Common.dll</Left>
<Right>lib/net6.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.PointF</Target>
<Left>ref/net6.0/System.Drawing.Common.dll</Left>
<Right>lib/net6.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.Rectangle</Target>
<Left>ref/net6.0/System.Drawing.Common.dll</Left>
<Right>lib/net6.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.RectangleF</Target>
<Left>ref/net6.0/System.Drawing.Common.dll</Left>
<Right>lib/net6.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.Size</Target>
<Left>ref/net6.0/System.Drawing.Common.dll</Left>
<Right>lib/net6.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.SizeF</Target>
<Left>ref/net6.0/System.Drawing.Common.dll</Left>
<Right>lib/net6.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.Color</Target>
<Left>ref/net7.0/System.Drawing.Common.dll</Left>
<Right>lib/net7.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.KnownColor</Target>
<Left>ref/net7.0/System.Drawing.Common.dll</Left>
<Right>lib/net7.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.Point</Target>
<Left>ref/net7.0/System.Drawing.Common.dll</Left>
<Right>lib/net7.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.PointF</Target>
<Left>ref/net7.0/System.Drawing.Common.dll</Left>
<Right>lib/net7.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.Rectangle</Target>
<Left>ref/net7.0/System.Drawing.Common.dll</Left>
<Right>lib/net7.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.RectangleF</Target>
<Left>ref/net7.0/System.Drawing.Common.dll</Left>
<Right>lib/net7.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.Size</Target>
<Left>ref/net7.0/System.Drawing.Common.dll</Left>
<Right>lib/net7.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.SizeF</Target>
<Left>ref/net7.0/System.Drawing.Common.dll</Left>
<Right>lib/net7.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.Color</Target>
<Left>ref/net8.0/System.Drawing.Common.dll</Left>
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.KnownColor</Target>
<Left>ref/net8.0/System.Drawing.Common.dll</Left>
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.Point</Target>
<Left>ref/net8.0/System.Drawing.Common.dll</Left>
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.PointF</Target>
<Left>ref/net8.0/System.Drawing.Common.dll</Left>
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.Rectangle</Target>
<Left>ref/net8.0/System.Drawing.Common.dll</Left>
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.RectangleF</Target>
<Left>ref/net8.0/System.Drawing.Common.dll</Left>
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.Size</Target>
<Left>ref/net8.0/System.Drawing.Common.dll</Left>
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.SizeF</Target>
<Left>ref/net8.0/System.Drawing.Common.dll</Left>
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:System.Drawing.Imaging.Encoder.ColorSpace</Target>
Expand Down Expand Up @@ -96,4 +241,4 @@
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
<Right>lib/net462/System.Drawing.Common.dll</Right>
</Suppression>
</Suppressions>
</Suppressions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// This is required for back-compatibility with legacy Xamarin which had these types in System.Drawing.Common.dll
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.Color))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.ColorTranslator))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.KnownColor))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.Point))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.PointF))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.Rectangle))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.RectangleF))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.Size))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.SizeF))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.SystemColors))]
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<Compile Include="SRDescriptionAttribute.cs" />
<Compile Include="System.Drawing.Common.Forwards.cs" />
<Compile Include="System\Drawing\Bitmap.cs" />
<Compile Include="System\Drawing\BitmapSuffixInSameAssemblyAttribute.cs" />
<Compile Include="System\Drawing\BitmapSuffixInSatelliteAssemblyAttribute.cs" />
Expand Down

0 comments on commit e486f38

Please sign in to comment.