Comptime – C# meta-programming with compile-time code generation and evaluation
21–30 of 71 posts
Re: Comptime – C# meta-programming with compile-time code generation and evaluation
#22Earlier quoted context omitted.
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…
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.
Re: Comptime – C# meta-programming with compile-time code generation and evaluation
#23How is Comptime different from default AOT compilation? I assume it can work with third-party libraries that AOT don’t work with yet?
Re: Comptime – C# meta-programming with compile-time code generation and evaluation
#24It has a clean syntax, decent package management, and basically every language feature I regularly reach for except algebraic data types, which are probably coming eventually.
I think the association of .NET to Microsoft tarnished my expectations.
Re: Comptime – C# meta-programming with compile-time code generation and evaluation
#25Re: Comptime – C# meta-programming with compile-time code generation and evaluation
#26 • Supported return types:
◦ Collections: ..., List, ...
◦ Note: Arrays are not allowed as return types because they are mutable. Use IReadOnlyList instead.
I don't understand. Why is List allowed then if it's mutable?Re: Comptime – C# meta-programming with compile-time code generation and evaluation
#27C# meta programming game is strong. Source generators are :chefs_kiss:
I love (and heavily use) source generators, but the development experience is godawful. Working with the raw Roslyn types is painful at best and this is compounded by them having to be written against .NET Standard, severely limiting the use of newer .NET functionality. Eventually I want to write a good baseline library to use for my source generators -- simplifying finding definitions with attributes, mapping types…
And the documentation is still pretty sparse.
> Eventually I want to write a good baseline library to use for my source generators -- simplifying finding definitions with attributes, mapping types to System.Type, adding some basic pattern matching for structures -- but haven't found a way to do it that's general enough while being very useful.
I'd use it in a heartbeat. The new ForAttributeWithMetadataName function has been a big help, but everything else feels like a totally different language to me.
Re: Comptime – C# meta-programming with compile-time code generation and evaluation
#28This seems like the kind of feature that should be built into MSBuild.
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…
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.
Re: Comptime – C# meta-programming with compile-time code generation and evaluation
#29• Supported return types: ◦ Collections: ..., List , ... ◦ Note: Arrays are not allowed as return types because they are mutable. Use IReadOnlyList instead. I don't understand. Why is List allowed then if it's mutable?
Re: Comptime – C# meta-programming with compile-time code generation and evaluation
#30This is more like constrexpr than a macro system.