Skip to content

Add (experimental) native AOT support #8530

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

Merged
merged 1 commit into from
May 22, 2025
Merged

Add (experimental) native AOT support #8530

merged 1 commit into from
May 22, 2025

Conversation

flobernd
Copy link
Member

As titled.

@@ -36,6 +36,11 @@ protected override (string ResolvedUrl, string UrlTemplate, Dictionary<string, s
[JsonConverter(typeof(SearchRequestOfTConverterFactory))]
public partial class SearchRequest<TInferDocument> : SearchRequest
{
static SearchRequest()
{
DynamicallyAccessed.PublicConstructors(typeof(SearchRequestOfTConverter<TInferDocument>));
Copy link
Member Author

@flobernd flobernd May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might have to generate this for all generic types that are using converter factories to make Activator.CreateInstance succeed even when T is a value type (e.g. if the user for some reason uses struct for top level documents).

@flobernd flobernd requested a review from Mpdreamz May 22, 2025 09:10
@flobernd flobernd marked this pull request as ready for review May 22, 2025 09:10
Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, can't wait to give it a spin!

[JsonSerializable(typeof(ushort))]
[JsonSerializable(typeof(ushort?))]
[JsonSerializable(typeof(object))]
[JsonSerializable(typeof(string))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suprised this is needed in the transport we do the following:

https://github.com/elastic/elastic-transport-net/blob/main/src/Elastic.Transport/Components/Serialization/LowLevelRequestResponseSerializer.cs#L40-L42

To get all the defaults attached to our JsonSerializerContext

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nullable value types don't work out of the box with the combined DefaultJsonTypeInfoResolver. The other ones probably would work, but since this behavior is a bit of a blackbox to me, I rather define all these types explicitly.

@flobernd flobernd merged commit 4117107 into main May 22, 2025
21 of 24 checks passed
@flobernd flobernd deleted the native-aot branch May 22, 2025 10:10
github-actions bot pushed a commit that referenced this pull request May 22, 2025
flobernd added a commit that referenced this pull request May 22, 2025
Co-authored-by: Florian Bernd <git@flobernd.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants