Repository navigation
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsFixes: #78098 Consider for servicing because it makes properties without setter not usable with new
|
There was a problem hiding this comment.
I think this check could be moved inside the InitializePropertyCache method to avoid iterating over the items yet again.
There was a problem hiding this comment.
Unfortunately not in current state because we initialize constructor parameter cache after InitializePropertyCache is called which means we can't check for that correctly in here because we don't know which ones are initialized as part parametrized constructor. It would need likely quite a bit of refactoring to move this logic - probably makes more sense to do that refactoring as part of adding parametrized constructors to the public contract.
There was a problem hiding this comment.
Then this check could be moved inside JsonPropertyInfo.Configure with all the other propertyInfo-level validations.
There was a problem hiding this comment.
as I mentioned here: #78152 (comment) unfortunately that can't be move (at least not in the current state of the code), the ordering is following and each step depends on the previous:
- we initialize properties
- we initialize ctor parameters
- we check required properties used correctly
if I moved last step to first one we wouldn't know about which property is constructor parameter and be back to original bug
There was a problem hiding this comment.
IsWritable sounds kind of ambiguous when compared with CanDeserialize. Given that it's only being called in one place I think you could simply inline CanDeserialize || IsConstructorParameter to make it more clear what is being checked?
There was a problem hiding this comment.
I initially done it this way but I ended up splitting it because I eventually want to fix #77307 which will need similar property.
There was a problem hiding this comment.
Do we really need this method? IsConstructorParameter has a private setter so we can assume that the assert invariant is preserved.
There was a problem hiding this comment.
This is called from JsonTypeInfo.CreateConstructorParameter - I prefer to have it here rather than making IsConstructorParameter internal - this way I can add extra check and make sure it's not going to be misused in the future.
|
Per feedback in #78098 (comment), I don't think this meets the bar for servicing. I'm not entirely convinced that we should be supporting That being said, there clearly is a gap in functionality when it comes to specifying required constructor parameters (currently, STJ will pass We also need to be careful about what the relationship between |
|
@krwq please do not add |
|
@krwq I'm putting this into Draft status since it's accumulated some merge conflicts and it might be easier to start with a fresh PR when we return to this. |
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
|
Reopen? :) |
|
I'll focus on this PR after #78556 |
|
@krwq should we close this? We can revisit constructor parameters overall in the next release. |
|
Yeah, let's go ahead and close it for revisiting in net9. |
Fixes: #78098
Fixes following scenario: