Source Generation
Source Generation
Repo
Generated code allows developers to skip over tedium and keep focused on important design details.
My source generation platform aims to establish a definitive .NET project architecture of declarative descriptor languages. Several backend and frontend tasks follow patterns which can be boilerplated from a source descriptor document.
Account.model
schema {int Id,
string Email = {""},
string FirstName = {""},
string LastName = {""}
}
partial WithPassword {
string PasswordScheme = {""},
string PasswordHash = {""},
string PasswordSalt = {""},
DateTime? PasswordSet
}
repo {
dbo.Account_GetById(int id)
=> Account,
dbo.Account_GetWithPassword(string email)
=> Account.WithPassword,
...}
service {
AttemptLogin(string email, string password)
=> Account.WithSession,
LogOut(),
ResetPassword(string resetToken, string password),
...}
DTO classes are generated for the table schema and derived partials.
var dto = new Account(); dto = new Account.WithPassword();
A service interface is generated which must be implemented fully in the application backend.
public class AccountService : Account.IBackendService { ... }
Also accompanying functions to call SQL stored procedures and API endpoints.
Account.Repository repo; repo.Account_GetWithPassword(...); Account.IService service; service.AttemptLogin(...);
Declarative, reactive components are defined in ".view" files.
They are descriptions of HTML segments which can be reused, nested, and composed to create larger complex views. As the user interacts with a web page, the browser makes calls to the backend to render new HTML and react to user actions.
Each component has a set of state variables which are remembered during the component's lifetime, and a set of functions the browser can invoke to cause updates.
state { int count, bool enabled = {true}, string firstName = {""}, ... }
interface { Increment(), Decrement(), Add(int amount), ... }
Then give the component a body.
div(| class = {"d-flex flex-row gap-2"} |
div(| class = {"my-auto"} |
{"Count:" + count}
)
button(|
class = {"btn btn-danger"},
onclick = {"dispatch(this, 'Decrement');"}
|
<">-</">
)
button(|
class = {"btn btn-success"},
onclick = {"dispatch(this, 'Increment');"}
|
<">+</">
)
)
Business logic and event handlers are written in C# running in the backend.
HTML content is automatically swapped out by the dispatch(el, action, args)
function written in JS.
The developer can build large portions of the application codebase from succinct lines leveraging structured generation patterns.
Language Server with Visual Studio integration

(above: source generation language server running next to Visual Studio 2022)
Syntax highlighting and validation

(above: custom syntax highlighting extension with semantic colors)

(above: simple validation messages for syntax correctness)