serilog-settings-configuration icon indicating copy to clipboard operation
serilog-settings-configuration copied to clipboard

Annotate Serilog.Settings.Configuration as not trim-compatible

Open agocke opened this issue 1 year ago • 4 comments

Unfortunately I don't have any good news for this library. It looks like the fundamental concept, loading arbitrary types by name from arbitrary assemblies, configured by the user at run-time, is fundamentally incompatible with trimming and AOT.

This at least marks it as such. Supporting a feature set like the one provided here would likely require a source generator, or build-time code generation phase.

agocke avatar Mar 31 '23 21:03 agocke

PolySharp is currently missing RequiresAssemblyFiles (https://github.com/Sergio0694/PolySharp/issues/65) but the author is very responsive, so I'll wait for them to add it and then I'll pull in a new version.

agocke avatar Apr 05 '23 23:04 agocke

I should also mention -- it's worth considering if this space should have an AOT-compatible solution. I think a source generator would probably be necessary.

agocke avatar Apr 05 '23 23:04 agocke

@agocke just thinking about:

I should also mention -- it's worth considering if this space should have an AOT-compatible solution. I think a source generator would probably be necessary.

Would this have much benefit over just relying on the C# configuration API? (The C# API can still pull values from appsettings.json directly, where parameters need to vary at deployment time..)

nblumhardt avatar May 05 '23 00:05 nblumhardt

This is a good point -- I was thinking that theoretically you could use a source generator to parse the file, and then construct an equivalent graph at compile time. But that would create a potentially confusing situation where people may believe they can change the file after deployment and get different behavior -- and they can't. Making this a code-only configuration system seems like the right idea.

agocke avatar May 05 '23 21:05 agocke