AOT support
Hi, I'm the guy who maintains NPOI. Enums.NET is really nice. Thank you for the nice work.
I'd like to check if you have plan to support AOT because someone suggests me to get rid of Enums.NET in order to support AOT. But I don't like his idea. I think it's better to check with you first.
Sorry I've never used Enums.NET from an AOT app. Can you explain what things are broken in Enums.NET in an AOT environment? Is there some reflection I'm doing that's not supported?
It looks like I tried addressing AOT support for Unity in https://github.com/TylerBrinkley/Enums.NET/issues/23 but never received feedback if it fixed it.
I'm not an expert of AOT. But as I understand, if you use anything about reflection, then it's not AOT compatible.
Please check this issue: https://github.com/nissl-lab/npoi/pull/1156
It's not so urgent as I don't believe AOT can get popular in a short time. But you can check if it's possible to make Enums.NET AOT compatible.
@karakasa Would you be able to enlighten me on what changes or attributes I should add to add AOT support? Thanks.
The basic steps are as follows:
- Mark the project as AOT compatible for net6+ targets: https://github.com/Singulink/Singulink.Enums/blob/cb3845ea1d2bf4f2d090c44dd77a13668ef7def1/Source/Directory.Build.props#L16-L19
- Add
-windowstargets if you also want to ensure that your library won't have any problems with AOT windows apps. The<CsWinRTAotWarningLevel>element from above ensures that you won't get any runtime marshalling exceptions when using types from your library with WinRT. - Build and observe that you will get a bunch of trim and/or AOT warnings. Iteratively fix all of them until there are no more warnings when you build.
Most of step 3 will likely involve annotating generic type parameters, such as: https://github.com/Singulink/Singulink.Enums/blob/cb3845ea1d2bf4f2d090c44dd77a13668ef7def1/Source/Singulink.Enums/EnumExtensions.cs#L24, but you can get more info on what may be required here: https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming?pivots=dotnet-8-0
@tonyqus Shameless plug for the lib linked above, just released v2 with AOT support if you want something similar to enums.net that is AOT compatible right now.