ClassiCube / MCGalaxy

A Minecraft Classic / ClassiCube server software
GNU General Public License v3.0
162 stars 76 forks source link

In dotnet build, System.Drawing has issues on non-Windows #720

Closed UnknownShadow200 closed 1 year ago

UnknownShadow200 commented 1 year ago

https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only https://github.com/dotnet/designs/blob/main/accepted/2021/system-drawing-win-only/system-drawing-win-only.md https://github.com/dotnet/dotnet-docker/blob/main/documentation/scenarios/using-system-drawing-common.md

Need to decide the best way of handling this

(not the end of the world though, since it only breaks /imgprint and Heightmap world generation theme)

forkiesassds commented 1 year ago

The only alternatives they recommend using are all 3rd party libraries. And all of them don't support .NET Framework 4.0, which means the version used has to be bumped or a whole entire module just for .NET 6+ has to be made.

UnknownShadow200 commented 1 year ago

The only parts of System.Drawing that core MCGalaxy depends on is decoding/resizing/accessing images, so it's not a huge burden to add an abstraction layer for just that

I'm still deciding between whether it's better to a) Always Pinvoke libgdiplus directly on macOS/Linux (both mono and dotnet) b) dotnet build always uses a third party library (on all OSes)

(As for why a), although unlikely to occur, turns out that when running on mono, if you have System.Drawing but are missing libgdiplus, trying to do /imprint will crash the server)

UnknownShadow200 commented 1 year ago

Fixed by 522260da587ca64f629893a404a2332b4dec84cd

Also found a workaround, so that server doesn't crash when you have System.Drawing but are missing libgdiplus