You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Been using Tomlyn in my product and it's working well, but I was writing some tests and came across a speed bump.
It'd be nifty if we could use something like the following to generate "ad-hoc" TOML content for my tests. I use a similar pattern for JSON:
varcargoToml= Toml.FromModel(new{ package =new{ name ="pkgname", version ="1.0.0"}});
This doesn't work though, because the properties of anonymous types are generated as get-only, and StandardObjectDynamicAccessor.Initialize() specifically filters out get-only properties. cargoToml in that example ends up being "[package]\r\n". I think that filtering makes sense for ToModel, but it's kind of inconvenient in scenarios where I'm only generating TOML with FromModel but not parsing it.
I know I can work around with the following, but the anonymous-types version is just a bit more concise:
Been using Tomlyn in my product and it's working well, but I was writing some tests and came across a speed bump.
It'd be nifty if we could use something like the following to generate "ad-hoc" TOML content for my tests. I use a similar pattern for JSON:
This doesn't work though, because the properties of anonymous types are generated as get-only, and
StandardObjectDynamicAccessor.Initialize()
specifically filters out get-only properties.cargoToml
in that example ends up being"[package]\r\n"
. I think that filtering makes sense for ToModel, but it's kind of inconvenient in scenarios where I'm only generating TOML with FromModel but not parsing it.I know I can work around with the following, but the anonymous-types version is just a bit more concise:
The text was updated successfully, but these errors were encountered: