-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Enum decorated with [JsonStringEnumMemberName] fails to deserialize #106406
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis |
Thanks. Any chance you could distil this to a minimal repro? 🙏 |
I'll give it a whirl tomorrow. This was a very end-of-day I'll just give this a quick try...oh no kinda thing. |
Hello @martincostello according to the example #74385 you need to add |
@Ilchert Thanks, that was it. I'd incorrectly assumed I didn't need it anymore and completely removed my converter attribute, rather than just change it to not use my custom converter. |
Would it make sense to infer the string-based converter based on the presence of the new attribute? I'm not sure what the right approach should be here. |
That would certainly help guide people towards the pit of success. I hadn't seen any specific documentation or example of using the new attribute, I just saw the API diff adding entry and thought "oh I know where I could use that" and got over-agressive with the deleting forgetting the default behaviour would have been to treat it as an |
Description
I saw
[JsonStringEnumMemberName]
in the API diff for .NET 9 preview 7 and thought I'd try it out as I have a custom converter to deal withSCREAMING_SNAKE_CASE
at the moment in an application, so it should simplify things.On updating the code however, one of my tests fails due to deserialization failing.
I can't see an obvious reason why - the test case contains the value
"USER_INITIATED"
, which matches the code.Reproduction Steps
build.ps1
in the root of the repository.Expected behavior
The tests pass and enum values are correctly (de)serialized.
Actual behavior
An exception is thrown by the Can_Deserialize_Request test:
Regression?
No - new functionality.
Known Workarounds
None.
Configuration
9.0.100-preview.7.24407.12
9.0.0-preview.7.24405.7
Other information
No response
The text was updated successfully, but these errors were encountered: