Does YamlDotNet support trimming? #1063
-
Can YamlDotNet be used to deserialize classes with embedded classes (etc.) in apps that will be trimmed? If so, what if anything do I need to do to ensure that I won't have problems with things like constructors being trimmed (which I ran into with NewtonsoftJson)? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Yes it does. You’ll need to use the static builders and the Vecc yamldotnet static serializer nuget package. |
Beta Was this translation helpful? Give feedback.
-
There are some limitations though. The classes need to be public or internal along with the constructors. Constructors need to also be parameter less. Properties and fields also need to be internal or public. I don’t think record classes work either. One second and I’ll send you the tests around it so you can see how to do it |
Beta Was this translation helpful? Give feedback.
-
https://github.com/aaubry/YamlDotNet/blob/master/YamlDotNet.Core7AoTCompileTest/Program.cs Is a complete example of it. It references the static project directly which is packaged up into that Vecc nuget package. |
Beta Was this translation helpful? Give feedback.
-
https://www.nuget.org/packages/Vecc.YamlDotNet.Analyzers.StaticGenerator |
Beta Was this translation helpful? Give feedback.
-
The answer is yes, but not with generics (#1023). The min repro I made before searching issues: |
Beta Was this translation helpful? Give feedback.
The answer is yes, but not with generics (#1023).
The min repro I made before searching issues:
YamlGenericStaticFail.zip