Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to serialize members of base types first #984

Closed
n9 opened this issue Sep 26, 2024 · 2 comments · Fixed by #985
Closed

Option to serialize members of base types first #984

n9 opened this issue Sep 26, 2024 · 2 comments · Fixed by #985

Comments

@n9
Copy link

n9 commented Sep 26, 2024

Is your feature request related to a problem? Please describe.
Members are serialized in the order returned by reflection, with members of base types coming last, which is sometimes not desirable.

Describe the solution you'd like
Remove sealed from ReadablePropertiesTypeInspector and and from ReflectionPropertyDescriptor.

public sealed class ReadablePropertiesTypeInspector : ReflectionTypeInspector

private sealed class ReflectionPropertyDescriptor : IPropertyDescriptor

And extract ReflectionPropertyDescriptor to a top-level class (see Additional context), or make protected.

Describe alternatives you've considered
Copy/paste ReadablePropertiesTypeInspector and tweak the order.

Additional context
WritablePropertiesTypeInspector can be also later refactored to share code with ReadablePropertiesTypeInspector.

public sealed class WritablePropertiesTypeInspector : ReflectionTypeInspector

@EdwardCooke
Copy link
Collaborator

To keep this change simple I'll just remove sealed and make the type protected for now.

n9 pushed a commit to n9/YamlDotNet that referenced this issue Sep 27, 2024
…and WritablePropertiesTypeInspector

+ add virtual method CreateProperty to PropertiesTypeInspector and PropertyInfo to ReflectionPropertyDescriptor for aaubry#984
@n9
Copy link
Author

n9 commented Sep 27, 2024

@EdwardCooke Thank you!

I realized that I still need to copy part of code to achieve ordering (as some members are private). I try to address this by PR: #987

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants