It's a lot less ergonomic but there are source generators in C# :

https://devblogs.microsoft.com/dotnet/introducing-c-source-g...

That said, for more complex results, you'd typically load a serialization on start.

I can see the value in this tool, but there must be a fairly limited niche which is too expensive to just have as static and run on start-up and cache, but not so large you'd prefer to just serialize, store and load.

It also needs to be something that is dynamic at compile time but not at runtime.

So it's very niche, but it's an interesting take on the concept, and it looks easier to use than the default source generators.

> there are source generators

Last time I tried them discovered source generators in the current .NET 10 SDK are broken beyond repair, because Microsoft does not support dependencies between source generators.

Want to auto-generate COM proxies or similar? Impossible because library import and export are implemented with another source generators. Want to generate something JSON serializable? Impossible because in modern .NET JSON serializer is implemented with another source generator. Generate regular expressions? Another SDK provided source generator, as long as you want good runtime performance.

You can source generate JSON serdes from your own source generator but you do need to generate the jsontypeinfo metadata yourself.

Not terribly niche. All config that isn’t environment-specific and is used in inner loops or at startup. It’s even got a test for serialised values so can be used to speed your case up:

https://github.com/sebastienros/comptime/blob/main/test/Comp...

But you need to be sure you won’t want to change without compiling.

Well it also needs to be something that you need to generate/calculate, otherwise you would just write by hand the code that comptime outputs.

Also t4 templates before that for at least a decade

And much more developer friendly.

I use source generators pretty extensively but don't really understand how this is different (or what it's solving that source generators can't).

I'm pretty new in the source generation area and only do enterprise dev, so I'm sure I'm missing something or just don't have the use cases.