Comptime brings meta-programming capabilities to C#, enabling compile-time code generation and evaluation.
Comptime brings meta-programming capabilities to C#, enabling compile-time code generation and evaluation.
A .NET source generator that executes methods at compile time and serializes their results to C# code. Comptime brings meta-programming capabilities to C#, enabling compile-time code generation and evaluation.
Comptime allows you to mark methods with the [Comptime] attribute to have them executed during compilation. The return values are serialized into C# source code and used at runtime, eliminating the need for runtime computation of values that can be determined at build time.
This meta-programming approach enables developers to shift expensive computations from runtime to compile time, resulting in faster application startup and execution.
[Comptime] are executed during compilationint, long, short, byte, sbyte, uint, ulong, ushort, float, double, decimal, bool, char, stringIReadOnlyList, IReadOnlyDictionary, List, DictionaryIReadOnlyList instead.42, "hello", truenew List { 1, 2, 3 }, new[] { "a", "b", "c" }1 + 2, Math.PI * 2…[Comptime]| Code | Description |
|---|---|
| COMPTIME001 | Class must be partial |
| COMPTIME002 | Method must be static |
| COMPTIME004 | Unsupported return type |
| COMPTIME005 | Compilation emit failed |
| COMPTIME006 | Method execution failed |
| COMPTIME007 | Serialization failed |
| COMPTIME011 | Array return type not allowed (use IReadOnlyList) |
| COMPTIME012 | Argument must be a constant (no variables allowed) |
staticpartialIReadOnlyList)MIT License
No open issues yet, or sync has not completed.