Stéphane De Todaro — tech lead

@super-dev.app · Tech-lead
Active since 2017

Technical lead and full-stack architect, freelance since 2019. I design, industrialize and operate business platforms on Azure, and I publish open-source software engines.

All projects
Open-source project · .NET

NgSharp v3 — a template engine for .NET

Author — NuGet · MIT

Angular-style interpreted templates, format-agnostic: parses any text file with deep HTML awareness. Zero dependencies, Native AOT compatible.

first render in microseconds

The problem

Rendering HTML server-side in .NET usually means code generation: Razor compiles its views through Roslyn. That compilation weighs on cold start and rules out Native AOT.

The approach

NgSharp interprets instead of compiling. It parses the template into an AST on first use, caches the tree, then renders by walking it: no Roslyn, no IL emit, so cold start is instant and the reflection-free path stays Native AOT compatible. One dependency: System.Text.Json.

In practice

C#
1var builder = HtmlBuilder.Create();
2var html = builder.BuildFromTemplate(
3 "<ul>@for (u of Users) {<li>{{ u.Name | upper }}</li>}</ul>",
4 new { Users = new[] { new { Name = "ada" }, new { Name = "linus" } } });
5// → <ul><li>ADA</li><li>LINUS</li></ul>

Highlights

  • Angular-style syntax: interpolation, pipes, @if/@for, safe navigation
  • Interpreted: AST cached, no generated code
  • Native AOT and trimming compatible, reflection-free
  • Immutable, thread-safe AST: parsed once, rendered concurrently
  • Purpose-built HTML parser, a single runtime dependency (System.Text.Json)

Stack

  • C#
  • .NET 9
  • Native AOT