StbSharp / StbImageSharp

C# port of the stb_image.h
237 stars 21 forks source link

"readonly" breaks C# 5 standard. #25

Closed stromkos closed 1 month ago

stromkos commented 2 months ago

There are three instances of the readonly keyword not compatable with the console version requirements.

See https://github.com/MonoGame/MonoGame/issues/8459#issuecomment-2308668408

Adding readonly simply stops the reference from changing outside of a constructor. It is mostly useless on reference types.

Please disable the IDE0044 warning, so Visual Studio stops complaining and offering to "correct" this non-issue. #pragma warning disable IDE0044

rds1983 commented 2 months ago

I'll reference this issue to those asking why StbImageSharp uses so ancient C# standard. :) Anyway, feel free to make the PR replacing readonly with, say, readonly properties.

JakeLegendXIII commented 1 month ago

Unfortunately even updating the automatic readonly properties to make it C# 5 compatible still leaves the generated code that uses stackalloc initializers in the Png, Jpg, and Tga files which is C# 7.3... It starts flagging those once you make the first set of updates. Those are a bit riskier to change.

Edit: turns out those might not be too bad either since it is only the initialization and I have the older generated code. Might submit a PR :)

rds1983 commented 1 month ago

Should be fixed. Thanks @JakeLegendXIII!