You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it compatible with AOT compilation?
I’m asking because I see the following warning, for example:
JsonSerializerContext.cs(15,22,15,51): warning SYSLIB1034:
The member 'GeoJSON.Text.Geometry.Point.Type' has been annotated with 'JsonStringEnumConverter' which is not supported in native AOT.
Consider using the generic 'JsonStringEnumConverter<TEnum>' instead.
Reacted by Dmitry Kandiner, Captainpast and Daniel Gekeler
Hi,
yes, I compile the code to native form for both x64 and arm64. For now, I'm running the code with GeoJson without converting it to AOT, but once I finish converting the project that uses it, I plan to deploy native code to the cluster.
Sorry guys, I'm quite busy, will have a look tomorrow
I think I made too many irrelative changes; I will submit PR from other branches.
Key changes to make it AOT compatible:
Pass JsonSerializerOptions down if possible
Use type instead of interface in JsonConverters. Example: PolygonEnumerableConverter should implement JsonConverter<ReadOnlyCollection<Polygon>> instead of JsonConverter<IReadOnlyCollection<Polygon>>
Use JsonStringEnumConverter<T> for NET8 or greater. This is only available after NET8, but it is okay from AOT perspective because AOT is only meaningful after NET8.
For enum members, instead of using EnumMember and use reflection to get lowercase names, just use JsonStringEnumMemberName for NET8 or greater.
Activity
xfischer commentedon May 28, 2025
Hi @stalek71 thanks for reporting.
AOT is not officially supported yet. Is that something you'd be interested in ?
stalek71 commentedon May 28, 2025
Hi,
yes, I compile the code to native form for both x64 and arm64. For now, I'm running the code with GeoJson without converting it to AOT, but once I finish converting the project that uses it, I plan to deploy native code to the cluster.
Captainpast commentedon Sep 23, 2025
AOT should be possible since #31, by writing an own
JsonSerializerContext.But, there is no release containing it.
rabbitism commentedon Dec 6, 2025
https://github.com/irihitech/Irihi.GeoJSON.Text
We spent some time to make this library AOT compatible, there might be some corner cases, but should be production ready for common scenarios.
It's a big change compared to current branch head, maybe you can review first to see if you want to accept my pull request. @xfischer
xfischer commentedon Dec 11, 2025
Sorry guys, I'm quite busy, will have a look tomorrow
rabbitism commentedon Dec 12, 2025
I think I made too many irrelative changes; I will submit PR from other branches.
Key changes to make it AOT compatible:
JsonSerializerOptionsdown if possibleJsonConverter<ReadOnlyCollection<Polygon>>instead ofJsonConverter<IReadOnlyCollection<Polygon>>JsonStringEnumConverter<T>for NET8 or greater. This is only available after NET8, but it is okay from AOT perspective because AOT is only meaningful after NET8.EnumMemberand use reflection to get lowercase names, just useJsonStringEnumMemberNamefor NET8 or greater.