Skip to content
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

Generated serialization code with a custom hook via the CodeGenSerializationAttribute does not pass the ModelReaderWriterOptions parameter #4594

Closed
Tracked by #4490
joseharriaga opened this issue Apr 17, 2024 · 0 comments · Fixed by #4665
Assignees

Comments

@joseharriaga
Copy link
Member

For example, I created my own serialization hook like this:

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void SerializeDataValue(Utf8JsonWriter writer, ModelReaderWriterOptions options)
{
   ...
}

The generator correctly recognizes the hook and uses it in the generated code, but it is not passing the options parameter.

Observed:

void IJsonModel<EmbeddingCollection>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
{
    ...
    writer.WritePropertyName("data"u8);
    SerializeDataValue(writer);
    ...
}

Expected:

void IJsonModel<EmbeddingCollection>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
{
    ...
    writer.WritePropertyName("data"u8);
    SerializeDataValue(writer, options);
    ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants