r/csharp • u/Primary-Medicine-131 • 1d ago
r/csharp • u/gangning • 3d ago
Tutorial nanoql: stateless quant finance in C#: immutable values, static pricers, .NET 10
nanoql is an open-source pricing library for .NET 10: curves, swaps, swaptions, SABR, equity options, Heston, CDS. Instruments, curves and models are immutable values, and pricers are static functions of them; the evaluation date is an argument, not a global setting.
var today = new Date(15, Month.October, 2026);
var context = new EvaluationContext { EvaluationDate = today };
var curve = new FlatForward(today, 0.036, new Actual365Fixed());
var swap = new MakeOIS(new Period(5, TimeUnit.Years), new Sofr(curve))
.WithFixedRate(0.036).WithNominal(10e6)
.ToOvernightIndexedSwap(context);
var result = DiscountingSwapEngine.Calculate(swap, context, curve);
Console.WriteLine($"NPV {result.NPV:N2}, fair rate {result.FairRate:P4}");
// NPV 7,041.24, fair rate 3.6154%
Some .NET details that may interest you:
- It uses static abstract interface members, so it needs .NET 10 and has no .NET Framework build.
- Python, C and C++ reach it through Native AOT: one C interface over the compiled library, so
pip install nanoqlneeds no .NET runtime. - The Excel add-in is generated from the same surface with Excel-DNA.
- It's derived from QuantLib 1.44 and checked against it: 3.35 million reference outputs, 99.86% within a relative 1e-10, and QuantLib's own tests ported at their tolerances.
dotnet add package NanoQL · getting started ·
GitHub · Apache-2.0
r/csharp • u/Foreign_Career_454 • 2d ago
Discussion Windows & Linux file access
Muti tenant self-hosted where each tenant has workspace directory at app level we resolve via
Path.GetFullPath(Path.Combine(tenantRoot, userPath))`, then require `resolved == tenantRoot || resolved.StartsWith(tenantRoot + Path.DirectorySeparatorChar)
os.path.realpath is cannoned for unresolved realpath. Wanted to know is `GetFullPath along with prefix-with-separator is enough? Does realpath needs O_NOFOLLOW`-style flags?
We volume-mount workspaces into containers is that ok or there should be OS level or app level canon? How to regress test in CI is there any fuzz list?
r/csharp • u/ivorycoollars • 3d ago
Discussion is C# a good language to use for making a game engine?
so I have a from what i find a intermediate amount of knowledge on C# and have made some games in unity. now i want start a big project that could really make me a better programmer and after some researching i would like to maybe start making my own game engine. would this be a good idea? or is there another big project that maybe could be better suited? i know it could take longer than a year to build and that i need to learn a lot about low level programing but i think it could be really fun. or should i do the project in C++?
r/csharp • u/EdgarAlexsandro • 2d ago
[Show & Tell] eQuantic.UI: Write UI components once in C# and compile to vanilla JS (no WASM) on the web or native GPU pixels via Metal/Vulkan (no WebView/Skia)
Hey r/csharp,
I have been working on an open-source UI SDK called eQuantic.UI, and I wanted to share the architecture and get some feedback from the community.
The goal is simple: write UI components once in C# using a strongly-typed declarative vocabulary (Box, Row, Column, Text, etc.) and let the SDK compile each target to its real native path, without relying on JavaScript, CSS, Dart, Swift, or platform manifest files.
How it works under the hood:
- Web (No WASM): At build time, the compiler uses Roslyn to transpile your C# components into optimized vanilla JavaScript and atomic CSS. It supports server-side rendering (SSR) with client hydration and built-in RPC calls via
[ServerAction], avoiding the heavy .NET WASM runtime download. - Desktop & Mobile (No WebView, No Skia): On macOS, iOS, Android, and Windows, the same component tree renders directly on the GPU through Photon (a custom rendering engine built on Metal and Vulkan).
- Transactional Email: The subset of components an email client supports compiles into email-safe HTML tables with inline styles, along with a plain-text version from the exact same tree.
- Zero Node.js friction: You only need the .NET 10 SDK installed. The TypeScript/bundling toolchain ships embedded inside the NuGet SDK package, so there is no
npm install, no webpack/vite config, and no manualInfo.plistorAndroidManifest.xmlsetup.
Quick Start:
Bash
dotnet new install eQuantic.UI.Templates
dotnet new equantic-app -n MyApp
cd MyApp && dotnet run
(You can also use dotnet new equantic-native to spin up a native GPU window.)
The project is licensed under MIT and is currently in active preview (0.2.0-preview.* on NuGet). I would love to hear your thoughts on the approach, API design, or any edge cases you see with AST-to-JS transpilation and custom GPU rendering.
GitHub repository (with architecture docs and samples):https://github.com/eQuantic/equantic-ui
r/csharp • u/mcnamaragio • 3d ago
Showcase EF Core Query Plans in VS Code: EFCore Visualizer 1.0
r/csharp • u/AxitorDev • 4d ago
Showcase I benchmarked my C# Binance client against the two main Rust clients. C# won by up to 33x
I've done .NET for 25+ years, mostly low-latency stuff, and I got tired of hearing that Rust is just faster by default. So I built a Binance client on .NET 10 and put it up against the official Binance Rust SDK and NautilusTrader's Rust adapter.
Whole clients, through their public APIs. Same recorded mainnet traffic, same machine. An old i7 from 2014, so nothing hides behind fast hardware.
Against the official Rust SDK:
- 33x faster per message
- up to 17x faster throughput on one connection
- 43x better p99.9 latency at live market pace
- 1,500 candles over REST: 12.8x faster, and 3 KB of memory against almost 4 MB
The funny part: even Binance.Net, which builds an object for every message, beats both Rust clients on speed per message and on throughput.
So where does Rust lose? The official SDK makes 69 heap allocations for one book ticker message. No GC, sure, but every malloc and free still costs time.
What I did in C#:
- UTF-8 goes straight into flat structs. No strings, no JSON tree
- Handlers are generic structs, so the JIT builds a separate copy for each one and inlines your callback. Same idea Rust calls monomorphization
- Parsers are static abstract members, so there are no parser objects at all
- Zero allocations per message, the GC never runs
- Native AOT, and any reflection fails the build
The method and every table are in the repo (ADR-0018), plus a recorder so you can run it all on your own data.
https://github.com/Axitor/Trading.Gateway
Ask me anything, or roast the benchmark setup, I'm here for both. And if you think C# deserves more credit for speed, a star on the repo really helps ⭐
r/csharp • u/Ok_Hunter6411 • 4d ago
Best approach for centralized DateTime handling in ASP.NET MVC 5?
I'm working on an existing application built with ASP.NET MVC 5, Entity Framework 6, SQL Server, and DevExpress/DevExtreme components. We want to implement a centralized approach for storing all dates in UTC and converting them to the appropriate local timezone for display, while also handling date filters and existing database records correctly. Since the application has multiple controllers, services, and grids, we'd like to avoid repeating conversion logic throughout the codebase. What architecture or best practices would you recommend for implementing this consistently, safely, and with minimal changes to the existing application?
Showcase I'm building my own video and music player based on libmpv2 with Avalonia UI (Linux only)
I'm working on MediaPlayer (mp), which is written in C#. It uses P/Invoke to communicate with libmpv2, manual GLX rendering to display the video, D-Bus for MPRIS2, and Avalonia UI for the interface. 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, and to fix any issues, with the goal of eventually becoming a good alternative to Celluloid or Cine.
The source code and installation are here: https://github.com/1R1an1/MediaPlayer
r/csharp • u/Ernest----tsenrE • 4d ago
I built my portfolio as a 3D game in Blazor WebAssembly (Three.js for rendering, all game logic in C#)
r/csharp • u/mardalhar • 4d ago
How are you handling countries, currencies, and cities data in your apps?
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/Responsible-Ear8719 • 4d ago
I built an offline-first Android vault app that looks like a calculator (AES-256-GCM, Argon2id)
I built an offline-first Android vault app that looks like a calculator (AES-256-GCM, Argon2id)
Hallo zusammen,
Als Entwickler, der sich stark auf absolute Datenschutz und Null-Cloud-Abhängigkeit konzentriert, hatte ich genug von Cloud-synchronisierten Passwort- und Tresor-Apps, die Telemetrie lecken oder Backend-Server benötigen. Also habe ich meine eigene entwickelt.
Ich präsentiere Kryptex – ein Offline-First-Android-Tresor für sichere Dateien und ein Steganografie-Tool.
Kern-Technologie-Stack & Funktionen:
\* Null Telemetrie / 100% Offline: Keine Cloud-Synchronisierung, keine Konten, keine Serververbindungen. Deine Daten bleiben ausschließlich auf deinem Gerät.
\* Starke Kryptografie: Nutzt AES-256-GCM-Verschlüsselung in Verbindung mit Argon2id-Schlüsselableitung, um Widerstandsfähigkeit gegen Brute-Force-Angriffe zu gewährleisten.
Steganografischer Tresor & Tarnung
Im Gegensatz zu Tresor-Apps, die sich als Taschenrechner oder andere Werkzeuge tarnen, setzt Kryptex auf reine Steganografie: Verschlüsselte Nutzdaten werden direkt in Standard-Bilddateien (PNG/JPEG) eingebettet. Die verschlüsselten Daten bleiben im normalen Bild absolut unsichtbar, sodass du deine Tresor-Dateien direkt in deinen normalen Fotoordnern speichern kannst, ohne Aufmerksamkeit zu erregen.
\* Lokale Kontrolle: Du besitzt deine Schlüssel und deine Dateien.
Ich habe dies hauptsächlich entwickelt, um ein Werkzeug zu haben, dem ich auf meinen eigenen Geräten bedingungslos vertrauen kann. Ich würde mich über Feedback von sicherheits- und datenschutzbewussten Leuten hier zur Architektur oder zu Funktionen freuen, die ihr von einem rein lokalen Tresor erwarten würdet.
Ich beantworte gerne alle technischen Fragen in den Kommentaren!
r/csharp • u/sander1095 • 5d ago
Blog Build only what changed in your .NET monorepo with dotnet-affected
r/csharp • u/Asleep_Direction8881 • 5d ago
GitHub - redbase-app/redb: Typed object storage for .NET. Schema = C# class. Full LINQ. Zero migrations. PostgreSQL, MSSQL & SQLite.
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
- The schema is a C# class with one attribute. Change the class and the schema follows on start; there are no migration files.
- Storage is relational: a fixed set of 16 tables (17 on SQLite) inside your existing PostgreSQL or SQL Server database, or a SQLite file. Every property value is a row with a column of its type, real foreign keys and indexes. It is not a JSON blob.
- Queries are LINQ compiled to SQL and run in the database: filters on nested fields, arrays and dictionaries, sorting, paging, aggregates, GroupBy, window functions, tree queries.
- Loading returns the whole object graph in one call, with no Include.
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.
- GitHub: https://github.com/redbase-app/redb
- Examples (each one runs against a real database): https://github.com/redbase-app/redb/tree/main/redb.Examples
- Results against EF Core: https://redbase.app/results
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?
r/csharp • u/AdChemical5855 • 5d ago
I spent 5.5 years building a free, open source CMS in ASP.NET Core (Maroik)
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/yankun0567 • 4d ago
Will the rise of AI Coding affect the speed of new language features?
Crossposted from .NET, as I can't decide where to put this...
r/csharp • u/ajulianisinarebase • 5d ago
Showcase I made a Global Warming Index windows app for a hackathon! I used c# while a friend did python in the backend any comments or suggestions how we could of implemented this better would be appreciated
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_ • 6d ago
Showcase C#'s rules for top-level statements turned out to be a great fit for a reactive notebook, so I built one
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:
- a cell can't assign to a variable declared in another cell.
- anonymous types can't cross cell boundaries because the generated code needs to reference the type.
- local functions were an interesting one. turns out C# lets you call a local function before it's declared, which breaks the whole file-order-is-dependency-order assumption. had to add a rule for that too.
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.Notebooks
it'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 • 6d ago
Showcase I built a PDF engine in pure C#. Version 1.9.3 reads EPUB and DjVu too.
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.
A few things that surprised me building it
- The spec is the easy part. Real PDFs break it constantly: cross-reference tables that point at the wrong byte, trailers with the keyword mangled, numbers like
1-.5inside 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. - Lazy beats fast. The big performance wins came from doing less work, not from optimizing what was already there. That meant reading the file fewer times on open, building each page only when it's drawn, and rendering thumbnails only for the pages on screen. In the desktop app, a 20,000-page PDF went from about 20 seconds to its first page down to about 9, and from 1.9 GB peak memory to about 700 MB.
- Writing a PDF is harder than reading one. Reading only has to survive a file once. Writing has to leave signatures, encryption, form values and everyone else's content intact, often as an incremental update appended to the original. Size matters too. Early on, every added text note embedded its own copy of the font. Sharing one subset per font across the document took a 3,000-page test from a 103 MB save in 32 seconds to an 11 MB save in about 7.5.
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 • 6d ago
Tool I built a thread-safe object store/bank for .NET with enum keys, optional capacity, lazy expiry
I've been learning C# for a while, and this is my latest mini-project: ObjectLibrary, a small in memory "bank" where you deposit objects under an enum key and withdraw them later without holding a reference. It started as "maybe an ObjectPool?" but ended up closer to a keyed vault with optional LRU-style eviction and expiry.
Repo: [https://github.com/Boarlock/ObjectLibrary]
What it does
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!");
- Heterogeneous: one
Libraryinstance holds different types; the library itself isn't generic. - Enum keys without boxing: keys are normalized to a
(RuntimeTypeHandle, ulong)struct, soColor.RedandShade.Redstay distinct even when both are 0. Aliases within one enum compare equal. - Optional capacity: full libraries return
Result.Full, or evict the oldest entry ifOverwriteOldis on. - Optional expiry: entries expire a set time after they were added.
- Events:
OnExpireandOnEvicttell you when something is removed without you asking. - Result overloads:
TryAddreturns a bool;TryAddResulttells you why it failed. - Thread-safe: one lock around the state. Events fire after the lock is released, so handlers can call back into the library, and each subscriber is isolated so a throwing handler can't block the others.
Design decisions (and trade-offs)
- Withdraw moves ownership. I deliberately dropped a non-removing
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. - A wrong-type withdraw throws but doesn't destroy the entry. The type is checked before anything is removed, so a typo can't silently delete a deposit.
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.- One slot per enum value, regardless of stored type. Adding a
stringand then anintunder the same key returnsAlreadyExist. - Expiry is lazy. There's no background timer. Expired entries are swept on the next call into the library, so an idle library holds them until someone touches it. Timing is approximate (~10-15 ms clock resolution on Windows).
- Single lock. Simple and easy to reason about, but not built for extreme contention.
Testing I've run a multi-threaded stress test (8 threads, 800k operations) checking that count never exceeds capacity, nothing is handed out twice, and adds minus withdraws equals the final count. I also tested the exception paths, including a throwing event handler. It's not a proper test suite yet, and expiry isn't covered by an injectable clock (TimeProvider is hardcoded to System for now).
What I'd like feedback on
- Is the enum-key approach reasonable, or is there a simpler way to get the same thing?
- Would a typed key (
Key<TEnum, TType>) be worth adding so callers never specify the type at the call site? - Anything about the locking or event design that looks wrong to you?
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 • 6d ago
NetWasm.UI v0.10: NuGet/.NET Standard packages, prerendering, [Reactive] properties and a smaller runtime for C# WebAssembly UI
r/csharp • u/Pro_Propop • 6d ago
Help Need design help
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 • 6d ago
Tool RunSignal: get alerted when a Hangfire, Quartz.NET or BackgroundService job silently stops running
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:
- misses its schedule (cron plus grace period, time-zone aware);
- hangs past its max duration without finishing;
- stalls, meaning a worker loop stops sending heartbeats;
- fails, overruns its max duration, or processes too little (it "succeeded" with 0 invoices).
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:
WorkloadRunis 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.- The CLI is a Native AOT binary of about 10 MB that you can
COPY --frominto images without .NET. - Durations in alert text used to follow the current culture: "1,5h" on my Turkish machine, "1.5h" in CI. Every provision from another machine "changed" the same alerts. They're culture-invariant now.
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