Skip to content
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

.NET 6 - System.Drawing.Common is no longer supported on non-Windows systems #929

Open
dstj opened this issue Dec 16, 2021 · 10 comments
Open

Comments

@dstj
Copy link

dstj commented Dec 16, 2021

With .NET 6, System.Drawing.Common become a "Windows-only" dependency.

See this official Microsoft note about the breaking change. They it's mainly because libgdiplus used on Linux systems is "subpar".

SVG uses System.Drawing.Common, thus libgdiplus, so it's having issues with my docker image based on aspnet:6.0-alpine . Any plans to migrate to one of the recommended alternatives?

Recommended action
To use these APIs for cross-platform apps, migrate to one of the following libraries:

ImageSharp
SkiaSharp
Microsoft.Maui.Graphics

--
Sidenote: the reason I got into this is because I have an alignment issue under Linux that I do not have under Windows.

image

The code relies on amountSvgText.Dx = new SvgUnitCollection { new(SvgUnitType.Pixel, CONSTANT - amountSvgText.Bounds.Width) }; and I believe the culprit is libgdiplus.

@Happypig375
Copy link

@mrbean-bremen
Copy link
Member

See also #910.

@dstj
Copy link
Author

dstj commented Dec 30, 2021

Use https://github.com/wieslawsoltes/Svg.Skia

I want to create an SVG from scratch, not render a bitmap from an SVG. Svg.Skia doesn't do that.

@AraHaan
Copy link

AraHaan commented Dec 30, 2021

Likewise I think this code should add an .NET 6 TFM to it that does not reference manually:

  • System.ObjectModel (it already is referenced in Microsoft.NETCore.App)
  • System.Memory (also referenced in Microsoft.NETCore.App)
  • runtime.osx.10.10-x64.CoreCompat.System.Drawing (not needed and I think targeting 6.0 should make it "Windows only" by having the 6.0 tfm be: net6.0-windows)
  • System.Drawing.Common (can be eliminated by having the net6.0-windows target import the WindowsDesktop SDK manually (or have it set UseWindowsForms and/or UseWPF to true when '$(TargetFramework)' == 'net6.0-windows')

So then in the end the 6.0 target would be added to TargetFrameworks only when the build os is Windows and is windows only, imports the Desktop runtime for the 6.0 target and references only Fizzler / other dependencies that themselves have no dependencies.

For me it's annoying having to delete the osx files manually every time I rebuild my windows forms program so a 6.0 target is a must for me on this dependency of it (because I only want the Svg.dll and Fizzler.dll's copied to the compiled output folder).

@mrbean-bremen
Copy link
Member

Likewise I think this code should add an .NET 6 TFM to it that does not reference manually:

It sounds as if you already have done this locally - you may make a PR in this case. If you only use net6.0-windows it would basically mean that 5.0 is (and will be) the last version supported for non-Windows systems. I'm not sure if there are other options, but for now it seems sensible.

CC @wieslawsoltes, @gvheertum

@wieslawsoltes
Copy link
Contributor

The real issue is the removal of System.Drawing.Common breaks a lot of stuff and backwards compatibility and you have re-implement it using something else. See my attempt to just remove the dependency #931

@wieslawsoltes
Copy link
Contributor

I did try today Microsoft.Maui.Graphics with my Svg.Model (base library used by Svg.Skia) to implement basic svg rendering.

I have found several issues in that library: https://github.com/dotnet/Microsoft.Maui.Graphics/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+author%3Awieslawsoltes

The library is not that hard to use but lacks some features and definitely not as powerful as SkiaSharp.

image

@AraHaan
Copy link

AraHaan commented Jan 10, 2022

That looks cool, perhaps that can be split into Svg.Maui, and have the normal Svg package get killed off, with there being an Svg.WinForms which is then Windows only (does not reference the System.Drawing.Common package as it would reference the Windows Forms reference pack implicitly from the .NET Sdk) which would help me out as then I would only get the Svg.WinForms.dll file and the Fizzler dependency copied only so then I do not need to delete the OSX files manually on my program that is Windows only.

Or better yet, have the normal Svg package by itself an ".NET Sdk" that then determines if the program is a Windows Forms or WPF application or not and reference Svg.WinForms or Svg.Maui depending on what it finds.

@wieslawsoltes
Copy link
Contributor

wieslawsoltes commented Jan 12, 2022

That looks cool, perhaps that can be split into Svg.Maui, and have the normal Svg package get killed off, with there being an Svg.WinForms which is then Windows only (does not reference the System.Drawing.Common package as it would reference the Windows Forms reference pack implicitly from the .NET Sdk) which would help me out as then I would only get the Svg.WinForms.dll file and the Fizzler dependency copied only so then I do not need to delete the OSX files manually on my program that is Windows only.

Or better yet, have the normal Svg package by itself an ".NET Sdk" that then determines if the program is a Windows Forms or WPF application or not and reference Svg.WinForms or Svg.Maui depending on what it finds.

The Microsoft.Maui.Graphics is not even close to being ready to use, it's buggy, missing basic features, unreleased and unsupported. Don't get your hopes high, it will take a lot of time until Microsoft.Maui.Graphics is ready maybe even 18 or more months or it can even be canceled.

@wxdlt
Copy link

wxdlt commented May 12, 2022

Due to the problem of memory non release in Linux, when can It release a new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants