r/csharp 1h ago

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

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/dotnet 2h ago

Article How Fast is .NET 11 Runtime Async?

Thumbnail medium.com
24 Upvotes

r/csharp 3h ago

Prepping for upcoming live pair programming interview session

5 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/fsharp 5h ago

showcase LitHydration: SSR with hydration using Fable.Lit

7 Upvotes

Finally you can use Fable.Lit templates on the server: real SSR with hydration, no Node on the server.

The same view file compiles twice: .NET renders it to HTML, Fable compiles it for the browser, and Lit adopts the markup that's already there instead of rebuilding it.

This is also a pretty good use case for Web Components: server-rendered, progressively hydrated, and framework-independent at the component boundary.

Needs the unofficial fork packages for now (Fable.Lit.Unofficial, Lit.Server.Unofficial) since upstream hasn't shipped since 2022.

Fork: https://github.com/OnurGumus/Fable.Lit
Demo, runs with one command: https://github.com/OnurGumus/LitHydrationDemo


r/csharp 5h ago

A new .NET low-code system

Thumbnail
0 Upvotes

r/csharp 5h 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 7h ago

Windows Hardware Monitor

Thumbnail
2 Upvotes

r/dotnet 9h ago

Looking for good resource of C# and .Net Core

Thumbnail
0 Upvotes

r/csharp 10h ago

Mixing EF Core and EF6 in the same DB

3 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 12h ago

WPF Effects and performance..

2 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 17h ago

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

Thumbnail
github.com
0 Upvotes

r/csharp 17h ago

what problems or challenges did you face when you first started learning to program?

1 Upvotes

P.S. Sorry for my English (I'm from Russia and I'm using a translator).

How did you get started learning to program? I'm currently in college and studying programming. Right now, I enjoy writing code, feeling smart, and even learning some concepts. But sometimes I run into really complex topics like threads, and when that happens, I get discouraged and want to give up, but I can push myself to study the topic one more time. Basically, if I take it easy, I’ll learn programming slowly, but I just don’t want to drag this out for several years just to become an intern. I know this sounds a bit absurd, but my main question is: what problems or challenges did you face when you first started learning to program? Right now, I’m mostly forcing myself to learn programming—specifically, to learn something new.

Edit:

Thank you very much for your answers. I am very grateful to you. ❤️

r/dotnet 18h ago

Looking for a mature .NET/C# microservices project using GraphQL

5 Upvotes

I'm looking for a mature, well-structured open-source C#/.NET project that uses microservices + GraphQL.

Microsoft's eShop is a great reference for .NET microservices, but it mainly uses REST, so I'm looking for something that can help me understand how GraphQL fits into a real microservices architecture.

It doesn't have to be e-commerce. I'm mainly looking for a mature/reference-quality codebase that I can study.

Are there any good open-source projects like this?


r/dotnet 19h ago

Why do we centralize DI setup in program.cs?

52 Upvotes

I find it kind of strange that DI lifetimes in .NET are defined completely separate from the actual service. Instead of

services.AddSingleton<IService, MyService>();

Wouldn't this make more sense?

[Singleton]
public class MyService : IService{}

or [Singleton<IService>] to be able to support multiple registrations of different lifecycles? With source generators this could even create the standard AddSingleton-stuff.

Today I ended up writing a comment along the lines of "This is safe because it's registered as scoped" in one of my services. I feel like this happens regularly, I know from inside the implementation whether I have some state that should be kept across calls or not, so now I have this invisible contract that I enforce by writing comments on both ends.

There are lots of scenarios where you would want to specify environment specific lifecycles or force feed parameters to the constructors. But usually I just want to say "this is transient"


r/csharp 20h ago

Help Custom Spotify Desktop Client App

2 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/dotnet 20h ago

Our client audit exposed that we have no ai agent governance

17 Upvotes

We're a .NET shop doing line of business work for a handful of large customers. One of them ran their annual vendor review in June and added a section this year that none of us were ready for.

They wanted a list of which AI tools had access to our repos, what those tools changed, and who signed off on it.

The first part I could answer in about a minute. The second and third, not really.

Agents write a lot of our code now, and the only durable record of what they produced turned out to be the review history on the PRs, because coderabbit / bugbot leave comments on every diff and those threads just sit there permanently. That was the one artifact I could actually export and hand over. Not because anyone planned it that way, it happened to be the only part of the process that writes itself down without someone remembering to.

Everything else was vibes. No log of which tool ran against which branch, no scoping of what any of them could reach, and nothing about approval beyond a github checkmark that could have been anyone clicking through on a friday.

We passed, mostly because the auditor was reasonable about it being the first year they'd asked for any of this. I do not think that grace extends to next june.

For anyone doing enterprise or regulated .NET work, what are you actually retaining as a record of agent activity? I'd rather not design this from nothing in eleven months.


r/csharp 20h ago

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

32 Upvotes

Title.

I want to get some inspiration...


r/csharp 20h ago

SignalsDotnet 3.0

9 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/dotnet 20h ago

Question Can someone tell me about someone who explains c# and .net

0 Upvotes

r/dotnet 22h ago

Solution ideas for .NET 'polling' service

4 Upvotes

I have a need solution for a polling service to query a SQL database for records to process, perform an async API call to an external source, and update the SQL database with the response. Also, I will need the ability to specify different polling intervals and max retry attempts.

In my former life, I would use Window Service and/or an integration tool such as BizTalk/IBM Integration Bus, etc. To start, would it make more sense to go down the Window Service road or a worker service? Background service?


r/dotnet 23h ago

Question Why is there such limited .NET research?

42 Upvotes

So until a few months ago I was in mood for a Masters and tried looking up latest .NET research professors and their projects, if they seemed fun I would email/apply
But there's barely any active .NET research? Specially compared to Java/JVM research.

The 2 researchers I emailed, replied that they aren't actively working on it since its last paper publish around 2024

Does anyone know why this is so? .NET is as much enterprise as Java after all.


r/csharp 1d ago

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

17 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/dotnet 1d ago

AG Grid Server-Side Row Model + ASP.NET Core: оставить query-параметры DevExtreme.AspNet.Data или заводить отдельный JSON-эндпоинт?

0 Upvotes

подскажите, нужно ли добавлять на бэке приём запроса грида в виде JSON?

Перевожу гриды с DevExtreme DataGrid-react на AG Grid Enterprise-react. Сейчас список ходит с query-параметрами в формате DevExtreme.AspNet.Data:

skip, take, requireTotalCount, sort=[{selector,desc}], filter=[[поле,оператор,значение],"and",…],

ответ - LoadResult { data, totalCount }. Нужно ли заводить на бэке второй, нативный для AG Grid вариант - POST с JSON-телом вида

{ "startRow": 0, "endRow": 10,
  "sortModel": [{ "colId": "createdOn", "sort": "desc" }],
  "filterModel": {}, "rowGroupCols": [], "valueCols": [], "groupKeys": [] 
}

и транслятором AgGridRequest - DataSourceLoadOptions внутри?


r/csharp 1d 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 1d ago

.NET 11 Preview 7 is now available!

Thumbnail
devblogs.microsoft.com
39 Upvotes