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

Support source generation for struct types #1009

Open
Baka632 opened this issue Nov 27, 2024 · 2 comments
Open

Support source generation for struct types #1009

Baka632 opened this issue Nov 27, 2024 · 2 comments

Comments

@Baka632
Copy link

Baka632 commented Nov 27, 2024

Is your feature request related to a problem? Please describe.
I wish to serialize/deserialize struct types (including readonly struct) when NativeAOT enabled, but when I use my own StaticContext, it throws NotImplementedException.

I checked the output of YamlDotNet.Analyzers.StaticGenerator and found that no code was generated for my struct.

Describe the solution you'd like
Modify source generator to support struct types.

Describe alternatives you've considered
Convert my struct to class, but it's a breaking change.

Additional context
I am using Vecc.YamlDotNet.Analyzers.StaticGenerator for source generation.

@EdwardCooke
Copy link
Collaborator

EdwardCooke commented Nov 28, 2024

We can try adding structs but I don’t know if we’ll be able to in the static serializer. We run into the issues where the compiler prevents things from code compiling due to needing constructors which would take some pretty hefty code changes and wouldn’t be reliable. I think your best bet is creating an IYamlConverter to serialize and deserialize these data types. Shouldn’t be too hard depending on the number of classes your doing.

@Baka632
Copy link
Author

Baka632 commented Nov 28, 2024

Seemed that this is related to #571

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

No branches or pull requests

2 participants