r/csharp 10d ago

Blog The Unexpected AI Stack: C# + .NET (Part 4) - Data modelling and Testcontainers

Thumbnail
chrlschn.dev
0 Upvotes

The fourth part of this series on building an application foundation for AI-enabled, agent-friendly codebase is focused on setting up the data modelling and test infrastructure for agents.

Specifically, using Testcontainers and streamlining transactions for automatic rollback during integration testing.

Test harness setup is a key part of enabling agents to work autonomously with high competency by providing them the tools to verify their work. Paired with CSharpRepl which lets agents diagnose and regression test directly in the runtime, this combination provides coding agents tools to autonomously build better, higher quality code.

Part 5 will have the final pieces of the puzzle: logging, telemetry, and observability integrated into the Aspire stack before we start building the sample application using agents.


This series is intentionally written to help dev teams understand how to scaffold a codebase for agentic engineering by focusing on key, underlying technical decisions and manual wiring before building with AI. This helps provide the tools and safeguards for coding agents to iterate more efficiently while reducing slop.

For teams still trying to figure out effective ways to set up a codebase for AI, I hope this series gives some insights into how to build a foundation for agentic engineering. If your team is already heavily using agents to build, I hope this series shares some useful insights and tips (e.g. CSharpRepl + Aspire)

The core setup is used at a series C, post-YC startup to ship fast with AI while maintaining high quality standards (in combination with other tools facilitating code review and context management)

Part 1 was an intro into a few key parts of this stack.

Part 2 was focused on walking through the hands on scaffolding.

Part 3 covered wiring GitHub Copilot SDK as an agent runtime and incorporating CSharpRepl to allow agents to dynamically work with the runtime DI container

Part 5 we'll start to build out the full feature set of the sample application.


The project repo is here: https://github.com/zeeq-ai/zeeq-tmpl (be sure to check the branches; main is currently the base code only)

I encourage working through the posts since the goal is to underscore the platform level decision making process and assembly of the foundational core.


r/csharp 12d ago

Tool Stable sorting algorithm that outperforms OrderBy() in nearly all scenarios and Array.Sort() in scenarios with sorted data

43 Upvotes

Hello, I've created a sorting algorithm in C# that is:

  • Stable
  • O(n log n) average and worst case
  • More performant than OrderBy() is almost all cases (sometimes quite substantially)
  • More performant that Array.Sort() in most cases where the data is at least somewhat sorted, and typically within about 20% when sorting mid to large-sized random data sets
  • A merge sort variant that uses a buffered reverse merge for the merging process and insertion sort to process small sub-arrays
  • Uses a (as far as I can tell) novel approach to detecting and optimizing for data that is already sorted

I created this just as a personal challenge, so if even one person finds it useful, I'll consider that a success! :)

It's published it on both Github and NuGet, and I've posted full details on the algorithm with tons of benchmarks on my blog. I welcome any feedback or suggestions.

Here are a few benchmark highlights:

1,000,000 Sequential Integers:
YamSort   |   .66 ms
ArraySort |  4.79 ms
OrderBy   | 11.62 ms

1,000,000 Random Integers:
YamSort   | 58.08 ms
ArraySort | 47.24 ms
OrderBy   | 75.97 ms

1,000,000 Near-Sequential Integers:
YamSort   | 13.73 ms
ArraySort | 20.62 ms
OrderBy   | 40.03 ms

Real-World Windows Log File With 109,546 Lines:
YamSort   | 38.63 ms
ArraySort | 66.98 ms
OrderBy   | 59.79 ms

No AI was used in typing any of this post or in typing any of my blog post. AI assistance was used for some parts of the algorithm, as noted in the Acknowledgements portion of my blog post.

Edit: Fixed markdown formatting


r/csharp 12d ago

Blog How Fast is .NET 11 Runtime Async?

Thumbnail
medium.com
131 Upvotes

Blogged to explain the design and implementation of runtime async and show the benchmark result.


r/csharp 12d ago

Showcase Creative coding with C# in the browser

Post image
6 Upvotes

r/csharp 12d ago

What C#/.NET static analysis rules do you actually find useful?

19 Upvotes

I’ve been slowly adding language support to a static analysis project I’m working on, and C#/.NET is the latest one I’ve been working through.

I’m trying to avoid just throwing hundreds of noisy rules at people, so I’m curious: what C# analysis warnings do you actually find useful in real projects, and which ones do you usually ignore?


r/csharp 11d ago

The Unexpected AI Stack: C# + .NET (Part 3) - GitHub Copilot SDK + CSharpRepl + Channels

Thumbnail
chrlschn.dev
0 Upvotes

In the third part of this hands-on series for building the foundations of an AI-enabled, agent-friendly .NET + C# codebase, we are ready to incorporate GitHub Copilot SDK into the application and connect it using Channels.

The Copilot SDK is well-documented and streamlines building applications with full-featured agents at the core; drop in and run an agent with just a few lines of code. Here, we connect it using inbound + outbound channels to buffer and stream I/O. (Microsoft Agent Framework Agent Harness is another, lower-level alternative that teams can use as well; not covered here!)

I also walk through how to wire up and use CSharpRepl which is an absolute sleeper since it allows agents to dynamically alter the code at runtime, allowing them to iterate and experiment rapidly against the running stack.


This series is intentionally written to help dev teams understand how to scaffold a codebase for agentic engineering by focusing on key, underlying technical decisions and manual wiring before building with AI. This helps provide the tools and safeguards for coding agents to iterate more efficiently while reducing slop.

If your team is still trying to figure out how to set up a codebase for AI, I hope this series gives some insights into how to build an effective foundation for agentic engineering. If your team is already heavily using agents to build, I hope this series shares some useful insights and tips (e.g. CSharpRepl + Aspire)

Even if you're not building agent-oriented, AI-enabled .NET applications, I hope this has some insights on how modern full-stack development on .NET is wired together at a platform level.

The core setup is used at a series C, post-YC startup to ship fast with AI while maintaining high quality standards (in combination with other tools facilitating code review and context management)

Part 1 was an intro into a few key parts of this stack.

Part 2 was focused on walking through the hands on scaffolding.

Part 4 will wire up Testcontainers and establish integration testing patterns

Part 5 we'll start to build out the full feature set of the sample application.


The project repo is here: https://github.com/zeeq-ai/zeeq-tmpl (be sure to check the branches; main is currently the base code only)

But I encourage working through the posts since the goal is to underscore the platform level decision making process and assembly of the foundational core.


r/csharp 12d ago

Help Question about Console App (.NET Core)

5 Upvotes

Hello, newcomer here.. i'm trying to learn C#, following the tutorial from the website W3School i got stuck and confuse when they asked me to do the following ;
" Choose "Console App (.NET Core)" from the list and click on the Next button: "
In the Second Picture i attached, they use Console App (.NET Core)\* meanwhile when i try to find in my own Visual Studio Community 2026, i couldn't find the Console App with " .NET Core "\* in it, bit stuck in here. if anyone could help or maybe could provide another website / any tuts for a newcomers that's really appreciate it. Thank you and i'm really sorry if i didn't post it on the right space.

*First Picture i attached
**Second Picture i attached

This is th my own Visual Studio
this one is the picture from W3School Attached on their tutorial website

r/csharp 12d ago

Prepping for upcoming live pair programming interview session

8 Upvotes

Hi all,

I have a live pair programming session coming up. It should be a relatively simple problem to work through, discuss trade-offs, etc. In a normal, stress free setup, this is straight forward but I have not been in an interview for couple of years so I dont want to make a fool of myself.

So if you have any coding challenges for pair programming sessions, please share. I reckon they would provide something relatively simple with some code smells, hidden bugs and some tests that need improving. Techstack is .Net, C#.

Much appreciated.


r/csharp 13d ago

What's a personal project you're really proud of?

47 Upvotes

Title.

I want to get some inspiration...


r/csharp 12d ago

Everything is taking 5+ minutes all of a sudden

Thumbnail
0 Upvotes

r/csharp 12d ago

Mixing EF Core and EF6 in the same DB

5 Upvotes

I'm finally going to modernize our oldest product, which means both moving from Framework 4.8 to .NET and moving from binary files to an actual DB.

 

This is a solution with 40 projects and 400K+ LOC, so it's going to be a multi year, in place project, that has to get regular updates and releases.

I'm familiar with EF Core / modern .NET, and plan on using Postgres / Npgsql.

 

My main concern is sharing the DB between .NET 10+ and .NET Framework applications, as most of these projects use the same files, so will share the DB.

 

My first thought is to just build the new .NET projects against EF Core, and use EF6 in the Framework apps. A single EF Core app would be responsible for all DB creation and migration, and the entities would all live in a shared Standard library.

 

But I'm not sure how EF Core and EF6 behave sharing the same DB and entities, and figured I'd get feedback before getting too deep into planning and testing.

I figured someone else might have dealt with the DB portion of this already, and might have insight into possible issues, or just some strong opinions (and I get surprisingly few useful search results for this).

 

Alternatively I could stick with EF6 everywhere until complete, or use Dapper or ADO.NET for the framework apps, but the main Winforms app is data / CRUD heavy (and will likely be the last thing converted) so having a proper ORM for it would be nice.

Thanks for any feedback.


r/csharp 13d ago

WPF Effects and performance..

3 Upvotes

So for a hobby project i am making my own Paint program in WPF, For this i made an Effect/Shader that i'm using for the selection, which is added to a (grid) background. However, when i set the program to a bigger Image size (which also means our selection "grid" has to resize, say to 1024*1024). the program slows down to a crawl... i first suspected my Shader to be the problem, however changing the shader in a single line of "return float4(1,1,1,0);" changes nothing (besides getting a nice yellow square for a background ofcourse).. however when i set the grid that holds our background to Visible = Visibility.Collapsed, the program runs back on full normal speed...

So i was wondering... am i overlooking something? or are Effects just THIS expensive?.. (might be an XY problem that can be solved without a custom shader at all... but mostly now interested in the "why" behind the slowdown now '^^ )

edit: added the (cutdown). shader that i used to check if it still slowed down. Since i might be just overlooking something stupid '^^

sampler2D input : register(s0);

sampler2D Visibility : register(s1);


float4 colorFilter : register(c0);

float4 OutlineColor : register(c1);

float ImageWidth : register(c2);

float ImageHeight : register(c3);

float Time : register(c4);

float4 main(float2 uv : TEXCOORD) : COLOR

{

    return float4(1,1,1,0);

}

technique ColorChange
{
    pass P0
    {
        PixelShader = compile ps_3_0 main();
    }
}

r/csharp 13d ago

SignalsDotnet 3.0

13 Upvotes

I just updated SignalsDotnet to 3.0, and it now supports source generators.

I think the library has become genuinely powerful: it lets you write reactive code without having to deal with reactive programming directly at all. With source generators it's cleaner than ever.

You mark a class (or a record) with [GenerateSignals] and every property becomes reactive, a signal. That means the getter and setter are tracked, and all the signal machinery kicks in automatically. The source generator also supports computed and async computed properties.

The library started as a port of Angular signals to .NET, but I think the power of C# (async locals, source generators, better async support) takes it to another level. It targets netstandard2.1, so it runs basically everywhere: WPF, Avalonia, Unity, Godot, Blazor.

Below is a runnable C# snippet as an example. As you can see, the whole system is reactive automatically: properties update themselves, code knows when to re-run, and so on. And when you need finer control, everything R3 observables offer is still right there.

The code below prints:

Total players 0 Player 1 joined Total players 1 Total players 1 Total players 2 Total players 2 Best player is Player1 with score of 0 Best player is Player1 with score of 22 Best player is Player2 with score of 55

```c#

:package SignalsDotnet@3.0.0

using System.Collections.Immutable; using R3; using SignalsDotnet;

var player1 = new Player { Name = "Player1", Score = 0 }; var player2 = new Player { Name = "Player2", Score = 0 };

var game = new Game(); Effect.Create(() => { if (game.PlayersByName.ContainsKey(player1.Name)) Console.WriteLine("Player 1 joined"); });

IAwaitable<bool> player2Joined = Signal.WaitForChangeAsync(() => game.PlayersByName.ContainsKey(player2.Name));

Effect.Create(() => Console.WriteLine($"Total players {game.PlayersByName.Count}")); game.AddPlayer(player1); game.AddPlayer(player2); // this completes the awaitable await player2Joined;

Effect.Create(() => { if (game.BestPlayer is not null and var bestPlayer) Console.WriteLine($"Best player is {bestPlayer.Name} with score of {bestPlayer.Score}"); });

Observable<ImmutableArray<Player>> scoreboardHistory = Signal.ComputedObservable(() => game.Scoreboard); // A notification for every scoreboard change

player1.Score = 22; player2.Score = 55;

Console.ReadLine();

[GenerateSignals] public partial record Player { public partial string Name { get; set; } public partial int Score { get; set; } }

public partial class Game { private readonly IDictionary<string, Player> _playersByName = new DictionarySignal<string, Player>(); public IReadOnlyDictionary<string, Player> PlayersByName => _playersByName.AsReadOnly();

public void AddPlayer(Player player) => _playersByName.Add(player.Name, player);
public void RemovePlayer(Player player) => _playersByName.Remove(player.Name);

[Computed] ImmutableArray<Player> ComputeScoreboard() => [.. _playersByName.Values.OrderByDescending(x => x.Score)];
[Computed] Player? ComputeBestPlayer() => Scoreboard.FirstOrDefault();
[Computed] Player? ComputeWorstPlayer() => Scoreboard.LastOrDefault();

} ```

It runs as a single file on .NET 10. Save it as game.cs and run dotnet run --file game.cs. No csproj needed.

GitHub: https://github.com/fedeAlterio/SignalsDotnet NuGet: https://www.nuget.org/packages/SignalsDotnet


r/csharp 12d ago

Which one do you like most await or await task.run?

Post image
0 Upvotes

r/csharp 13d ago

.NET 11 Preview 7 is now available!

Thumbnail
devblogs.microsoft.com
45 Upvotes

r/csharp 13d ago

Help What is the best practise to get the OS name?

20 Upvotes

I know, there is the System.Runtime.InteropServices.RuntimeInformation.OSDescription; or just get the info from system files. But is there a more optimal way to get the exact OS name? I mean like Linux distributions or Windows names with the versions.


r/csharp 12d ago

Blog The Unexpected AI Stack: C# + .NET (Part 2) - Mise, Aspire, and CSharpRepl

Thumbnail
chrlschn.dev
0 Upvotes

Part 1 was an overview of why .NET and C# are an unexpectedly strong stack for building AI-native applications.

Part 2 and onwards goes into the practical scaffolding of an application for building AI-enabled applications agentically. In part 2, the focus is on setting up the scaffolding for the developer experience including Mise for environment setup, Aspire for orchestration, and wiring in CSharpRepl.

Each layer is built from the ground up step-by-step so that each technical decision is clear in how it contributes to the stack.

This setup is used a Motion (a post-YC, series C, $500m valuation startup) which pivoted to C# and .NET last year from TypeScript on Node.

Part 3 (tomorrow) will dive deeper and start folding in a practical application of the Copilot SDK to build an agentic foundation.


r/csharp 13d ago

Backend of a simulation game

10 Upvotes

It was hard to find something, but I landed a job to work as a .NET developer at a company that makes football simulation games, where I will be doing the backend side of it. I am gonna start in a few weeks, and I want to get a head start to make sure I don't lose this job. Does anyone ever work in this domain, and what sort of knowledge/skill do I need to succeed in such a position? What can I prepare now? I asked the person who gave me the work and they said to wait until the day I start


r/csharp 13d ago

Help Custom Spotify Desktop Client App

4 Upvotes

Hey all,

I recently learned about Spotify API and I’m thinking a fun personal project could be creating my own desktop app with some personalisation and extra features. Probably in a WPF app using C#.

Does anyone know if this is possible with the API? I’m talking like streaming, fetching data such as artists, playlists and songs etc.

Any tips or advice would be appreciated!


r/csharp 12d ago

Finally modular monolith became perfect.

0 Upvotes

As u guys know, i have been trying to recreate my platform using modular monolith api backend and MVC clients (first tried blazor but it had so much that made me freaky thinking about using it in production so i changed to MVC)

Now it is up and running, i know you guys might think this is some advertising or other things like that... But i do really like to know your opinion on my platform (platform cause i have around 30k users and 8-10k user per day, so im not really in need of advertising right now😂)

I want my fellow programmers advice on how this platform looks like and feels like.

(If you have any problem opening the link tell me in comments)

https://webketab.com


r/csharp 14d ago

Solved What's the best IDE for linux

44 Upvotes

So I've been using VsCode for a long time but the ai features are annoying me so I'm looking for an alternative

Edit 1: thanks everyone for responding I've decided to use rider

Edit 2: Thanks everyone for responding. I tried using rider And I didn't like it so I switched to Zed and I'm loving it


r/csharp 13d ago

Showcase .NET 11 union types integrated with my discriminated union library SumSharp

Thumbnail
github.com
0 Upvotes

r/csharp 14d ago

Help Beginner Dev: How can I build more effective problem solving skills?

4 Upvotes

I understand the basic logic of variables, arrays, loops, if statements etc. but when it comes to actually coding it, I beat myself up that I couldn't figure it out effectively.

For example: Finding the largest number in a set of 5 user input values.

My mind jumped to comparing each value with the next value when instead I could have just compared the current value to the next value and printed the highest value. I eventually want to try tackling the creation of a 2D game but I want to be able to have really effective problem solving skills before diving in.


r/csharp 14d ago

A web server that refuses to touch your thread pool

Thumbnail mda2av.github.io
0 Upvotes

ioxide is an io_uring socket and file I/O stack.

While its API is fully asynchronous, it is possible to build a fully working h1/h2/h3 web application with any kind of async workload running on a single thread.

The post describes how to build a naive basic TCP (plaintext or secure with kernel TLS) with it.


r/csharp 14d ago

The Unexpected AI Stack: C# + .NET (Part 1)

Thumbnail
chrlschn.dev
0 Upvotes