Skip to content

Deserializer should support only getter for IDictionary properties #29391

@steveharter

Description

@steveharter

For objects that expose an IDictionary<,> currently the deserializer requires a public property setter but ideally it should not - it should only require a public getter. The POCO type would create the dictionary itself (likely from within its constructor) and return it from the public getter.

Note that IList<> currently supports this mode of not having a setter.

Implementation support for this is incremental:

  • Add a IsPropertyDictionary to ReadStackFrame
  • Add PopStackOnEndObject to ReadStackFrame and use accordingly in JsonSerializer.HandleStartObject\HandleEndObject
  • Modify ApplyValueToEnumerable to handle the property case.
  • Add tests for this including when there is a public setter but the dictionary is already initialized (we should just use the existing instance)
  • ...

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions