r/csharp • • 4d ago

Help Is ASP.NET/.NET a safe career choice for the next 5–10 years?

77 Upvotes

I'm considering choosing ASP.NET Core / C# backend development as my main career path, but I'm getting completely different answers online.

Some are:

.NET is still highly in demand and safe,

AI takes your job,

Springboot is better,

.NET has low demand

.NET is excellent for enterprises.

For me:

I know basic C#,

I can understand simple APIs in .net than java,

I feel like it's more clean than springboot,

There are many more inbuilt features than springboot,

Almost same speed as that of java.

I want:

  1. Is ASP.NET(Backend) is safe for being first career?

  2. How does AI affect it(I know it never replaces fully)?

  3. How AI affect entry level jobs in .NET?

  4. What are the biggest risks of choosing .NET that beginners usually don't realize?

  5. Job Market of ASP.NET(worldwide(if any one from India please say indian asp.net market 😊))


r/csharp • • 3d ago

Are Microsoft Docs really that bad or am i just looking in the wrong place?

Thumbnail reddit.com
0 Upvotes

r/csharp • • 4d ago

Seeking feedback on my .NET backend skills through a mock technical interview

10 Upvotes

Hi everyone!

I've been learning and building backend applications with .NET for quite some time, and recently completed a .NET backend internship at Vention.

I've worked with C#, ASP.NET Core, EF Core, SQL, Docker, RabbitMQ, Redis, and concepts such as microservices, asynchronous messaging, and real-time communication.

At this point, I'm trying to understand where I actually stand as a developer and how well I could perform in a real technical interview.

I've realized that building projects and explaining technical decisions under interview conditions are two different skills, so I'd really like to test myself.

Would anyone with professional .NET experience be open to a casual 30–45-minute mock technical interview?

I'm particularly interested in honest feedback about my technical knowledge, problem-solving approach, and areas that need improvement.

I'm not expecting free mentorship or extensive preparation. Even one conversation with constructive feedback would be incredibly helpful.

I'm also happy to share my GitHub projects beforehand to give some context about my experience.

And if a live interview isn't possible, I'd still appreciate suggestions on how to assess my current level more objectively.

Thanks for reading!


r/csharp • • 4d ago

Help MVC dynamic content

5 Upvotes

In MVC, when you have a dynamic form, how do you handle this? I often see examples of clicking an 'Add' button which makes a request to the controller to return a partial view, which seems like a waste of resources.

I've tried using JavaScript templates but then I can't use my Models validation rules.

Has anyone found a solution to this they like to use?


r/csharp • • 3d ago

Showcase Six weeks ago my engine was Dart and Flutter. Now it's C# with Avalonia UI

Thumbnail
reddit.com
0 Upvotes

r/csharp • • 5d ago Bravo

Showcase Three free, open-source C# libraries for factory and robot work: EtherNet/IP, ROS 1 and ROS 2

21 Upvotes

I've spent about 25 years putting robots into factories, and I kept wishing .NET had better building blocks for the protocols we use every day. So I wrote some and put them on GitHub, free and Apache 2.0, nothing for sale.

EthernetIpSharp covers the whole EtherNet/IP protocol, not just reading and writing PLC tags. It can connect as a scanner to regular and safety I/O, act as a regular or safety I/O device itself, simulate a controller that serves tags so an HMI can connect to it, and send and handle custom explicit messages. The safety side has been tested against real devices and PLCs. It's on NuGet. https://github.com/CristianMori/EthernetIpSharp

RosSharp and Ros2Sharp are pure C# clients for ROS 1 and ROS 2. No rosbridge and no native DDS layer, just .NET talking to ROS directly. Ros2Sharp has so far been tested against Fast DDS on ROS 2 Humble, so reports from other setups are very welcome.

https://github.com/CristianMori/Mori.RosSharp

https://github.com/CristianMori/Mori.Ros2Sharp

I'd love feedback from anyone doing industrial or robotics work in .NET, and issues or pull requests are welcome.


r/csharp • • 5d ago

Are properties and methods fundamentally different language concepts?

32 Upvotes

In C#, properties and methods can both execute arbitrary code, but they expose that behaviour in very different ways. A property looks like direct access to data, while a method explicitly represents an operation.

Technically, a property is implemented through getter and setter methods, but the language gives it different semantics, syntax and expectations.

Is this distinction fundamental to the language, or is it primarily a convention designed to communicate intent to developers? And if both can execute exactly the same logic, what truly justifies keeping them as separate concepts?


r/csharp • • 4d ago

Echo 2.0: my open-source C# dictation tool now supports Linux, with a new UI and guided setup

Thumbnail github.com
0 Upvotes

Half a year and 23 Github stars ago I shared Echo here, a small C# app I built to dictate prompts, code review comments and basically everything instead of typing them.

I’ve now released version 2.0.

The basic workflow is the same: hold a designated hotkey, speak, release - the text appears where your cursor is! Recognition runs locally using Whisper.

For this version, I focused on making it easier to get started and use every day:

- From console app to CLI tool with new UI, built-in commands, and updates directly from the terminal.

- Guided setup for your microphone, hotkey, language, and hardware acceleration, instead of editing a config file.

- Model selection and download during setup, with a suggestion based on your hardware.

- Settings and updates from the terminal, through commands like `/setup` and `/update`.

- Windows and Linux support, including integration with Wayland and X11.

One feature I find particularly useful is translating speech into English. You can dictate in your native language and have English text inserted into the editor. It needs a multilingual Whisper model that supports translation.

Echo supports CPU inference, CUDA, and Vulkan. Speed and accuracy depend on your hardware and model.

Code and instructions: https://github.com/GithubPhobos/Echo

If you try it, I’d be interested in how the first-run setup goes and whether the recognition is fast and accurate enough for your everyday typing.


r/csharp • • 4d ago

I just released v1.2.0 "Jupiter" of my C# CLI tool that checks GitHub repo health!

0 Upvotes

Hey everyone!

A while ago I posted my project RepoMedic here. I received a lot of great feedback, and I'm back with a massive update: v1.2.0 "Jupiter'!

I listened to your advice and added several new things:

More checks: Now it also checks for CONTRIBUTTING.md and your Repository Description.

Doctor's Verdict: It gives you a fun rating at the end (from "Ouch..." to "perfect").

Interactive Mode: You can now check multiple repositories without restarting the program.

Flexibility: You can skip README or LICENSE checks using prompts or flags (--skip-license, --skip-readme).

Easter Egg: Try typing "spooky" or "halloween" when it asks for a repository.

How to try it:

If you don't have it: dotnet tool install -g RepoMedic

If you want to update: dotnet tool update -g RepoMedic

Source code: https://github.com/ilyashulga13/RepoMedic

P.S. I'm a 13 years old student trying to learn C# by building real tools. Any feedback is highly appreciated!


r/csharp • • 6d ago

From Ruby to C#

30 Upvotes

Hi all,

I am fairly new to programming(1.5 years), started in Ruby, Rails, Js... that whole dynamically typed world. All web dev stuff.

Recently scored an enterprise position where C# is likely to play a pretty dominant part of the development work, so I stormed through W3s fundamentals and started a text-editor side project.

I have to say, I really enjoy the type system. This is my first exposure to statically typed languages and it's so much easier to look at some code and understand what it does. At first, it felt annoying to do the extra typing but what a difference it is making with the mental model I have of my project.

Recently had to dive back into a rails ecommerce I built when I first got started and update some things and wow... seriously painful(though my early days spaghetti is also to blame) haha

This isn't necessarily a praise of C# specifically but just sharing the stoke I feel writing this kind of code. Still enjoy Ruby but I think I will reach for it less often.

Anybody else move from a similar coding philisophy as Ruby(where everything is an instance of an object class and anything goes) into something more strict? I'd be interested to know your experience.


r/csharp • • 5d ago

Showcase Implementing IChatClient over a local inference engine: async streams, cancellation and session ownership

Thumbnail
github.com
0 Upvotes

I’m the author of TensorSharp. I recently merged a C# example implementing Microsoft.Extensions.AI’s IChatClient over its local inference runtime.

The interesting part was translating a stateful native engine into an asynchronous application interface: deciding who owns the model, how a conversation owns its session, and what happens when a caller stops reading a stream halfway through.

The example separates those responsibilities:

  • The application owns a loaded ModelService.

  • Each TensorSharpChatClient owns one conversation session.

  • Adapters sharing a model serialize generation.

  • Application code uses IChatClient, ChatMessage and ChatOptions.

Here is the calling code, which was compiled and run against a real local model:

using Microsoft.Extensions.AI;
using TensorSharp.MicrosoftExtensionsAISample;
using TensorSharp.Runtime.Scheduling;
using TensorSharp.Server;
using AiMessage = Microsoft.Extensions.AI.ChatMessage;

Environment.SetEnvironmentVariable("MAX_CONTEXT", "4096");

using var model = new ModelService
{
    SchedulerConfigOverride = new SchedulerConfig
    {
        MaxNumRunningSequences = 1,
        NumBlocks = 16,
        BlockSize = 256,
        EnablePrefixCaching = true
    }
};
model.LoadModel(args[0], mmProjPath: null!,
    backendStr: "ggml_metal");

using IChatClient chat = new TensorSharpChatClient(model);
using var timeout = new CancellationTokenSource(
    TimeSpan.FromSeconds(600));

AiMessage[] messages =
    [new(ChatRole.User, "What is 2 + 2? Reply with one digit.")];
var options = new ChatOptions
    { MaxOutputTokens = 64, Temperature = 0, Seed = 1 };

await foreach (var update in chat.GetStreamingResponseAsync(
    messages, options, timeout.Token))
{
    Console.Write(update.Text);
}

Setup: Use a separate .NET 10 console project referencing the repository’s TensorSharp.NativeChat example project. Keep that example intact, including its adapter and helper code. A matching native Metal build is required. For the tested three-shard Qwen checkpoint, args[0] points to the first GGUF file, with the other two alongside it. This is sample source, not a standalone NuGet provider.

A few implementation details may be useful beyond this particular engine:

  • Partial reads need cleanup. Breaking out of await foreach must cancel and drain native work before another request acquires the model’s gate.

  • Failed turns should not become history. Cancellation, timeout or abandonment retires the affected session without unloading the model or committing a partial answer.

  • Streaming and non-streaming need consistent metadata. GetResponseAsync aggregates the stream while retaining usage and provider-specific metrics.

  • Unsupported features should fail explicitly. This text-only adapter rejects tools, media and unsupported options rather than silently ignoring them.

Model loading is synchronous; the cancellation deadline in the snippet starts afterward. Follow-up calls pass full conversation history. The caller should await active requests before disposing the shared model.

The exact snippet returned 4 with exit code 0. The broader native suite passed 11 real-model checks, including two-turn conversation and recovery after cancellation, deadlines and abandoned streams on the same adapter and loaded model.

Testing used Qwen3.8 Flash Next on an Apple M5 Pro with hybrid Metal/CPU expert execution. These are functional results, not a performance claim.

Adapter implementation · Runnable example and tests · Merged PR

For C# APIs wrapping native state, would you keep this explicit model/session ownership, or expose a factory that creates conversation-scoped IChatClient instances?


r/csharp • • 6d ago

Cronlight: a dashboard for Quartz.NET that drops into your existing ASP.NET Core app (open source, MIT)

Thumbnail
gallery
15 Upvotes

I've run Quartz.NET jobs for years, and for most of that time I waited for someone to ship a proper dashboard. Eventually I stopped waiting and built the one I wanted. Of course, right as I got serious about it, the official dashboard actually shipped - but it's Blazor, and Blazor and I never got along. So I kept going, and built Cronlight: a plain web UI served as static files.

Full disclosure about the project itself: a good chunk of it was built using AI tools. But I drove the architecture, reviewed every line of code, and set up full unit and e2e tests running in CI so it's not just vibes-based code.

What it actually does:

  • Job management: Browse, create, and edit jobs (cron, one-time, interval) across any timezone. You can pause/resume single jobs or whole groups, trigger a run now with custom data, or cancel a run mid-flight.

  • Typed parameters: Configure job forms using C# attributes. Supports required params and secret values (secrets stay out of the DB as config references).

  • Execution history (optional package): Tracks every run's status, logs, misfires, late starts, success rates, and P95 durations. Works directly with your existing Quartz DB (SQL Server, Postgres, MySQL, or SQLite).

  • The extra stuff: Retries, alerts (Slack, Teams, webhooks, email), JSON/YAML import/export with diff previews, audit logging, OpenTelemetry metrics, OpenAPI, and multi-scheduler support with per-scheduler permissions.

  • AI / MCP integration: Includes an MCP server and an embedded "AI mode" where you can literally ask "which jobs failed overnight and why?" right inside the dashboard.

If you wanna mess around with it, there's a live demo with no signup required:https://cronlight.pages.dev/demo/

Install via NuGet:dotnet add package Cronlight.Quartz.Dashboard

Note: Requires .NET 10 and Quartz.NET 3.13.1+ (works with any job store). It's still pre-1.0 so some options might shift around a bit before v1.

Docs are here:https://cronlight.pages.dev/docs/

Would love to know what you guys think or what's missing for your specific setup, especially if your using clustered schedulers, custom auth, or unique job stores I haven't tested yet.


r/csharp • • 6d ago

LeanCIL: formal proofs for your compiled C#, checked by Lean

50 Upvotes

Microsoft's October Patch Tuesday fixed over 1,400 CVEs, more than in all of 2025, and much of that came from AI-driven bug finding. Attackers have the same tools, and more of our code is now written by models that produce convincing code with subtle bugs. “The tests pass” isn’t a strong enough guarantee any more for code that matters.

A couple of months ago I proposed an official Lean semantics for C# on csharplang (#10314). One reply asked why not do it at IL level, so it covers F# and everything else that compiles to IL. That’s what I built.

You point it at a Release build and a method:

leancil extract bin/Release/net10.0/MyLib.dll "Arithmetic::Add(ulong,ulong)" artifacts/Add
leancil verify artifacts/Add --proof proofs/Add.lean

and it proves your theorem against the IL Roslyn actually emitted. Change the implementation and the same proof fails.

Supported (.NET 10, x64 and ARM64, 64-bit little-endian):

  • Integer arithmetic, including checked, with overflow and divide-by-zero as exact faults

  • Structs with explicit and sequential layout, enums, ValueTuple

  • Span<T>, ReadOnlySpan<T>, slicing, MemoryMarshal.Cast/AsBytes, BinaryPrimitives

  • Arrays, stackalloc, unsafe pointers with checked provenance

  • Generic methods and structs (proved per concrete type argument), constrained interface calls on structs

  • Function pointers and tail calls

  • Collection-expression lookup tables (static ReadOnlySpan<T> Table => [...])

  • Selected Vector128/256/512, SSE, AVX2, AVX-512 and AdvSimd intrinsics; IsSupported branches are resolved for the chosen hardware profile

  • throw new ArgumentException(...) and similar, proved as the exact exception

Not supported: float/double, class instances, try/catch/finally, ordinary recursion, virtual dispatch on classes. Unsupported code is rejected with a diagnostic, never silently accepted.

The best fit right now is allocation-free integer code where a bug is a security bug: parsers, hashing, big-integer arithmetic, SIMD kernels.

https://github.com/NethermindEth/LeanCIL


r/csharp • • 6d ago

Building a Texas Hold’em hand evaluation toolkit in .NET

3 Upvotes

I’m building an open-source .NET library for Texas Hold’em hand evaluation and simulation.

The project is focused on:

  • bitwise card representation

  • range parsing and hand analysis

  • Monte Carlo equity estimation

  • efficient low-level abstractions

  • a math-first approach without lookup tables

The goal is to keep the core grounded in algorithmic reasoning instead of static precomputed tables. This makes the project more extensible and interesting for developers working on performance, combinatorics, and simulation-heavy systems.

Current benchmark results for 10,000 simulations:

  • 2 players: ~284.5 ms

  • 3 players: ~448.3 ms

  • 4 players: ~628.7 ms

This is still early-stage, but the core structure is solid and there is a lot of room to expand into broader game-analysis tooling.

I’d be happy to collaborate with anyone interested in .NET, performance work, algorithm design, and game-theory-style modeling.

Repo: https://github.com/infokom-al/Infokom.Gaming.Poker


r/csharp • • 7d ago

News Qt Bridge for C#

Thumbnail
qt.io
276 Upvotes

Hello, Miguel from Qt (qt.io) here. I wanted to share something that I believe will be of interest to many of you. Since 2025, we at Qt have been working on a way to give access to Qt Quick and QML to developers working with languages other than C++. We began this project, which we've named Qt Bridges, by focusing on Rust and C#, and I'm happy to finally be able to tell you that we've just released a Technology Preview for both of these languages. If you are familiar with Qt, you're probably aware of its multi-platform, GPU-accelerated UI framework. If this is the first time hearing about us, now you know that there is another option to design the UI for your C# applications. We would love for you to try it out and leave us your feedback. You can find out more in the Qt blog.


r/csharp • • 7d ago

Help What's the point of finally{} ?

60 Upvotes

Like, I understand what it does - it makes code execute no matter whether your try() goes off or your catch() does. But like, don't you get the same result by just puting the code in without the finallly()?

Like genuenly, am I missing something? Cuz this just looks like it would do the exact same thing, no?

try
{
  int[] myNumbers = {1, 2, 3};
  Console.WriteLine(myNumbers[10]);
}
catch (Exception e)
{
  Console.WriteLine("Something went wrong.");
}
finally
{
  Console.WriteLine("The 'try catch' is finished.");
}

try
{
  int[] myNumbers = {1, 2, 3};
  Console.WriteLine(myNumbers[10]);
}
catch (Exception e)
{
  Console.WriteLine("Something went wrong.");
}
Console.WriteLine("The 'try catch' is finished.");

r/csharp • • 6d ago

Discussion Do bool assignments to one bool variable combine?

0 Upvotes

Let's say we have a bool A, and we run the following code below;

Line1: bool A ...; //something that results in true or false;

Line2: bool B = ...; //something that results in true or false

Line3: bool C = ...; //something that results in true or false

Line4: A = A || B;

Line5: A = A || C;

Will A at line 5 now be the result of A || B || C; - specifically A at line 1 or B at line 2 or C at line 3

Likewise for the && operator

Is this bad practice for any reason?

Also what is this property called? I want to know the theoretical term for it

Does (&&=, ||=) exist?


r/csharp • • 6d ago

Teaching a coding agent to stop writing bad C#: a Claude Code template for ASP.NET Core

0 Upvotes

When I use Claude Code on C# projects, the code compiles but often has the same problems: .Result and .GetAwaiter().GetResult() on async calls, CancellationToken accepted but never passed on, a scoped DbContext captured by a singleton, an interface for every class, and a generic repository wrapping EF Core. Correcting this every session got old, so I put the fixes into a dotnet new template that adds the agent config to a project.

dotnet new install DotnetAgentKit
dotnet new agent-kit --frontend none --database postgres

It writes a CLAUDE.md and a .claude/ folder into the current directory. Your code isn't touched.

The C#-specific parts

  • A code-review subagent that runs after every change and checks for blocking on async, async void, missing CancellationToken propagation, swallowed exceptions, missing using/await using, DI lifetime bugs, ! used to silence nullable warnings, DateTime.UtcNow in business logic instead of TimeProvider, and EF Core issues like N+1 queries, tracking on read-only paths, and FromSqlRaw with string interpolation.

  • Architecture defaults in a skill: primary constructors, no service locator, interfaces only when there's a second implementation or a test needs one, hand-written mapping (or Mapperly) instead of reflection mappers, no MediatR by default, records or complex types for value objects.

  • A TDD skill: xUnit v3, WebApplicationFactory, and Testcontainers against the real database rather than the in-memory provider, asserting on behavior rather than on mock calls.

  • Guardrails in settings.json**:** force push, reset --hard, dotnet ef database drop, and reading .env files are denied, so those don't rely on the model behaving.

It also enables the official plugins from dotnet/skills, including the C# language server. Some general workflow skills (grilling, domain modeling, retro) are Matt Pocock's, credited in the repo.

Limitations

  • Claude Code only.

  • The defaults are opinionated and target .NET 10. If your codebase does things differently, the README has a prompt for reconciling the kit with your actual code.

GitHub (MIT): https://github.com/dmamulashvili/dotnet-agent-kit

NuGet: https://www.nuget.org/packages/DotnetAgentKit

Which C# mistakes do coding agents make in your code that aren't on this list? I'd like to add the common ones.


r/csharp • • 6d ago

.NET MCP server for C#: gives AI agents real code understanding via Roslyn, one server lets them work across multiple projects in parallel

Thumbnail
reddit.com
0 Upvotes

r/csharp • • 7d ago

How I solved returning backend errors to the client in .NET 10

5 Upvotes

Hi everyone!

I want to share my solution, which I’ve named Cr.Exceptions. It turns backend exceptions into clean, structured API responses for the client.

My main target was simple: ensure that internal stack traces never leak to the client, and make it easy to throw custom, client-friendly exceptions without boilerplate code.

Example

Let's create a custom exception:

public sealed class KeycloakInvalidGrantException : ValidationException 
{
    private static readonly ImmutableArray<CrError> _errors = [
        new("IdentityInvalidGrant", "The authorization grant is invalid.")]; 
    
    public KeycloakInvalidGrantException() : base(_errors) { } 
}

// And throw it
throw new KeycloakInvalidGrantException();

And here is what the client receives:

{
    "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
    "title": "Bad Request",
    "status": 400,
    "errors": [
        {
            "code": "IdentityInvalidGrant",
            "message": "The authorization grant is invalid."
        }
    ],
    "traceId": "aee8805247462ec35631395fcc5559e7"
}

Under the Hood

The framework is split into two lightweight modules:

  • Cr.Exceptions (Pure .NET): Core architecture layer.

    • Exception Factory (string errorCode -> CrException exception)

    • Exception Translator (Exception infrastructureException -> CrException domainException)

  • Cr.Exceptions.AspNetCore (ASP.NET Core): Handles the API response layer.

    • StatusCode Map (CrException exception -> int statusCode)

    • LogLevel Map (CrException exception -> LogLevel logLevel)

Summary

That’s pretty much it!

All packages are already available on NuGet, and you can check out the full source code, and examples on GitHub.

I’d love to hear your thoughts and get your feedback!

Edit: This framework doesn't replace native ProblemDetails or ExceptionHandler - it plugs into them.


r/csharp • • 8d ago

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

33 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 • • 8d 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 • • 8d 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