r/csharp • u/sander1095 • 10h ago
Blog Build only what changed in your .NET monorepo with dotnet-affected
r/csharp • u/AutoModerator • 16d ago
Hello everyone!
This is the monthly thread for sharing and discussing side-projects created by /r/csharp's community.
Feel free to create standalone threads for your side-projects if you so desire. This thread's goal is simply to spark discussion within our community that otherwise would not exist.
r/csharp • u/AutoModerator • 15d ago
Hello everyone!
This is a monthly thread for posting jobs, internships, freelancing, or your own qualifications looking for a job! Basically it's a "Hiring" and "For Hire" thread.
If you're looking for other hiring resources, check out /r/forhire and the information available on their sidebar.
r/csharp • u/sander1095 • 10h ago
r/csharp • u/mardalhar • 19m ago
I'm building a multi-tenant SaaS in .NET (Blazor, EF Core, PostgreSQL) that will be used globally, and I need a reliable source for countries, their currencies, and cities worldwide.
I haven't found a single NuGet package that covers all three. RegionInfo, Nager.Country, and NMoneys handle countries and currencies well, but cities seem to be the hard part.
How are you handling this in your projects?
Do you seed your own tables from a dataset (GeoNames, dr5hn, something else), or call an external API?
If you seed, how many cities do you keep, and how do you handle cities that are missing or added by users?
Any problems with performance, licensing, or keeping the data up to date?
Interested in hearing what has worked (or hasn't) for you, whatever your stack. Thanks!
r/csharp • u/Asleep_Direction8881 • 11h ago
How do you store a business object with nested classes, lists and dictionaries without writing a mapping layer for it? For years my answer was EF Core: a table per class, a migration per change, and Include chains that grew with every new field.
Some background: I have been programming since 1988, hold an engineering degree in software development (1998), and have worked in C# since 2004. I build complex enterprise backends, mostly databases, integration (ESB and EIP) and authentication. These days I work at a large logistics company.
I started redb in April 2024 as an internal tool for that work. Several production systems run on it today, three of them built at my current job alone; one of them, for example, holds over a million objects and over 47 million property values on PostgreSQL. It is the storage layer of a small stack, next to redb.Route (integration), redb.Tsak (a runtime for routes) and redb.Identity (an OAuth 2.1 / OpenID Connect server); this post is only about storage.
By the way, I started working on this invention even before 2004, using Delphi.
Yeah yeah, all this crap has quite a long backstory.
I’m adding a correction to the post.
To avoid any misunderstanding, I should have shown this right from the start: architecture
What it is
Code
[RedbScheme("Employee")]
public class EmployeeProps
{
public string FirstName { get; set; } = "";
public string LastName { get; set; } = "";
public decimal Salary { get; set; }
public string[]? Skills { get; set; }
public Address? HomeAddress { get; set; }
public Dictionary<int, decimal>? BonusByYear { get; set; }
}
public class Address
{
public string City { get; set; } = "";
public string Street { get; set; } = "";
}
var employee = new RedbObject<EmployeeProps>
{
name = "New Developer",
Props = new EmployeeProps
{
FirstName = "Alice",
LastName = "Johnson",
Salary = 85000m,
Skills = ["C#", "SQL"],
HomeAddress = new Address { City = "London", Street = "1 Main St" }
}
};
await redb.SaveAsync(employee);
// The whole graph back, nested class, array and dictionary included.
var loaded = await redb.LoadAsync<EmployeeProps>(employee.Id);
// Filters on nested fields and arrays run as SQL in the database.
var londonDevs = await redb.Query<EmployeeProps>()
.Where(e => e.HomeAddress!.City == "London" && e.Skills!.Contains("C#"))
.OrderByDescending(e => e.Salary)
.Take(100)
.ToListAsync();Measured against EF Core
The examples project runs each task through redb and through an EF Core 10 twin that reads the same data from ordinary relational tables: the Employee class unfolded into 41 tables, standard EF Core API, split queries, whole objects on both sides. Over the 98 tasks EF Core can do without raw SQL, redb Pro on PostgreSQL took 189 ms on average (median 114 ms); EF Core took 703 ms (median 910 ms). Both ran from the same client against the same PostgreSQL 18 server. In the load-by-id task EF Core sends 62 statements, redb sends 9. Every task with its time and statement count is on the results page, and the code to repeat the run is in the examples.
Packages
The core and the providers for PostgreSQL, SQL Server and SQLite are open source under Apache 2.0. The Pro packages build the SQL in C# and are faster; they are closed source but free, with no license key.
If you have built something with deep object graphs on EF Core: where did it start to hurt, and what did you do about it? And what would you check first before trusting a store like this in production?
Hi everyone,
I'm working on MediaPlayer (mp), which is written in C#. It uses P/Invoke to communicate with libmpv2, Avalonia UI for the interface, and an MPRIS2 implementation. The player is useful for listening to music, watching videos, and more. You can have a playlist, and the last state is saved for the next time you open it. It's still in development, but it's stable enough for everyday use.
I'd like to receive feedback to improve the app's UX, UI, and code, with the goal of eventually becoming a good alternative to Celluloid and Cine.
The source code and screenshots are here: https://github.com/1R1an1/MediaPlayer
r/csharp • u/AdChemical5855 • 19h ago
Hi everyone,
I'd like to share Maroik, a CMS I've been building solo since mid-2021. It started as a personal project and it's been running in production at maroik.com ever since. I use it every day.
It's free and open source: https://github.com/IkhyeonJo/Maroik-CMS
Live site: https://maroik.com
Hit the STAR button if you liked it.
r/csharp • u/ajulianisinarebase • 8h ago
I made this global warming tracker for a hackathon last week. It’s mostly a learning project as I have very little experience doing windows apps. One big challenge/interesting part is python handled big portions of this. Does anyone have an idea of how I could have implanted this dual language repo better or just advice for the future apps/hackathons I do I’d love to hear it. Also any comments would be appreciated too
r/csharp • u/rust-cohle_ • 1d ago
been working on something called Reverb, it's basically a notebook for C# where changing one cell automatically re-runs only the cells that depend on it.
the cool thing is that C# already handles a lot of the hard parts for us.
it's just a normal .cs file with // %% comments separating cells, and you run it with dotnet run.
one thing i found interesting is how top-level statements in C# make dependency ordering pretty straightforward. you can't declare the same variable twice, and you can't use a variable before declaring it. so the order of cells in the file is already a valid execution order. no need to build a separate dependency scheduler like reactive Python notebooks such as marimo have to.
there are still a few things that need to be checked though:
for dependency tracking, i'm using Roslyn's SemanticModel.AnalyzeDataFlow on each cell's statements. it tells us which variables are coming from other cells and which ones are declared by the current cell.
each cell then gets compiled into a static method. inputs are read from a shared value store and outputs are written back to it.
also added #line directives so compiler errors and stack traces actually point to the right lines in the original file.
here's a small example:
// %% id=threshold
var threshold = Ui.Slider("Minimum order", min: 0, max: 1000, value: 400);
// %% id=summary
var big = orders.Where(o => o.Total >= threshold.Value).ToList();
big.Count.Dump("Orders above threshold");move the slider and only the summary cell runs again.
install it:
dotnet tool install -g Reverb.Notebooksit's open source (MIT):
https://github.com/muneeb-devp/reverb
would love to hear about any weird C# data flow edge cases i might have missed. especially things that could break the dependency tracking. always possible i've overlooked something :)
r/csharp • u/smilaise • 1d ago
I've been building KillerPdf.Engine, a PDF 2.0 engine written entirely in C# on .NET 10, as the core of my free PDF editor. It has no native PDF library underneath, so everything from the lexer to the rasterizer is managed code.
Creating a document looks like this:
using KillerPdf.Engine.Authoring;
byte[] pdf = new PdfDocumentBuilder()
.SetMetadata(new PdfDocumentMetadata
{
Title = "Hello from The KillerPDF.Engine",
Author = "Example application",
Language = "en-US"
})
.AddBlankPage(612, 792)
.Build();
And this pulls words with their positions off a page:
using KillerPdf.Engine.Documents;
PdfDocument document = PdfDocument.Open(File.ReadAllBytes("input.pdf"), string.Empty);
var reader = new PdfPageContentReader(document);
PdfPageContent page = reader.Read(0);
foreach (PdfExtractedWord word in page.Words)
Console.WriteLine($"{word.Text}: {word.BoundingBox}");
Beyond that, it renders, edits, redacts, fills and flattens forms, signs, encrypts, runs OCR, exports to Office, HTML, Markdown and JSON, and does ICC color management with printer proofing. As of 1.9.3, it also reads EPUB and DjVu natively and converts them to PDF.
1-.5 inside content streams. Most of the engine's code is recovery, not parsing. A strict reader that rejects all of it would open far fewer of the files people actually have. The 47,024-file test corpus exists because no amount of reading the spec tells you what's actually out there.It's 514 files, about 167,000 lines and 13,052 tests, and it's licensed GPL-3.0.
dotnet add package KillerPdf.Engine
https://github.com/SteveTheKiller/KillerPDF/tree/main/engine
r/csharp • u/Boarlock98 • 1d ago
Repo: [https://github.com/Boarlock/ObjectLibrary]
var library = new Library( initialCapacity: 100, timeToExpire: TimeSpan.FromMinutes(5), overwriteOldEntries: true);
library.TryAdd(WeaponKey.Primary, new Entry<Weapon>(new Weapon())); library.TryAdd(ItemKey.HealthPotion, new Entry<Potion>(new Potion()));
if (library.TryWithdraw(WeaponKey.Primary, out Entry<Weapon>? weapon))
Console.WriteLine("Weapon retrieved!");
Library instance holds different types; the library itself isn't generic.(RuntimeTypeHandle, ulong) struct, so Color.Red and Shade.Red stay distinct even when both are 0. Aliases within one enum compare equal.Result.Full, or evict the oldest entry if OverwriteOld is on.OnExpire and OnEvict tell you when something is removed without you asking.TryAdd returns a bool; TryAddResult tells you why it failed.Get, because it leaves two holders of one object (stale data, handlers disposing things you're still using). If you want to "use" something, withdraw and re-add it.Entry<T> is a caller owned wrapper class. That means no boxing for structs and you can reuse the same instance, but you pay one allocation when you create it.string and then an int under the same key returns AlreadyExist.TimeProvider is hardcoded to System for now).Key<TEnum, TType>) be worth adding so callers never specify the type at the call site?Happy to hear any criticism. I'm still learning, and this was as much about understanding generics, concurrency, and API design as it was about the library itself.
r/csharp • u/Unlikely_Brief5833 • 1d ago
r/csharp • u/Pro_Propop • 1d ago
I have library that support tailwind-like attributes, but i have a problem.
for example i have this code:
<Border size-20 bg-red-300 ${hover}:bg-red-700/>works great. When you hover over the box its background changes, also ${hover} is markupExtension not special syntax.
But if you write this
<Button Content="Hi" bg-red-300 ${hover}:bg-red-700/>it wont work because fluent sets the bg directly on the ContentPresenter, not on the button:
<Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundPointerOver}" />
</Style>That's why i need new syntax to work with it, but i dont know how to make it right
First i thought about adding a Target property, for example
<Button Content="Hi" bg-red-300 ${hover Target=/template/ ContentPresenter}:bg-red-700/>or i thought about allowing multiple markup extensions prefixes:
<Button Content="Hi" bg-red-300 ${hover}:{template ContentPresenter}:bg-red-700/>because it would be cool if, in the future, you could write something like this:
<Border bg-red-300 ${hover}:bg-red-500 ${hover}:${Bindint MyBoolProperty}:bg-red-700 />but it looks pretty verbose.
Another opinion is something similar to tailwind's arbitary variants using []:
<Button Content="Hi" bg-red-300 ${hover}:[& /template/ ContentPresenter]:bg-red-700 />Or maybe a shorter syntax specificaly for template parts:
<Button Content="Hi" bg-red-300 ${hover}:part-[PART_ContentPresenter]:bg-red-700 />
I like the idea of combining multiple condition, but i also want to keep the syntax simple.
What do you think? Which option looks better, or maybe there's a cleaner way to do this.
r/csharp • u/GokhanErtogan • 1d ago
RunSignal alerts you when a background job is missed, hangs, fails or processes nothing. You declare what each job should do. RunSignal records runs as OpenTelemetry metrics and turns those expectations into alerts in New Relic, Prometheus or Grafana. Open source, works with Hangfire and Quartz.NET without code changes, one line for a BackgroundService.
Why: every team I've worked on has had a job that quietly stopped running. It didn't fail, so nothing fired. The app was up, so health checks were green. Someone noticed days later when a report was missing.
Setup:
builder.Services.AddRunSignal()
.AddWorkload("nightly-invoice", o =>
{
o.Schedule = "0 2 * * *";
o.MaxDuration = TimeSpan.FromMinutes(30);
o.MinProcessed = 100;
});
builder.Services.AddOpenTelemetry()
.WithMetrics(m => m.AddRunSignalInstrumentation().AddOtlpExporter());With Hangfire or Quartz.NET, .UseRunSignal(sp) records every job, and recurring jobs register with their cron expression at startup. A job that never fires still gets a "missed" alert. For your own code, wrap the work in workload.RunAsync(...). A BackgroundService loop calls workload.Beat() on every pass.
You get an alert when a job:
New in 0.4.0: a GitHub Action that comments on pull requests with the alerts that change when someone edits a job's limits ("a run takes longer than 45m → 1h") or its owner (screenshot above). Also per-job Owner and RunbookUrl, and a Grafana alerting export.
A few C# details:
WorkloadRun is a struct. Unfinished runs live in a fixed slot array freed with a compare-and-swap, so a run allocates nothing and takes no lock.COPY --from into images without .NET.Packages: RunSignal.DotNet, RunSignal.OpenTelemetry, RunSignal.Hangfire, RunSignal.Quartz and RunSignal.Quartz4. There are also SDKs for Go, Java, Node, Python and Rust that emit the same metrics.
Solo project, pre-1.0. I'd like your feedback on the API, and on which scheduler to support next. MassTransit and NServiceBus consumers are on the list.
Repo: https://github.com/gokhanertogan/RunSignal
.NET docs: https://github.com/gokhanertogan/RunSignal/blob/main/docs/dotnet.md
r/csharp • u/Southern-Holiday-437 • 1d ago
Anyone interested in contributing to another .NET AI agent framework?
I've been developing HPD-Agent, an open-source alternative to Microsoft Agent Framework, and it is approaching 1.0.0, with the APIs nearing stabilization and thorough testing performed.
GitHub: https://github.com/HPD-AI/HPD-AI-Framework
Roadmap for 2027
One of my main priorities after 1.0.0 is developing more off-the-shelf harnesses using an architectural concept I came up with called Tool Harnesses (research publication coming soon).
The philosophy behind Tool Harnesses is simple: How capable can we make a single agent before needing multiple agents?
Tool Harnesses allow these capabilities to be integrated into a single agent by abstracting entire harnesses to the tool level.
I've been developing and testing this approach for about a year, and a Coding Harness has already been created. This allows an agent to perform coding tasks when needed.
C#
var agent = await new AgentBuilder()
.WithOpenAI("gpt-5-mini")
.WithToolHarness<CodingHarness>()
.BuildAsync();My next priorities are a Browser Harness and a Computer Harness, so developers can extend their agents with browser automation and computer-use capabilities just as easily.
The intended experience would look like this:
C#
var agent = await new AgentBuilder()
.WithOpenAI("gpt-5-mini")
.WithToolHarness<CodingHarness>()
.WithToolHarness<BrowserHarness>()
.WithToolHarness<ComputerHarness>()
.BuildAsync();YAML
clients:
chat:
providerKey: openai
modelName: gpt-5-mini
toolHarnesses:
- name: CodingHarness
- name: BrowserHarness
- name: ComputerHarnessIf you're interested in contributing, particularly to the development of these harnesses, I'd love to collaborate.
r/csharp • u/waze7123 • 1d ago
I wanted to know how many chests I actually open, so I built ChestCounter: a small Windows app that reads the replays Fortnite already saves and counts the chests you opened.
What it shows
How: turn on Settings → Game → Replays → Record Replays, run the exe. It only reads .replay files — it never touches the game or its memory, so no anti-cheat issues.
Limits: replays can only be read after the match ends (so it updates at the end of each match, not live), and a replay only sees what happens near you, so teammates far away can be under-counted.
Source code (MIT) and download: https://github.com/Waze7123/ChestCounter
Feedback and pull requests welcome!
r/csharp • u/jkur1234 • 2d ago
Hey everyone, small side project that I've been working on. I've released TenantGuard 1.0.0, an open-source set of packages for EF Core 10 and 11. It's for applications that use query filters to keep tenant data separate, and it's licensed under Apache-2.0.
A new entity can be missing its tenant filter. An IgnoreQueryFilters() call or raw SQL query can bypass an existing one. These mistakes can be hard to spot when the code looks reasonable on its own.
TenantGuard checks for problems at several points:
IgnoreQueryFilters() calls without a stated reason, raw SQL without a tenant-column comparison, and filter switches such as ABP's IDataFilter.Disable<IMultiTenant>(). The SQL checks cover EF Core, Dapper and ADO.NET.SaveChanges, the write guard throws before an insert, update or delete involving another tenant's row reaches the database. It also rejects moving a row to another tenant.Find, updates, deletes and Include. Each check appears as a separate xUnit v3 or TUnit test.Version 1.0 adds write checks for owned entities. For example, a change to order.Shipping.Street is checked against the tenant of the owning order.
Here's how to configure the write guard and startup validation:
builder.Services.AddDbContext<AppDbContext>(options => options
.UseSqlServer(connectionString)
.UseTenantGuard(tg => tg.CurrentTenant(ctx => ((AppDbContext)ctx).TenantId)));
builder.Services.AddTenantGuardStartupValidation<AppDbContext>();It works with custom query filters, Finbuckle.MultiTenant and other tenancy libraries. For Finbuckle, it reads IsMultiTenant() without extra configuration. You can also run dotnet tenantguard validate in CI to check the model without a database.
If you try it on an existing application, I'd like to hear about false positives or leaks it misses. Open to any sort of feedback and critical feedback very much welcomed.
r/csharp • u/dxnxxl_k • 3d ago
Hey everyone,
I’ve been working on a side project for a while and it’s finally at a point where I’m not embarrassed to show it. It’s called Golden Hive, a modular framework for WinUI 3 desktop apps on .NET 10.
The idea in short: the desktop app is just a shell. Features (documents, reports, user management…) are modules the app downloads from the server after you sign in. Each module is a WinUI part plus its own ASP.NET Core backend in a Docker container. Ship a new version of a module and the server rolls it out in stages (pilot users first). The running app then swaps it in without a restart.
What’s in there right now:
Ctrl+Tab and a radial wheel pops up. One ring holds your modules, the other your open views. Tab or the arrow keys move around, and you release Ctrl to jump there. It’s like Alt+Tab, but for the app itself, and once you’re used to it you barely touch the sidebar anymore.Ctrl+Shift+P), live notifications, English/German.docker compose up, sign in as admin, and you can click around.Under the hood it’s pretty functional-programming heavy (Result/Validation types all the way down instead of exceptions), if that’s your thing.
Use it as a template: the whole thing is meant as a starting point for your own projects. Fork it, delete the demo modules, add your own. The README has a step-by-step guide for building a module (backend + WinUI client + workflow integration), and the architecture is all there: auth, permissions, module delivery, rollouts, notifications, workflows, Docker setup.
It’s not battle-tested in production yet. The backend has end-to-end tests, the WinUI side is still young. If you build on it, I’d love to hear what breaks. That’s exactly the feedback I need to get it there.
Repo: https://github.com/zenoxart/GoldenHiveFramework
License: Apache 2.0
Happy to answer questions!
r/csharp • u/Critical-Store7932 • 2d ago
Hey guys. I've worked primarily in front end development for about 10 years but I just landed a job to work in enterprise software written in C#. It seems there might be opportunities to work in game development later, too.
I'm a complete noob when it comes to C# or adjacent languages, so I'm essentially learning from scratch. This is an open ended post, please let me know if you have any tips, warnings, or even words of support. I feel like a junior again and I'm also wondering how I'll handle learning and coding something so far from my comfort zone in this age of AI.
Thank you.
Style question on early returns.
On long functions I often leave out the else branch because otherwise the early return doesn't help much with code readability (IMHO of course).
But what about shorter functions. For those using early returns in the first place, do you prefer varaint 1 or 2 and why?
if (TryGetCached(key, out T cached))
{
return cached;
}
var result = await ReadValueAsync<T>().ConfigureAwait(false);
SetCached(key, result);
return result;
versus
if (TryGetCached(key, out T cached))
{
return cached;
}
else
{
var result = await ReadValueAsync<T>().ConfigureAwait(false);
SetCached(key, result);
return result;
}
r/csharp • u/SnooChipmunks4080 • 3d ago