A wrapper around the Roslyn API for generating, saving, and compiling C# code programmatically.
Testura.Code is a .NET library that acts as a wrapper around the Roslyn compiler API to programmatically generate, save, and compile C# code. It provides a set of builders and generators for creating classes, methods, statements, and expressions, enabling dynamic code creation at runtime. This is particularly useful for automating code generation tasks, building custom tools, or implementing metaprogramming patterns in C# applications.
C# developers and teams building code generators, templating systems, automated refactoring tools, or any application that requires dynamic C# source code creation. It's also suitable for those working with Roslyn who want a higher-level abstraction.
Developers choose Testura.Code because it offers a clean, fluent API that simplifies the complexity of direct Roslyn usage, making code generation more approachable and maintainable. It provides built-in support for saving and compiling generated code, which reduces boilerplate and accelerates development of code-generation workflows.
Testura.Code is a wrapper around the Roslyn API and used for generation, saving and compiling C# code. It provides methods and helpers to generate classes, methods, statements and expressions.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The ClassBuilder and MethodBuilder provide an intuitive, high-level abstraction over Roslyn, simplifying code generation as shown in the Hello World example with clean, readable syntax.
Supports contemporary C# syntax like file-scoped namespaces and primary constructors, demonstrated in the record example, ensuring compatibility with latest language versions.
Includes Compiler and CodeSaver classes for in-memory or file-based compilation and saving, reducing boilerplate code for runtime code execution workflows.
Covers a wide range of statements from declarations to iterations, useful for generating complex logic, as evidenced by the test class example with NUnit assertions.
The library is exclusively for C# code generation, making it unsuitable for projects involving other programming languages or multi-language codebases.
The high-level API may obscure low-level Roslyn features, requiring workarounds for advanced customizations not covered by the builders, as hinted in the 'Missing anything?' section.
As a wrapper around Roslyn, it is vulnerable to breaking changes from underlying compiler API updates, potentially affecting long-term stability.