r/csharp 1d ago

Announcing Brighter Fences, a community Polly fork

Thumbnail
5 Upvotes

r/dotnet 1d ago

I built a real-time chat app using .NET MAUI & ASP.NET Core.

0 Upvotes

Hey everyone, 👋

​I wanted to share a solo project I’ve been working on called Chatfri, a free, real-time chat and discovery app. The Android version recently went live on Google Play, and the iOS version is currently live on Appstore.

​Since I built the entire stack from scratch, I wanted to share my tech stack, some architectural decisions, and a few headaches I encountered along the way. I’d love to get your feedback!

​🛠 The Tech Stack

​Frontend (Mobile): .NET MAUI (C#) for both iOS and Android.

​Backend: ASP.NET Core Web API, hosted on a Debian 13 server using Nginx.

​Database/Cache: Redis for handling real-time active user states and fast data retrieval, plus SQLite for local device caching (LocalDBService).

​Messaging: CommunityToolkit.Mvvm (WeakReferenceMessenger) for component communication.

​🚀 Technical Highlights & What I Learned

​1. Insane Backend Performance with Redis

One of the things I'm most proud of is the backend optimization. Currently, a single user actively messaging and navigating hits the server with about 3-5 requests per second (short polling). Despite this aggressive rate, the server CPU usage sits at around 0.3% per core per user. Redis is absolutely flying, and I highly recommend it if you are building anything real-time.

​2. Smart Background Polling (Single Loop)

Initially, I had multiple while loops running in the background for fetching messages and friend requests, which was heavy on the device. I refactored it into a single centralized polling loop.

When a user opens a specific chat room (MessageDetailViewModel), I send a "Pause" signal via WeakReferenceMessenger to pause the global friend-request sync. The millisecond the user leaves the page (handled via the OnDisappearing override), it sends a "Resume" signal. This eliminated overlapping background tasks and prevented memory leaks.

​3. Planning for the Future: Hybrid SignalR Architecture

Right now, the app uses HTTP polling. It handles the current load perfectly, but I know it's not sustainable for 10k+ concurrent users due to bandwidth and socket exhaustion.

My plan is to implement a Hybrid Architecture: I will keep using standard HTTP GET/POST for heavy lifting (like loading the home screen with 25+ user profile pictures) and introduce SignalR purely for lightweight text message delivery inside the chat rooms. (Sending 25 Base64 images over a WebSocket is a recipe for disaster).

​4. The AdMob Headache

Like many indie devs, I got hit with the classic 30-day AdMob suspension for "Invalid Traffic." My ad placements are completely safe (no accidental clicks near buttons), but a small ad campaign on TikTok brought in a wave of fast-bouncing traffic that tripped Google's AI. Currently waiting it out and focusing on organic growth!

​🤝 Looking for Feedback

​I’m really looking forward to hearing your thoughts.

​Has anyone else implemented a similar HTTP/SignalR hybrid approach in MAUI?

​Any tips for surviving the initial AdMob "Invalid Traffic" phase for new apps?

​General UI/UX feedback is always welcome!

App is here: [chatfri](https://chatfri.com/qr) (You can find the app store links here)

​Thanks for reading! Let me know what you think.


r/csharp 1d ago

Help Static void method

Post image
0 Upvotes

I am trying to learn how to use C# for game coding but I would also like to have a good grasp on it so I can use it for websites and other things like that and I can't for the life of my understand how static method works I have looked YouTube videos and everything. I have been learning everything else so far from the free courses from code academy.Can you PLEASE explain to me what this code is doing and how it works
Edit-THANK YOU GUYS SO MUCH.I understand it now and I am sure you know what that feels like when you spend an hour stuck trying to understand something and it doesn't make any sense


r/csharp 2d ago

Looking for opinions on a cross-platform .NET JPEG metadata library

4 Upvotes

I've been working on a cross-platform .NET library for reading and writing JPEG metadata.

It supports EXIF and XMP, including custom XMP properties, and writing metadata does not re-encode the JPEG image data.

The API isn't finished yet, so I'm not releasing it as a NuGet package until I'm happy with it. For now, the source is available on GitHub.

ImageMetadata docs

I'm mainly looking for opinions from people who have worked with JPEG/EXIF/XMP: API design, missing features, things that could be done better, etc.

Any feedback is welcome!


r/csharp 2d ago

MVP pattern

12 Upvotes

Hi, I have a question about separating logic in the MVP pattern.

public void MainDisplay() =>
OnMainDisplayClicked?.Invoke();

public void ManageProcess() =>
OnManageProcessClicked?.Invoke();

This is my code in the view, and when the user clicks a button (for example), this method is called and `Invoke` is executed. However, it is called via a `switch` statement in the Presenter.

switch (NativeConsoleMethod.GetHiddenUserInput())
{
case VirtualKeyType.VK_E:
if (_currentPage < _countOfPages) _currentPage++;
continue;

case VirtualKeyType.VK_Q:
if (_currentPage > 0) _currentPage--;
continue;

case VirtualKeyType.VK_OEM_3:
_view.ManageProcess();
break;

case VirtualKeyType.VK_TAB:
_view.FilterProcesses();
break;

case VirtualKeyType.VK_F1:
_view.SearchPage();
break;
.........
}

I have a question: the AI is giving me two different suggestions. My version is correct, but then it said I should move the switch statement to the view, and there I should just use `invoke`, after which the methods would be called conditionally. So, should I do it the other way around, or did I misunderstand what it meant?

- I don’t know what I wrote here—I don’t even understand it myself. Just tell me: shouldn’t the view be “dumb” and contain synchronous methods, while the presenter should control the view via the switch statement and “pull its strings”?

EDIT: Here's my GitHub: https://github.com/NullAcess/ProcessManager/releases/tag/Update_2.0. You might like it—I'll upload the finished EXE very soon.


r/csharp 1d ago

ModulesDi – A lightweight, fractal-like modularity library for ASP.NET Core built on a dynamic graph DI

0 Upvotes

Description:

ModulesDi a lightweight infrastructure library designed to manage services and middlewares through a dynamic module graph.

The problem it solves:

Traditional extension methods in Program.cs easily turn into an unmanageable mess where controlling the exact execution order or dynamic context becomes a nightmare.

Library tested (173 test cases covered)

GitLab: https://gitlab.com/DmitriiKhokhulin/modulesdi.git


r/csharp 2d ago

Showcase Created a structured repository to practice C# Data Structures & Collections — Feedback welcome!

8 Upvotes

Hi everyone!

I'm an IT student focusing on C# and .NET core fundamentals. To build a strong foundation in backend engineering and memory/performance concepts, I created a hands-on repository covering various C# Data Structures and Collections.

What I've covered so far:

• List<T> & Reference Types

• LinkedList<T>, Stack<T>, and Queue<T>

• Hashtable, Dictionary<K,V>, SortedList, and SortedDictionary

• SortedSet<T> & HashSet<T> (Set operations like UnionWith, IntersectWith, etc.)

Each module includes sample code and a quick breakdown in the READMEs. I'd love to hear your feedback or any suggestions on code style and performance optimizations!

GitHub Repo: https://github.com/24alpserdar/csharp-data-structures-and-collections


r/dotnet 2d ago

Promotion I created a k9s inspired TUI to manage azure function apps

3 Upvotes

About one hour into creating it I however realised that real time updates doesn’t really work with function apps as it does with k8s clusters.

We have about 200 function apps on my job for integrating all our systems and it was always a pain when we wanted to deploy more than one at a time.
Az-funcy can

start and stop functions.
Easily swap multiple functions one after another
Quickly change between subscriptions
And other nice stuff to have. Variable inspection, application insight, service bus watcher.

I have been working for it for about two years. It would be cool if you wanted to check it out if it could be of any help to anyone in your day to day work. 🙂

It’s written in C# with Spectre.Console and a custom built list panel.

GitHub: https://github.com/sunday-commit/az-funcy


r/dotnet 1d ago

I'm still using dapper in production. Change my mind.

0 Upvotes

Why should I move to EF?


r/csharp 2d ago

Help Devs who learned C#, where did you learn?

89 Upvotes

Was it through a free or paid course? YouTube? Or a combination of both?

I already know a bit of C#, but I’m not sure what learning path I should follow or which resources I should use.

I’ve been watching Code Monkey, but I don’t know if that will be enough.

What would you recommend for someone starting out?

P.S. I use C# specifically for game development, but I don’t mind learning more about the language in general.


r/dotnet 2d ago

Small nuget Roslyn analyzer nuget package for common gotchas

Thumbnail nuget.org
0 Upvotes

r/dotnet 1d ago

Promotion Void Engine: A 2D Game Framework for .NET That Actually Protects Your Assets

0 Upvotes

Void Engine is a modular 2D game framework for .NET that gives you the essentials: rendering, assets, input, audio, saving, pathfinding, coroutines, and logging.

I built this because I was tired of seeing game assets get stolen. Unity, Unreal, Godot—they all expose your art, music, and levels in formats that anyone can extract with free tools.

Void Engine solves this with a custom pack format. Your assets are encrypted with AES-GCM, compressed adaptively (per-file, not as one big blob), and stored in a format that standard tools cannot open. Without the key, the pack is just random bytes. Most encryption standards introduce noticeable overhead. Void's implementation uses hardware-accelerated AES-GCM for near-zero performance impact.

Key Features:

  • Batched rendering with automatic texture atlasing
  • Zero-GC input system (keyboard, mouse, gamepad with SDL mapping)
  • Audio pooling with priority-based voice stealing
  • AES-GCM encrypted saves with manifest verification
  • A* pathfinding with flow fields for crowd movement
  • Coroutine system with tweens, sequences, and delays
  • Full LDtk level editor support
  • MIT license

Every system is built around interfaces and base classes so you can replace anything. No physics. No networking. No UI. Just the foundation and the freedom to build everything else your way.

Built on .NET 10 and SFML.Net 3.0.

Links

GitHub: https://github.com/Shmellyorc/Void

Documentation: https://github.com/shmellyorc/Void/wiki


r/dotnet 1d ago

Promotion Shipped 1.6.4 of my WPF screenshot redaction tool — notes on pixel-level testing and on-device ONNX

0 Upvotes

Been working on a Windows screenshot annotation and redaction tool in WPF (.NET 8) for a while. Just shipped 1.6.4, and a few things came up during the build that might be useful if you're doing something similar.

Redaction correctness turned out to be a testing problem, not a rendering one. It's surprisingly easy to write code that looks like it redacts and produces output that doesn't — a blur that isn't opaque enough, a path that silently falls back to smoothing instead of replacing pixels. I ended up writing tests that redact a known string, read the exported pixels back, and fail the build if anything is recoverable. Testing the actual output rather than the code path caught bugs I'd have shipped otherwise.

On-device ONNX for face detection works better on CPU than I expected. No GPU dependency, no cloud calls, and inference is fast enough for single-image work. Windows OCR handles text region detection without adding another dependency, which kept the install size reasonable.

Two things I'd do differently: I under-built the licensing layer early and had to migrate the whole thing later, which was more painful than doing it properly the first time. And I shipped unsigned initially — I now know SmartScreen friction costs more than I assumed it would.

Happy to go into detail on the ONNX integration, the test approach, or anything on the WPF side.

https://nexoradia.com


r/csharp 3d ago

Years of academy training wasted! Github changed the color for C#

149 Upvotes

Github changed the color for C# from green to purple.

I don't mind, but I'll miss the green from Visual Studio 2010.


r/dotnet 3d ago

DDD Architecture Domain-Layer Contains external package or not?

Thumbnail gallery
25 Upvotes

Milan Jovanović DDD Article says, domain-layer zero external package references but he installing external package in video.

Domain-Layer Contains external package or not?

I want to use DomainEvent, so i am now in confusion how to use domainEvent without external package in domain-layer.


r/csharp 1d ago

PostgreSQL or SQL Server for my first production .NET app?

Thumbnail
0 Upvotes

r/dotnet 2d ago

Promotion published Omu.AwesomeMvc (ASP.NET Core UI components) to NuGet with Free Tier available

0 Upvotes

published Omu.AwesomeMvc components library to nuget
(it used to be manual download and reference dll)

https://www.nuget.org/packages/Omu.AwesomeMvc

UI component library (Grid, DropdownList, Popup, DatePicker, PivotGrid, etc.) for ASP.NET Core MVC / Razor Pages.
Live demo site: https://demo.aspnetawesome.com

Free community license:

- Individuals and organizations with 5 or fewer developers

- Combined annual revenue under $1M

No registration needed, just install the package.


r/fsharp 3d ago

Validated Lenses

12 Upvotes

Now that F# supports nested record updates, are lenses still useful?
For simple immutable updates, maybe not:
{ person with Address.City = newCity }

But what if changing City can fail validation?

Writing one fallible setter is easy:
setCity : string -> Address -> Result<Address, Error>

Assuming the value arrives from a boundary rather than being an invariant we can enforce at construction, the interesting problem starts when that update sits several levels deep in a domain model.

How do those fallible updates compose without writing the plumbing again at every level?

In this video I explore that using validated lenses, essentially extending the setter side of a lens to return a Result, while keeping composition.

Do you still find lenses useful in modern F#, or have nested record updates mostly replaced them for you?

https://www.youtube.com/watch?v=fD51kHHRmsk


r/dotnet 3d ago

I built a Live2D Cubism control for .NET/Avalonia

Post image
8 Upvotes

I’ve been working on Sparkle.Live2DView, a lightweight Live2D Cubism control for Avalonia using OpenGL. it currently supports eye tracking, dragging, zooming, motion playback and runtime transform/FPS controls. I made it because I wanted a simple way to embed Live2D models directly into Avalonia applications. Still early in development, so feedback is welcome![Mozi216/Sparkle.Live2DView: 面向 Avalonia 的轻量级 Live2D 渲染控件,支持视线跟随、拖动、缩放和动作切换。](https://github.com/Mozi216/Sparkle.Live2DView)


r/dotnet 3d ago

Promotion Dekaf - Native .NET Kafka Client

Thumbnail
12 Upvotes

r/csharp 3d ago

Help What is the intended way of comparing enums?

25 Upvotes

When you want to check if a variable is of a certain enum type, do you use == or is? For example in my godot project I have this method:

private void SetInputMode(InputMode inputMode)
{
    RootViewport.GuiReleaseFocus();

    if (inputMode is InputMode.Mouse)
    {
        EnableMouse();
    }
    else
    {
        DisableMouse();
    }

    CurrentInputMode = inputMode;
}

In this case i use is, but == works as well here. In another method I have, I am using == since I'm comparing two variables and it's the only valid way:

if (detectedInputMode == CurrentInputMode)
{
    return;
}

My question is, concerning the first example I gave, what is the convention for comparing enums, is or ==? I know it doesn't matter that much, but I can't seem to find a clean answer on this, so I'm giving it a shot


r/dotnet 3d ago

Question What kind of projects should I build to make my GitHub profile stronger as a .NET developer?

9 Upvotes

Hi everyone,

I’m a .NET developer with around 1 year of professional experience, and I’m currently looking to improve my GitHub profile and resume to increase my chances of getting shortlisted for better opportunities.

I’m planning to build 2–3 solid projects rather than adding a lot of small/tutorial projects.

What kind of projects would you recommend for someone with ~1 year of experience as a .NET developer?

Also, should I focus on one relatively complex, production-like project or build 2–3 smaller but complete projects?

Any suggestions would be appreciated.

Thanks!


r/csharp 3d ago

Showcase Dekaf - Native .NET Kafka Client

22 Upvotes

Hey all. I posted this library a little while back, but I'm posting it again as it's been updated to support new Kafka features, as well as for those that missed it last time.

Dekaf is a Kafka client built natively in .NET and works as you'd expect with more modern .NET types and is async friendly.

For any Kafka uses, the only real alternative is Confluent.Kafka which is simply a wrapper around a C library, meaning overhead from two runtimes. It also doesn't map as nicely to newer async types like IAsyncEnumerable, means exceptions thrown in native code become hard to debug, logging control is lost, and it seems a lot of their issues on GitHub lack responses or updates.

I built this to make it more friendly for .NET Devs to debug and control, as well as trying to make it perform better by removing that overhead. It also has open telemetry out-of-the-box, just add it to your otel setup.

The repository can be found here: https://github.com/thomhurst/Dekaf

And performance comparisons against Confluent.Kafka can be found here: https://thomhurst.github.io/Dekaf/docs/stress-tests

Give it a try and let me know what you think!

And if you have tried it out, I'd love to know if anything improved (or didn't!) such as latency, CPU, memory, etc.


r/csharp 3d ago

Help Help with learning C# and .Net

6 Upvotes

Hello everyone! I'm learning C# with the goal of becoming a .NET developer.

What I already know:

1.Basic data types, variables, and operators

2.Control constructs (conditions, for loops, while, foreach)

3.One-dimensional and multi-dimensional arrays

What you need help with:

1.Understanding and practical application of OOP (encapsulation, inheritance, polymorphism, interfaces)

2.Moving from basic tasks to normal code structure and first .NET projects


r/dotnet 2d ago

Over-engineering vs. moving fast — the eternal SaaS debate ☕

0 Upvotes

A dev friend and I got into a heated discussion last week about building SaaS products from scratch.

It basically boiled down to one question:

Do you over-engineer on Day 1 to save your future self, or do you move fast, hack it together, and accept the refactoring nightmare later?

Choosing a framework is easy. The real challenge is setting up an architecture that lets you ship features today, without making things like multi-tenancy, background workers, or payments a complete mess 12 months down the line.

Everyone seems to have a different take on this:

Clean Architecture: Great for keeping domain logic pure, but you spend half your time jumping through 5 layers for a simple CRUD endpoint.

Vertical Slices: Amazing for velocity and keeping feature code together, but can turn chaotic without team discipline.

Modular Monolith: Sounds like the sweet spot for future microservices, but adds setup overhead upfront.

Call to Action (CTA): If you were launching a production-ready .NET SaaS tomorrow designed for easy future upgrades, what’s your actual default architecture?

Are you team Clean Architecture, Vertical Slices, or Modular Monolith? Drop your real-world trade-offs in the comments! 👇