Fix ReturnType property deserialization in System.Text.Json #37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
ReturnTypeproperty onMethodDescriptionwas causingSystem.ArgumentException: 'Property set method not found.'during JSON deserialization with System.Text.Json.Problem
When deserializing JSON containing method definitions with explicit return types:
[{ "FullName": "Example.Class", "Methods": [{ "Name": "GetAllAsync", "ReturnType": "System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.IActionResult>" }] }]The deserialization would fail because:
ReturnTypeproperty was read-only (getter only)JsonDefaults.csattempted to set values on properties with[DefaultValue]attributesSolution
Minimal changes applied:
Fixes an issue with JSON deserialization of the ReturnType property by making it internally settable and refining how default values are applied.
Verification
ReturnTypevalues now deserialize correctlyReturnTypestill defaults to"void"as expectedThe fix ensures backward compatibility while enabling proper deserialization of method return type information from JSON.
Fixes #38.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.