Fix JSON deserialization crash by adding JsonStringEnumConverter#30
Fix JSON deserialization crash by adding JsonStringEnumConverter#30dmcrider merged 2 commits intopatch/2025-01from
Conversation
Co-authored-by: dmcrider <9904609+dmcrider@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a critical crash on mod load caused by System.Text.Json being unable to deserialize string enum values without explicit configuration. The fix adds JsonStringEnumConverter to enable proper conversion of season strings (e.g., "spring") to their corresponding Season enum values.
- Added
JsonStringEnumConverterto deserialization options inLoadBaseGameCrops() - Added the required
using System.Text.Json.Serializationdirective
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot Does this fix need to be applied to loading crop files for other mods? |
No, the fix is not needed for loading mod crops. The |
Mod crashes on load with
JsonExceptionwhen deserializingCrops.jsonbecauseSystem.Text.Jsoncannot convert string enum values without explicit configuration.Changes
JsonStringEnumConverterto deserialization options inLoadBaseGameCrops()using System.Text.Json.SerializationdirectiveThis allows the deserializer to convert
"spring"→Season.springfor theSeasonsproperty.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.