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

Add support for enum dictionary keys #29

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

VelvetToroyashi
Copy link
Contributor

No description provided.

@@ -117,4 +117,23 @@ public override void Write(Utf8JsonWriter writer, TEnum value, JsonSerializerOpt

writer.WriteStringValue(_enumsToNames[value]);
}

/// <inheritdoc />
public override TEnum ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Copy link
Member

Choose a reason for hiding this comment

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

This is unlikely to work since Read looks for a JsonTokenType of String, but PropertyName is its own TokenType.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. Did this because it's what STJ does, but I can look this over again

Copy link
Member

Choose a reason for hiding this comment

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

Add unit test to verify :P

@VelvetToroyashi
Copy link
Contributor Author

Tests have been added for the new cases, as well as a check for if the current token is a property name

@Nihlus Nihlus merged commit c4b6a44 into Remora:main Mar 19, 2024
2 checks passed
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 this pull request may close these issues.

2 participants