r/csharp

▲ 144 r/csharp+23 crossposts

I would like to share my latest open source local LLM inference tool implemented in C#. It supports models like Gemma4, Qwen3.6 with multi-modal (image, vision, audio), reasoning and function tool. It can run on Windows/MacOS/Linux and fully leverage GPU's capability. The API is completely compatible with OpenAI and Ollama interface.

Really appreciated if you can try it and give me some feedback. If you like it, it will be a big thank you if you can star it. Thank you very much!

u/fuzhongkai — 9 hours ago
▲ 1 r/csharp+1 crossposts

Have you ever wondered how ZoneTree compares with RocksDB, SQLite, and MySQL?

I published a benchmark for ZoneTree against RocksDB, SQLite, and MySQL.

It uses a profile-store workload with individual writes, secondary indexes, reads, lookups, ordered scans, queries, updates, and checksum validation.

2M-profile report:

https://zonetree.dev/docs/benchmark/reference/2m/

Benchmark source:

https://github.com/ZoneTree/ZoneTree

Profile Store Benchmark Relative Throughput

I’d love feedback on the benchmark design and fairness.

reddit.com
u/CallSoft6324 — 4 hours ago
▲ 1 r/csharp+2 crossposts

I wanted to learn Rust, so I built Glance: an open-source WinUI 3 (.NET 10) + Rust hybrid PDF reader for Windows 11.

Hey everyone,

I've been wanting to learn Rust for a while, and I finally decided to dive in by building a practical project: Glance, a fast, lightweight, and native PDF viewer designed for Windows 11. It's completely open-source (MIT license).

Instead of using a resource-heavy framework like Electron or going pure C#, I went with a hybrid architecture to combine the modern Fluent UI capabilities of .NET with the systems-level speed and safety of Rust.

The Stack & Architecture:

  • Frontend: WinUI 3 (.NET 10) leveraging native Mica backdrops, dynamic light/dark theme support, and virtualized scroll grids.
  • Backend (Rust): Google's PDFium library accessed through a raw Rust wrapper (pdfium-render). Rust handles the heavy lifting: document loading, page rendering to bitmaps, and annotation processing.
  • Bridge (FFI): A custom P/Invoke layer. All unmanaged FFI calls are offloaded to background threads using a custom asynchronous task bridge to keep the WinUI main thread buttery smooth (60fps scrolling).
  • Self-Contained MSIX: The installer bundles both the .NET Runtime and Windows App SDK binaries internally, making the app zero-dependency for end-users (no extra runtime prompts).

Key Features Implemented:

  • Side-by-side Split View: Compare two PDFs simultaneously with synchronized scrolling.
  • Visual Welcome Screen: An Evince-style welcome grid showing cover-page thumbnails rendered on the fly.
  • Anotations & Ink: Digital ink drawing for signatures (using a rounded pen pointer), text highlights, and floating sticky notes.
  • Local Persistence: Annotations automatically serialize to a local JSON cache on pointer release with a fully-functional Ctrl + Z undo stack.

Lessons Learned (C# ↔ Rust FFI):

Writing FFI code between a garbage-collected runtime like .NET and a memory-safe language like Rust was the most challenging and rewarding part of this project. I had to learn how to:

  1. Safely marshal complex structures and UTF-8 string pointers across the boundary.
  2. Implement a DllImportResolver to locate and load native binaries dynamically.
  3. Manage memory lifetimes carefully—specifically ensuring native Rust allocations (like page and document pointers) are freed correctly on the Rust side (memory_free) rather than letting the .NET GC touch them.

The code is fully open-source and I would love any feedback on the FFI structure or code design:

https://github.com/jonas1ara/Glance

github.com
u/jonas1ara — 9 hours ago
▲ 10 r/csharp+1 crossposts

Initial alpha release of Zigote - UI framework and game engine

Hello everyone!

I’ve published the first test release of the project: https://github.com/ZigoteProjectOrg/Zigote

First of all, apologies for the current state of the repository. Right now, the UI framework, editor, parts of the game engine, and various system components are all mixed together in one repo. I haven’t had enough time yet to split everything properly, prepare prebuilts, NuGet packages, or a proper installation flow, but I still wanted to make the project public.

I also apologize in advance for any rough architecture, chaotic code, and traces of active development. The project started more as an experiment and pet project — mostly something I built for fun while I was unemployed and on vacation. Over the next couple of months, I’ll likely be busy with job searching and moving, so I’m not sure how actively I’ll be able to work on it.

The release includes a C# and F# gallery, along with some basic examples. You can try it out, look at the API, and get a feel for the general direction. Building requires Zig 0.16+ and .NET 10+.

I’d really appreciate any feedback: what looks interesting, what is unclear, what should be cleaned up first, and which direction the project should take next.

Previous posts:

u/Constant-Junket6038 — 8 hours ago
▲ 29 r/csharp+1 crossposts

FluentStorage v7 released - now with Azure.Identity support

FluentStorage is a .NET library that provides a unified API for cloud storage providers. With v7, both Azure Blob Storage and Azure Files now use the same Azure.Identity authentication flow.

github.com
u/antisergio — 15 hours ago
▲ 5 r/csharp

Code architecture to support input actions being interrupted, overridden etc

What's a good architecture to be able to have a hierarchy of input actions, actions being interupptable by certain actions, but not by others etc. My example is in the context of game development, but the concept still applies.

Let's say the player is carrying a box. They can drop the box by pressing [E]. They carry this box up to a door. Upon pressing [E] while looking at the door, the door should open, the box should not drop

For this example, I can simply code that if the player is looking at a <Door>, then open the <Door>, otherwise if the player has a box in hand, and the player is not looking at a <Door>, drop the box

This is a good solution for this situation, however, how does someone design a system that allows for this sort of hierarchy of action, hierarchy of inputs. I can do it with a long (loooooong) list of if-else statements, however that is not scalable

Since there are only a limited number of keys, and sometimes it's preferred to use only a small set of them, there will be many situations where pressing a key can perform many actions.

Obviously the actions have conditions to them (If looking at door, keypress opens it. If looking at box, keypress picks it up. If holding box, not looking at door, key press drops it), however as stated above, this will result in a long list of if-else statements

I'd appreciate if someone can point me in the right direction, provide some examples where one keypress can do many actions, show me some code etc

Thank you

reddit.com
u/LifeExperienced1 — 16 hours ago
▲ 0 r/csharp+1 crossposts

I wrote a Visual Studio extension for Solidity development and deployment that automatically generates C# smart contract bindings

Visual Studio is heavily used for enterprise development but doesn't have any tooling for Solidity that compares to Visual Studio Code or Remix IDE. Viscous is an open-source Visual Studio extension that tries to bring parity between Visual Studio and other IDEs for Solidity smart contract development.

Features

  • Solidity project system for Visual Studio featuring Solidity compiler integration and NPM dependency management. Integrates with the Visual Studio New Project… and Open Folder… dialogs.
  • Uses the vscode-solidity language server for syntax highlighting, hover information, IntelliSense, and linting.
  • Solidity compiler integration with MSBuild and the Visual Studio Build command - compile Solidity projects and individual files from the IDE with errors reported in the Errors tool window.
  • Generate C# bindings to Solidity smart contracts automatically using Nethereum.
  • Manage EVM networks, endpoints, accounts, deploy profiles, and deployed contracts from the Blockchain Explorer tool window.
  • Deploy a compiled contract to a blockchain network and call its functions from inside Visual Studio.
  • Find vulnerabilities and code‑quality issues with Slither static analysis inside Visual Studio.

Requirements

  • Visual Studio 2022 and above
  • A recent version of Node.js or compatible runtime
  • Python 3.8+

Getting Started

Note that this is a pre-release so don't use it for deploying anything to production. Feedback welcome.

u/allisterb — 1 day ago
▲ 1 r/csharp

Question: Referencing one script in another script

Hello! I'm not exactly sure how specific my situation is, or if I'm going about this the complete wrong way, but I am rather new to C# and coding in general. I'm making a visual novel in Unity, and I have quite a few assets I've made that I need to reference in each "sequence" of the game.

In the Scene where I have all my gameplay, I have a script for a Game Manager and a script for Sequence_01. In the Game Manager, I basically have a list of all the assets I'll need--the textbox, the character sprites, the items, and the fade in/fade out screen. My thought process was to put it all in the Game Manager, then reference the Game Manager script in the Sequence_01 script so I could do that for all the other Sequences as well.

Is there a way to do this, or should I scrap this idea and try something else? Thank you!

If screenshots are needed, I can give them as well.

reddit.com
u/RylieLightBulb — 1 day ago
▲ 80 r/csharp+1 crossposts

I made a tool that generates Markdown-friendly database schema

I built with C# a small tool called DbSketch.

The idea is: point it at the real database, and it generates schema documentation that can live in your repository. It reads tables, columns, primary keys, foreign keys, and database comments, then outputs diagram-as-code formats like Mermaid, Graphviz DOT.

I originally made it because I wanted a lightweight way to keep database structure visible and version-controlled. It also useful when working with coding agents like Claude or Codex. Instead of trying to guess db structure from code or from migrations script (burning tokens) it could simply read it from markdown files.

NOTE: Mermaid format could show relation only as table to table lines VS dot format could show filed to field relation!

GitHub: https://github.com/DimonSmart/DbSketch

I’d really appreciate feedback from people who work with database-heavy projects. Does this solve a real annoyance for you? Is anything missing or unclear? Suggestions, criticism, feature ideas, and PRs are very welcome.

u/DimonSmart — 1 day ago
▲ 11 r/csharp

Is there a way to know the exact byte layout of a class at runtime?

Title basically. I'm trying to hack together a hobby project where I stackalloc a Span&lt;byte&gt; and bitcast it to a class instance, but I need to know the exact layout of the object and potentially the layout of its header. Are there any tools (or any reflection methods) that are able to give me that info?

reddit.com
u/AnnoyingMemer — 1 day ago
▲ 0 r/csharp+1 crossposts

DataVo v0.1 Alpha: I built a C#-native embedded database that hits 2.3M OPS by bypassing the GC

I’ve been working on DataVo, an open-source, embedded SQL + vector engine written entirely in C#. There are no native C/C++ binaries to bundle or cross-platform targets to fight with, it’s just a single managed library.

When you build a database engine in .NET, the garbage collector is your ultimate bottleneck. Object allocations on every operation completely destroy your P99 latency due to Gen 0 churn. To get around this, the entire engine is designed for zero steady-state allocations in the hot path.

A few ways it does that:

  • The write path is an LSM tree where the MemTable rents 32MB slabs from ArrayPool&lt;byte&gt;.Shared. Rows are serialized directly into the raw byte arrays using a bump allocator, so the GC never even tracks them.
  • It uses Roslyn source generators to compile query execution paths at build time. If you annotate a query, it generates a static, typed row reader that maps straight to your CLR type, skipping runtime AST parsing and avoiding object boxing.
  • Vector search runs flat and HNSW paths entirely over contiguous managed memory using System.Numerics.Tensors, eliminating the P/Invoke marshaling tax.

I ran the benchmarks on a standard, noisy GitHub Actions Linux runner against SQLite and LiteDB to see how it handles real-world cloud hardware. On a mixed concurrent workload, it hit 2,368,026 ops/sec (SQLite hit ~199k on the same box). For a 10k vector workload, it allocated about 10MB of memory, while LiteDB's brute-force path churned through 208GB of garbage.

To be entirely transparent about where it loses right now: SQLite's native sqlite-vec extension has a tighter C-kernel and still wins on single-query vector latency (3.1ms vs 10.5ms). Also, my current HNSW graph construction is single-threaded and brutally slow, taking 160 seconds to build an index that SQLite finishes in under a second. That's the next big optimization target.

The repo and deep-dive article are below. I'd love to get your thoughts on the architecture or have you guys try to break it.

Full Write-up: https://medium.com/@arintonakos/bypassing-the-net-gc-how-i-hit-2-3-million-ops-with-a-c-native-embedded-database-bfeac66c5cac

GitHub Repo: https://github.com/ArintonAkos/DataVo-DBMS

reddit.com
u/arintonakos12 — 1 day ago
▲ 0 r/csharp

AI not following “using” / imports

I’m mainly in typescript codebases for most of my day. AI is going great at understanding imports at the top of the file.

But for csharp, I often see AI making bad assumptions for what the code is doing … it thinks it’s running some other code because the names of functions match but the namespaces don’t.

This is definitely a reproducible problem that gets me often and I am in the middle of refactoring my codebase to avoid this kind of problem.

I wanted to ask this community if you see or experience the same thing… and how you solved it.

reddit.com
u/quincycs — 1 day ago
▲ 7 r/csharp+1 crossposts

Server recommendation where should I deploy my .net 10 api

Building a .net 10 web api for a client and I am overwhelmed by server choices. Azure vs AWS or Digital ocean, managed vs unmanaged VPS. What is your go to choice when deploying for a client, Tech-stack
Redis, PostgreSQL, Blob Storage required. S3 or Azure Blob

reddit.com
u/nahum_wg — 2 days ago
▲ 1 r/csharp+2 crossposts

HPD-AI Framework: Make AI agents, RAG, Auth, TUI, Workflows in .NET

Hi guys,

I would like to introduce the HPD-AI Framework. It is an all in one solution for specific parts of an ai application development: AI Agents, RAG, Workflows, Machine Learning and even TUI application development in .NET. I am still not done and everything is pre 1.0.0  but I wanted to let you guys know and I hope this brings value to any one is the community that might have needed something like this. 

Think of this like Tanstack but for mainly ai related stuff and its .NET

Check it out here if you are curious, if you have any questions let me know in the comments.

Documentation for all isnt ready yet but coming pretty soon.

https://github.com/HPD-AI/HPD-AI-Framework.git

reddit.com
▲ 0 r/csharp+1 crossposts

Best way to change app storage location for end-to-end testing

I'm playing with a toy project to learn some programming techniques. It's a C#, WPF app. I do dependency injection manually, without containers.

The app needs to store a SQLite DB somewhere, which defaults to AppData/Local. During composition (in App.xaml.cs), the default path is injected into a repository class, and away we go.

I feel like I should use a temporary test storage location that can be cleanly setup and torn down without interfering with any actual app installs on my machine.

For unit testing, it's easy enough to pass in something else to the repository class. For end-to-end testing (using FlaUI) the default path is used. I'm looking for options to change this default path at test-time. I've gone through several ideas:

  • Command-line argument: Don't like this idea, as there is no purpose for it outside of testing. The underlying logic would wind up in production code.
  • Command-line argument, but with #if DEBUG directive: Strips the logic, but now I can't end-to-end test Release.
  • Config file: The app still needs a default place to look for it, so I'm back to square one.
  • Temporarily override the LOCALAPPDATA environment variable during testing: GetFolderPath() does not use the environment variable to resolve the path.
  • Reference LOCALAPPDATA instead of GetFolderPath(), and temporarily override LOCALAPPDATA during testing: This is the best I got so far

This isn't a real app and I'm not a real programmer, but nevertheless I'd like some opinions on what the best technique would be. Shirley I'm not the first to come up against this.

reddit.com
u/TseehnMarhn — 1 day ago
▲ 0 r/csharp

Am i learning the right way? Cuz am feeling guilty

"I'm a beginner, I barely understand how big the programming world is. And I don't know how to express my feelings the right way. Please be patient.

Hey, I'm a second-year college student who studies Computer Science. I'm learning Java at the university; it's fun and all. This summer, I decided to learn C#, and I did. I finished all its basics in only 2-3 days, and I memorized it well.

I'm trying to understand logic, how to fix problems, how to make something that actually works, and I think I'm starting to understand it. So I decided to build my own small projects because I'm in love with C# for some reason, so I opened my IDE and Gemini.

I started to code, then Gemini suggested that I should use the HTTP library (since my project was about pulling some data from the browser).

Then it hit me, I don't know what the HTTP library is. Should I learn it? Am I wrong for making the AI do the work and me just watching without understanding and memorizing the library's codes? Do experts use AI to put a bunch of code into their projects? Should i memorise the library it self?

I feel guilty and like am betraying my self, i want TO LEARN it my self.

Am i doing good? Am i doing bad? I need an expert pov.

TLDR;

Should i learn and memorise librarys? ( like the http library for example ) or just make AI do the work?

reddit.com
u/V606R — 1 day ago
▲ 0 r/csharp

Autofac Not Resolving IIndex&lt;&gt;

Solved!

The solution, courtesy of u/kant8, is to resolve an `IList` or `IEnumerable` of the registered types, not a `List`. Because trying to resolve a concrete type like a `List` sends Autofac hunting for the corresponding list registered as itself. Which won't work.

=========================

I've registered a number of types via a common interface they share, keyed by different byte values:

builder.RegisterType(concreteType)
.Keyed<IJpgSegmentGenerator>(id)
.As<IJpgSegmentGenerator>()
.SingleInstance();

concreteType is the type being registered. All concrete types share a common interface, IJpgSegmentGenerator. id is a byte value distinguishing the different concrete types, some of which share the same key (which I’ve read online Autofac supports…unless the references I found are wrong 😀).

The registrations are successful, because after building the Autofac container I can see the registrations via Container.ComponentRegistry.Registrations (see first image in gallery above).

The individual registrations show the correct byte keys (see second image in gallery above for a zoomed in view of one registration).

However, the following code fails to resolve IIndex

var lazyList = Container.Resolve<IIndex<byte, List<Lazy<IJpgSegmentGenerator>>>>();

lazyList.TryGetValue( 237, out var generators ).Should().BeTrue();

(The above code is inside an XUnit test, hence the Should() reference)

I've checked that the service type is specified identically in both the registration and resolution code, and unless I'm going blind they sure seem to match, as does the type of the key. I've also tried not resolving to Lazy<>, and that fails to.

Thoughts?

u/MotorcycleMayor — 1 day ago
▲ 3 r/csharp+1 crossposts

I'm building a Spring Batch equivalent for .NET — because we've been deserved one for years

Every time I've had to build a batch processing pipeline in .NET, I end up duct-taping together the same primitives: a foreach loop, some retry logic, a table to track what ran, manual skip handling, and a prayer. Java devs have had Spring Batch for this since 2007. We have nothing.

So I started Conveyor.Batch — an open-source, production-grade batch processing framework for .NET 8+ that brings chunk-oriented processing, job repositories, restartability, skip/retry policies, and partitioning as first-class citizens to the ecosystem.

The core model should feel familiar if you've done any ETL work:

// Reader streams items asynchronously
public interface IItemReader&lt;out TInput&gt;
{
    IAsyncEnumerable&lt;TInput&gt; ReadAsync(
        StepExecutionContext context,
        CancellationToken cancellationToken);
}

// Processor transforms one item — return null to skip it
public interface IItemProcessor&lt;in TInput, TOutput&gt;
{
    ValueTask&lt;TOutput?&gt; ProcessAsync(
        TInput item,
        StepExecutionContext context,
        CancellationToken cancellationToken);
}

// Writer receives a committed chunk
public interface IItemWriter&lt;in TOutput&gt;
{
    ValueTask WriteAsync(
        IReadOnlyList&lt;TOutput&gt; items,
        StepExecutionContext context,
        CancellationToken cancellationToken);
}

The engine reads in configurable chunks, applies your skip/retry policies per item, flushes committed chunks to the writer, and tracks everything in a job repository so failed runs can restart from where they left off — not from scratch.

What's planned:

  • Conveyor.Batch — core chunk engine + abstractions
  • Conveyor.Batch.EntityFrameworkCore — persistent job repository (Postgres, SQL Server, SQLite)
  • Conveyor.Batch.IO — flat file, JSON, XML readers/writers
  • Conveyor.Batch.Http — paginated HTTP reader
  • Conveyor.Batch.Hosting — Worker Service integration

Honest status: this is early. The abstractions are defined, the chunk engine design is locked, and we're scaffolding now. Nothing is on NuGet yet.

I'm posting because I want to build this with the community rather than drop a v1.0 announcement six months from now. A few questions I'd genuinely like input on:

  1. What batch use cases do you hit most often in .NET that you'd want Conveyor to handle well?
  2. Any prior art I should study (beyond Spring Batch itself)?
  3. Would you rather see a PostgreSQL-first or SQLite-first job repository for v0?

GitHub: conveyor-batch/conveyor.batch — watch/star if you want to follow along.

u/yazidaqel — 2 days ago
▲ 4 r/csharp

Pre-release UI library updates + Gallery App screenshots

Support for multiple languages, as well as libraries for graphing and animation, has already been implemented. Work is currently underway to clean up the code and prepare it for release.

Screenshots down in comments.

I am primarily a Flutter developer myself; I started this project after experimenting with WGPU. As C# developers, what would you like to see in a UI framework during the early stages of development?

Previous post

UPD: https://github.com/ZigoteProjectOrg/Zigote/tree/main

reddit.com
u/Constant-Junket6038 — 2 days ago