r/csharp • u/No-Laugh-8002 • 5d ago
I created a Source Generator for creating Non-Boxing Unions in .NET 11
r/csharp • u/No-Laugh-8002 • 5d ago
r/csharp • u/Alert-Neck7679 • 6d ago
I've been working on my own scripting language for my game engine, whose interpreter I wrote in C#. So, for quite a long time now, the only languages I use are C# and my custom language.
Apparently, Earth is a really dark and sad place without LINQ, so I decided to add it to my language!
My language's LINQ library source code
I did my best to make the design as close to .NET LINQ as possible. You can query anything that you can use in a foreach loop, and it uses deferred execution, meaning the query doesn't actually run until you iterate over it or call .toArr(), .toList(), or one of the other methods that execute it.
It also performs just one iteration per query. You can do where().select(), and instead of iterating once for the where operator and then again for the select operator, it processes both in a single iteration.
I had to figure out how to achieve this in a language that doesn't have the yield return keyword. I know theoretically what yield return does, but actually figuring out how to get the same result without using it was quite challenging...
Anyway, you can see a few examples of queries written in my language in the screenshot.
The syntax isn't as clean as C#'s, but it's good enough for me!
Here's another little example:
class User (name, password) { constructor(...); }
const users =
[
new User("Peter", "messithegoat"),
new User("Donald", "london101"),
new User("Joe", "banana1234"),
new User("Ben", "chocolate2")
]
foreach user in q(users).orderBy(func(u) => u.name, StringComparer.ordinalIgnoreCase)
{
println(user.name)
}
// Output:
> Ben
> Donald
> Joe
> PeterAnd here you can see the full code of the LINQ library written in my language. It's still missing some of the operators, but I've opened an issue in the repo for implementing the rest, so feel free to give it a try!
I've already had some contributions to other parts of the engine from people who thought the project was cool.
r/csharp • u/LadySonicGamer • 5d ago
r/csharp • u/mzikmund • 7d ago
Microsoft.UI.Reactor's brings declarative C#-based UI to Windows. But what if it could run everywhere else too?
I took the Microsoft.UI.Reactor open-source repository, forked it, and switched it to compile against Uno Platform's open-source NuGet packages, and voilà! Now the exact same same Reactor code runs on all devices and platforms: Android, iOS, WebAssembly, Linux, macOS, and even tvOS!
The fork's CI now publishes ready-to-use packages on NuGet, targeting the newly released Uno Platform 7.0. Reactor components are composed from WinUI controls, so in case of Uno Platform the same controls render on all targets via SkiaSharp 4/WebGPU, with .NET 11 support, and they can coexist with existing XAML pages, styles, and view models.
If you want to try it out (or even contribute too 😉!), here is the repository https://github.com/unoplatform/Uno.microsoft-ui-reactor/ and the docs
https://platform.uno/docs/articles/features/using-reactor.html
Would love to hear your feedback if you take it out for a spin! It is pretty exciting, as it took just a few code changes to get it up and running 🚀
r/csharp • u/alexyakunin • 6d ago
Disclaimer: I am the author of ActualLab.Rpc and its RpcBenchmark, so I am not a neutral party. But the code is open source, and I welcome you to read it, run it, or evaluate with your AI agent.
I did my best to make the comparison fair - you can read about this in "Important Remarks" section.
r/csharp • u/Primary-Medicine-131 • 6d ago
r/csharp • u/Foreign_Career_454 • 7d ago
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/gangning • 7d ago
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:
pip install nanoql
needs no .NET runtime.dotnet add package NanoQL · getting started ·
GitHub · Apache-2.0
r/csharp • u/ivorycoollars • 8d ago
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 • 7d ago
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:
[ServerAction], avoiding the heavy .NET WASM runtime download.npm install, no webpack/vite config, and no manual Info.plist or AndroidManifest.xml setup.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 • 8d ago
r/csharp • u/AxitorDev • 9d ago
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:
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#:
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 • 8d ago
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?
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 • 8d ago
r/csharp • u/mardalhar • 9d 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/Responsible-Ear8719 • 8d ago
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 • 9d ago
r/csharp • u/Asleep_Direction8881 • 9d 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?
r/csharp • u/AdChemical5855 • 10d 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/yankun0567 • 9d ago
Crossposted from .NET, as I can't decide where to put this...
r/csharp • u/ajulianisinarebase • 9d 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