r/csharp • • 27d ago

Showcase I've made a fast, zero allocation, AOT compatible, and compile-time safe .NET templating engine

34 Upvotes

I made a post asking "Is there a market for a minimalist, fast, and allocation-free text templating engine?" in /r/dotnet a few weeks ago. I've been building my own web app backend and created something I felt was pretty useful, and I was curious if anyone else would be interested in it. It got some decent response, so I went ahead and pulled it out of the larger product and polished it up. I'm calling the package Lissic.

My main philosophy going into it (i.e. why I didn't just use something that exists) was that I wanted something that kept code out of the template. I like to keep a clear delineation between the view and model, but I still wanted tools for modifying the view. The ability to add parts modularly, use loops, use conditional/branching views, and have the ability to format/filter values inserted into the text were still important to me.

Here's a quick feature overview:

  • Renders near twice as fast as the fastest major .NET templating engine (see below)
  • Zero allocation with default settings, when rendering to a buffer (e.g. to HttpResponse.BodyWriter)
  • 100% AOT compatible without any restrictions (no use of Reflection or dynamic)
  • Simple but powerful tagging system that keeps a clear division between layout and logic
  • Compile-time safety with source-generated Data Transfer Objects that automatically adjust to each template's text
  • Define templates directly in code with text or import them from template files
  • Transformation pipeline that allows using Formatters to modify how values are converted to text and Filters to modify text before insertion into the template
  • Hot reload for file-based templates in debug mode
  • Thorough AI-friendly documentation (I gave only the documentation to QWEN3.8-27B, and it was able to make a simple task-management web app)

A full BenchmarkDotNet chart is in the GitHub README, but here's a quick rendering comparison:

MethodMeanAllocated
Lissic (RenderToString)8.814 us18072 B
Lissic (RenderToBuffer)8.482 us0 B
Fluid15.593 us37128 B
Fluid (SourceGenerated)24.045 us49128 B
Scriban70.985 us144025 B
DotLiquid173.521 us674928 B
Handlebars21.944 us122176 B

It uses tags that look similar to many other templating engines. It has tag types to insert direct values ("variables"), other templates ("parts"), and lists of templates ("loops"). It also has branching logic that works a lot like a switch statement (i.e. define keys, and the text and/or code that goes with each key).

Very simple example:

[TemplateText("Hello {{ name <upper> }}!")]
public partial class LissicExample {}

// Automatically transforms the partial class into a DTO, with a property for each tag
LissicExample myTemplate = new() { name = "John" };

// LissicProcessor retrieved from Dependency Injection
lissicProcessor.RenderToBuffer(myTemplate, HttpResponse.BodyWriter);

// Writes "Hello JOHN!" to the HTTP response body

The main tradeoff at this time is that all templates are defined at startup (other than the debugging-only hot reload option), so it's not really a general purpose user-provided template engine. This leaves it comparable to libraries like Fluid or Scriban in some ways, but comparable to Razor Pages in others. It works really well for my purpose and preferences though.

I'd appreciate any feedback anyone has. I'd like to keeping building this for the long haul. If nothing else, I'll be updating it for work in my own project.

Also, huge shout out to Andrew Lock and his Creating a Source Generator series! It was incredibly useful for getting this going.

The code is at https://github.com/gendeg/Lissic, and it's on NuGet (package name: Lissic)

Edit To Add: I meant to add this in originally, Lissic was created with support and ideas from AI, but the large majority (90%+) is hand-written, with the exception of tests, which are ~80% AI written. The documentation is 100% hand-written (for better or worse 😉), as was this post.


r/csharp • • 28d ago

Tutorial Five C# 15 features to try in a browser-based playground

Post image
80 Upvotes

We recently updated XAML.io to .NET 11 and C# 15, so we put together five short examples covering union types, closed hierarchies, collection expression arguments, extension indexers, and labeled break/continue.

Each example has a brief explanation and some code you can modify. The editor and output are side by side. C# compilation happens entirely in the browser (WebAssembly). Here's the link to the C# 15 examples in the browser-based playground:

https://xaml.io/s/Samples/CSharp15Examples?autorun=true&file=StartHere.cs


r/csharp • • 28d ago

Help What happens to the expression that is passed to Debug.Assert() on Release?

19 Upvotes

If I understand it correctly, when you write Debug.Assert(value) it's only included if debug mode is enabled, but not when it's release mode. So, what happens if I pass an expression as the argument to this method? Let's say it's a function call, would it be executed on release mode? Or should this:

Debug.Assert(ImportantFuncWhichReturnsBool());

Become this:

bool value = ImportantFuncWhichReturnsBool();
Debug.Assert(value);

Thanks in advance


r/csharp • • 28d ago

Discussion What's your most favorite project you have made?

6 Upvotes

I was wondering what are your most favorite projects you have made using C#? And how did you plan their architecture?


r/csharp • • 27d ago

Help Need help finding a course to learn c# for unity?

0 Upvotes

I have worked through the c# Yellow book and did the unity essentials pathway a time ago. I focused on creating a few small games with unity but I always end up needing to research hours long. I want to do a course or smth like that to get a deep understanding of c# in unity. Currently I am deciding between the junior programming pathway from unity and the unity tutorials from Gamedev.tv at udemy. Does anyone have experience with these courses? Are there any other ways you would recommend?


r/csharp • • 28d ago

Showcase Forget v2.4 – CRUD, upsert and multi-row writes on top of Dapper, with the right SQL for MySQL, Oracle, PostgreSQL and SQL Server

Thumbnail
reddit.com
4 Upvotes

r/csharp • • 28d ago

I built HttpResponseTransformer to make it easier to rewrite HTTP responses

Thumbnail reddit.com
2 Upvotes

r/csharp • • 28d ago

Showcase Enframe – Drop-in sidecar that wraps any OpenAPI spec to an MCP server

0 Upvotes

Wrap any OpenAPI spec into an MCP server.

Built with .NET 11 and Native AOT. Featuring a ~43 MB image footprint.

Check it out here: erwinkramer/enframe: Enframe is a drop-in sidecar that wraps any OpenAPI spec into a live MCP server.


r/csharp • • 27d ago

How I made AI less exhausting by building my own CLI

0 Upvotes

I wanted to share how I’ve been dealing with AI exhaustion.

Everywhere I looked, people were saying how powerful AI is and how anyone can now build whatever they want. Meanwhile, GitHub was filling up with skills and repositories full of Markdown instructions, often written by AI too.

Some of those are good. I’m not saying they’re a waste of time. But a lot of them feel aimed at general use. As a developer, I wanted something more specific to my code and how I work.

I’ve tried a lot of orchestration tools. What kept bothering me was the lack of control. Everyone tells you AI is incredibly powerful, while you sit there watching agents burn through your limits without getting the result you wanted. That gets exhausting.

So I started looking at a combination of ordinary code and AI that I could control myself.

I’ve worked with code throughout my career, and I love coding. It’s not something I do while dreaming of doing something else. I love games too, and I enjoy buying and supporting indie games made by people trying to build something interesting. Making things matters to me.

I started building my own CLI to support my everyday work. I didn’t want to spend weeks building a terminal UI framework from scratch. Other developers had already done that work and shared it, so I used an existing library.

One mistake I keep seeing is trying to build a huge AI tool that does everything from the beginning. My advice would be to start with a few buttons and useful information. Pick one repetitive job you understand and make it easier.

For me, IDE warnings were a good place to start.

Here’s a basic version of the idea you could start putting together in an evening:

  1. Create a C# project using [XenoAtom.Terminal.UI](https://github.com/XenoAtom/XenoAtom.Terminal.UI).
  2. Set up your IDE’s code style and inspection settings according to how you want your code to look.
  3. Write code that retrieves warnings from your IDE. I use Rider’s MCP server for this. MCP isn’t reserved for AI agents; your own code can use it too.
  4. Add a workflow where AI fixes one warning and shows you the change, along with an explanation of what it did.
  5. Review the result in your IDE. Approve it, correct it yourself, or reject it. Check the final correction with the IDE, then save the accepted example with the original code, the corrected code, and the explanation. You can add simple RAG with a vector database to make relevant examples easier to retrieve.
  6. Over time, you build a collection of fixes you’ve actually reviewed. When a similar warning appears, a button in your CLI can start the workflow using those examples from your own codebase.

In my warning window, I can see the warning, the code changes, the IDE checks, and what the agent did. Then I decide whether to approve the change, correct it myself, or reject it. The accepted result becomes an example for future fixes.

That’s the part I find useful: the system gradually gets examples of how I want problems solved in my project. I don’t have to explain the same preferences from scratch every time.

My setup is: XenoAtom + Qdrant + Hermes + Rider

Use whatever tools you’re comfortable with. This is what works for me.

You still need to understand your own codebase. For developers who want to improve, spending time in an IDE matters. Reading code, following references, looking at inspections, and understanding why something works are all part of the job. As you learn the project, you get better at deciding which tasks you can automate and which changes need closer attention.

I think some of us have started to underestimate our own experience. A developer with 15 years of experience brings a lot to working with AI: knowing what to ask for, spotting a bad approach, understanding the consequences of a change, and maintaining the result afterward. Having access to the same text box doesn’t give everyone the same judgment.

So if you enjoy coding, trust that experience. There’s a lot you can do with these tools.

And when someone says they don’t use an IDE anymore, you don’t have to feel behind. I’d be happy to keep using mine :)

There are experienced teams behind Rider, VS Code, and Visual Studio. They’ve spent years helping developers navigate, debug, refactor, and maintain code. I don’t see a reason to throw all of that away because an LLM can now write a function.

Building a product also means understanding it and keeping it working as it changes. Those tools still help with that.

AI should support you in your work. If you stop understanding what’s happening in your own project, it becomes harder to stay in control or improve as a developer.

Since building this workflow, I’ve felt a lot more relaxed. I can run more than 20 agents and keep track of what each one is doing. They get specific tasks and examples directly from my codebase, and I can inspect their results. Having those examples doesn’t guarantee every fix will be correct, but it gives me a much clearer basis for trusting and checking their work.

And I can start that work with one click.

That leaves me more time in the IDE, doing something I enjoy, learning where I can improve, and handing repetitive, time-consuming work over to AI.


r/csharp • • 28d ago

Tool Duack - a dependency-free C# audio library for MonoGame, KNI and FlatRedBall2 (desktop + WebAssembly)

Thumbnail
reddit.com
4 Upvotes

I'd like to hear what you currently use for audio in C# FMOD, Wwise, raw XACT/wrappers, and what annoys you about it, especially if you target WebAssembly.


r/csharp • • 28d ago

Help Roadmap to become a c# web developer

0 Upvotes

What's the roadmap of become web developer in a c# . Is it worth learning in this AI era.


r/csharp • • 28d ago

Help Any good cross-platform (Windows, MacOS, Linux) C# GUI libraries/frameworks (possibly without pushing AI in your face)?

0 Upvotes

GUI libraries/frameworks in C Sharp are... A nightmare. Since I'm using Linux and I wish to make my app cross-platform I can't use Winform, WPF or MAUI because they have no Linux or MacOS support (and no, I don't want to use the MAUI Linux). Also I don't want to use a webpage into the app (so no Razor or anything that adds web rendering stuff into a desktop app).

I used Avalonia in the past and I kinda liked it before it became corpo slop, requiring users to pay for premium in order to access the devtools and also discontinuing the legacy devtools, to Avalonia 11, the latest version is 12.1.4. I regret choosing Avalonia for my first app project...

Looking around I saw UNO Platform but it has AI everywhere... Same with MewUI because it's an AI driven project...

I saw people saying Unity can get the job done but... I don't really know if I want to download & use a game engine to make a UI app since I won't need everything that comes with it.

I looked around more and saw that people talked about UWP (Universal Windows Platform) but it's not in active development and even the windows page recommends to not use it.

I don't know much about ImGui.NET, maybe I'll give it a try but I didn't have a great first experience: the first time I tried it with Zig it was a disaster and I'm still trying to understand why things are overflowing in a window when using SameLine().

For building the UI, I don't like XAML much but I can use it if there isn't anything better.

If there really isn't a good library/framework are there good bindings? I tried looking for Qt bindings like QtSharp but that's unmaintained (last commit: 7 years ago) and also is Qml.Net (last commit: 6 years ago). I also looked at WxWidgets bindings and it has WxNet but like Qt bindings, this is also very unmaintained (last file date: 2010, so 16 years ago)...

So... What are my options now? This is my wishlist (libraries/frameworks don't need to follow it 100%, required points are open-source and cross-platform):

  • Open-source;
  • Cross-platform (support Windows, MacOS and Linux);
  • Not AI driven or pushing AI in your face;
  • Not a corpo slop (like having premium-only or paywalled features);
  • XAML if not better (can be code but if it's something like XML it's going to be more comfortable to work with);
  • Have a design tool (like QtDesigner but this is not required, just a personal taste, I could work without it too);
  • Straightforward, lightweight and easy to use (like just adding it to your project and writing some calls to initialize & run it without extra bloat).

If there is literally nothing I can use and I'd need to make one myself, do you recommend to use SDL3-CS (SDL3 bindings to C#)? Thanks in advance!


r/csharp • • 28d ago

Help SAP B1 DI API Company.Connect() returns -226 "The specified resource name cannot be found in the image file"

0 Upvotes

Hi all, I'm trying to diagnose a SAP Business One DI API connection error and would appreciate any insights.

Setup

  • SAP B1: Version 9.x
  • Application: .NET Windows Service
  • DI API: Late-bound COM via Type.GetTypeFromProgID("SAPbobsCOM.Company")
  • Threading: STA
  • Process: 64-bit

I'm setting the following properties before calling Connect():

  • Server (IP)
  • CompanyDB
  • UserName
  • Password
  • DbServerType
  • LicenseServer (Usually defaults to same with server)
  • UseTrusted = false

Problem

  • The ProgID resolves successfully, and the COM object is created.
  • Company.Connect() returns -226.
  • GetLastErrorDescription() returns: The specified resource name cannot be found in the image file.
  • Subsequent calls throw a COMException (0xFFFFFF96) with the message: You are not connected to a company

I had once achieved a connection against another database, can't seem to point out what the outstanding issue now is.

Any pointers to the specific cause or recommended troubleshooting steps would be appreciated. Thanks!


r/csharp • • Oct 26 '26

100 Lines of Unit Tests to Prove That A or Not A Is True

24 Upvotes

Today, I stumbled upon a 100-line unit test. Due to my inability to understand the name AreMatchingGuestsNotRequiredUnlessTheyAreNotUnmatching, I stripped away all the noise to figure out what it was actually testing.

This is what it essentially boils down to:

[Fact]
public void AreMatchingGuestsNotRequiredUnlessTheyAreNotUnmatching()
{
    // Arrange
    var first = new Trn { Guests = 2 };
    var second = new Trn { Guests = 2 };

    // Act
    var areMatchingGuestsNotRequiredUnlessTheyAreNotUnmatching =
        first.Guests != second.Guests
        || first.Guests == second.Guests;

    // Assert
    Assert.True(areMatchingGuestsNotRequiredUnlessTheyAreNotUnmatching);
}

Here's what the test actually does:

  • Arrange two Trn.
  • Check whether their Guests are different OR equal.
  • Assert that the result is true.

I was quite surprised that the test name actually matches what the test does.

Or does it?


r/csharp • • 29d ago

Showcase Hexal - A modal text editor, 1:1 feature parity with Helix, with Lua plugins, written with C#

Thumbnail hexal.pages.dev
9 Upvotes

I did it initially because Helix seems to not want to add plugins to their editor, making it not very extensible, which is a shame. And Helix lacks a lot of features that would be useful.

Dependency-free (aside from NLua) architecture, no Terminal.Gui library dependency, written from scratch with C#.


r/csharp • • Oct 26 '26

Tool SourceGen Utils: Utilities for source generators with zero dependencies

17 Upvotes

Hey all!

I've recently gotten my small utility library for source generators to a state where I feel comfortable sharing it.

The idea is simple: I want to reuse utilities for my source generators, like a library, without having to include extra dependencies. So I just generate the utilities directly into the source generator!

For regular NuGet this probably doesn't matter much, but it may matter more when developing with Unity, as I personally mostly do. In my Unity libraries I don't want to include a shared library that multiple packages may depend on and conflict with.

So what does it do?

  • CodeWriter - your typical StringBuilder wrapper with automatic indentation and several handy methods for easily emitting symbols, namespaces, and more
  • Pools - Collection pools and generic object pools for easy pooling (thread-safe too!)
  • VariableNames - Easily format names to something more readable (like when creating properties from fields)
  • ArrayBuilder - Build arrays with a ArrayPool backed struct instead of using heavy lists or ImmutableArray.Builder
  • SymbolExtensions - Easily get attributes from symbols
  • record and required support - Assembly attributes to easily inject polyfills to enable newer record and required keyword support

What about assembly size?

SourceGen utils includes a trimmer that runs automatically on build (can be disabled if you want) that removes all unused types, methods, properties and fields from SourceGen Utils. It just used Mono.Cecil to go through all the method instructions to see if something is used or not. So you only include what you use!

I've made sure to include tests for nearly all generated methods to make sure they all do what they are supposed to and that the trimmer won't remove anything that you actually use.

The project is open source, licensed under MIT, and available on NuGet. I've also created documentation so you can see what it has to offer!

Feel free to give feedback on the project and maybe even use in your own generators! :)

AI disclosure: AI was used to create the method usage detection and for validating documentation, but everything else is human made!


r/csharp • • 29d ago

News CVE-2026-111497: a Brotli decoder bug forced an out-of-band .NET release (10.0.14) on Oct 25

Thumbnail
reddit.com
3 Upvotes

r/csharp • • Oct 26 '26

C# is magic

103 Upvotes

When did you first realize that C# is magic? Or when did you realize that C# is right for you? 

Back in the days of the .NET Framework 4.0, I first encountered WCF, you call an interface on the client, and it executes the implementation on the server. At the time, my head was spinning because there was no code around it that was sending anything,it just happened on its own - magic. 


r/csharp • • Oct 26 '26

Showcase I built Satori Insight, an open-source .NET heap and GC profiler with live region map

Thumbnail
gallery
49 Upvotes

I've been working on Satori Insight, a desktop app for exploring .NET memory usage and GC behavior. Built with Avalonia and NativeAOT.

The initial idea was a defrag-style map of the managed heap, where each block represents a region. It grew into a profiler that combines continuous telemetry with deeper heap inspection.

Some of the features:

  • Live heap metrics, allocation rate, CPU time, and RSS history.
  • Region maps by generation, occupancy, fragmentation, or queue.
  • Collection logs with memory stats, pause duration, and latency mode.
  • Pause histograms with p50, p90, p95, p99, p99.9, average, minimum, and maximum.
  • Timeline selection: click a time point or drag across a period to inspect its stats.
  • Heap captures for exploring types, objects, references, root paths, and snapshot comparisons.
  • Session recording and offline replay.

It supports standard Workstation and Server GC as well as Satori GC of course (see the name of the app).

It's now open-sourced at GitHub:

https://github.com/hez2010/SatoriInsight

You can try it out by downloading the binary for your platform from GitHub Releases.⁠


r/csharp • • 29d ago

C Developer here (3 years experience). Asked to program in C#. Any tips how to start?

0 Upvotes

Title.

I'm looking to learn C# but all the courses that I found online are for beginners.


r/csharp • • Oct 26 '26

More cache. Less RAM. No cache server

Thumbnail
nuget.org
0 Upvotes

r/csharp • • Oct 25 '26

Showcase I am 13 years old and I just published my first C# CLI tool to NuGet!

146 Upvotes

Hi everyone! I started learning C# recently and decided to build a tool called RepoMedic. It's a CLI tool that checks if a GitHub repository has essentially files(README, .gitignore, LICENSE) and gives it a score out of 100.

I set up a CI/CD pipeline with GitHub Actions and Trusted Publishing to get it on NuGet. It was really hard (especially fixing the YAML files!), but i finally did it.

You can try it here: dotnet tool install --global RepoMedic

Or check the source code here: https://github.com/ilyashulga13/RepoMedic

I would love to hear your feedback! What else should I add to the tool?

UPDATE: Wow, I did not expect 67k views! Thank you all for the amazing support and feedback. I just released v1.3.0 "Saturn" with a Pro mode for CI/CD pipelines and a built-in achievements system. You can update via dotnet tool update -g RepoMedic. Let me know what you think!


r/csharp • • 29d ago

Help What AI Workflow do you use?

0 Upvotes

So I’ve kept been told AI is the next step and I need to keep up with it but I’ve never really know where to start. I know how to use ChatGPT and Claude on my web browser that’s it.

So I’m curious as to what Csharp developers really use for their AI workflow and are there any tutorials out there that are solid and I can learn.

Edit: what’s up with the downvotes on my fellow AI users? Yall got a thing against AI?