Skip to content

Order of serialized properties determined by dictionary enumeration on fast-path source generators #59043

@eiriktsarpalis

Description

@eiriktsarpalis

Currently, the fast-path source generator will use the TryFilterSerializableProps method to determine the properties that are serializable. The results are returned as a dictionary, which the source generator will enumerate in order to emit the relevant logic.

Note that dictionary enumeration does not provide any guarantees on ordering, as such it is likely that this could end up not honoring the desired serialization order (e.g. as specified by the JsonPropertyOrderAttribute). That being said, the current implementation of System.Collections.Generic.Dictionary happens to preserve ordering due to an implementation detail that may well change in the future. We should update the TryFilterSerializableProps method to provide more robust guarantees on property ordering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Text.JsonenhancementProduct code improvement that does NOT require public API changes/additionshelp wanted[up-for-grabs] Good issue for external contributorssource-generatorIndicates an issue with a source generator feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions