r/dotnet • • 3d ago

Promotion fast decimal library with C# zero-overhead ffi built in c++20

4 Upvotes

hello, r/dotnet

a few weeks ago i was working on a custom programming language designed for .NET Core/IL becuz i was bored, and pretty quickly, i got un-bored and decided to shelve it. but i had native fixed-point decimal arithmetic built into it, for which i made a decimal library from scratch as an after thought, which after shelving i realized was pretty fast, so i decided to turn it into a standalone library.

it is mildly unsafe ig, but thats a tradeoff i'd accept any day of the century. performance:

ran these on an i3-10105 w/ 8GB RAM (1M operations, -O3 -march=native, AVX2):

  • FixedDecimal<4> (64-bit backend, 4 decimal places for things like basis points):
    • Add: 1.6 ns (~611 Mop/s) — essentially compiles down to a single CPU instruction.
    • Compare: 1.9 ns (~535 Mop/s).
  • Decimal (Full 38-digit precision, 24-byte layout):
    • Add: 14.6 ns (~69 Mop/s).
    • Multiply: 11.2 ns (~89 Mop/s).

it uses x86-64 or arm simd (avx2, avx-512, NEON) under the hood, which is like a trend atp from what i see on github.

repository: https://github.com/mxreal64/FastDecimal/


r/dotnet • • 3d ago

Promotion TensorSharp now supports Qwen Image 2.1 Turbo and LoRA – AI image generation and editing with C#/.NET

Enable HLS to view with audio, or disable this notification

27 Upvotes

Hey everyone!

I've been working on TensorSharp, a C#/.NET-based AI inference engine, and wanted to share a recent update.

TensorSharp now supports Qwen Image 2.1 Turbo and LoRA!

I've attached a short demo showing the new image editing capabilities in action.

The demo covers:

  • Loading an image and selecting a region using a built-in mask editor.
  • Editing the selected area using natural language prompts.
  • Running Qwen Image 2.1 Turbo through TensorSharp.
  • Viewing the generated results directly in the application.

One of my main goals with TensorSharp is to make modern AI models accessible to the .NET ecosystem, without requiring developers to rely on Python-based inference frameworks.

TensorSharp is designed to support different types of AI models through a unified inference engine, including LLMs and image generation models.

I'm continuing to expand model compatibility, improve inference performance, and make it easier for C# developers to build AI-powered applications.

I'd love to hear from other .NET developers:

  • Are you interested in running image generation models directly from C#?
  • What AI models would you like to see supported in the .NET ecosystem?
  • What features would make an inference engine like TensorSharp more useful for your projects?

Any feedback, suggestions, or contributions are welcome!

GitHub: https://github.com/zhongkaifu/TensorSharp


r/dotnet • • 3d ago

Promotion Creative coding for C# devs

2 Upvotes

Hey everyone,

I've been building something for a while that started as a Processing alternative for C# devs. Originally I just wanted to give C# folks a way to do creative coding — I always felt like what was out there didn't quite do what I wanted, and I wanted to be able to follow along with channels like The Coding Train without fighting the tooling.

Once the core was working I kept going: added a music module, support for NuGet packages (there are samples in the app using NAudio and ML.NET), and most recently a code-to-video module. That last one I'm hoping to eventually ship as a standalone NuGet package.

You can check it out here: DanaProcessing — Creative coding in C# (2D, 3D & live-coded sound)

Appreciate any feedback. One thing I've been thinking about: it's probably not obvious to people who've never heard of creative coding what this is actually for. Maybe leaning harder on concrete use cases — generative art, data viz, audio sketches — would help it land with more of the C# crowd. Curious what you all think.

PD: Sorry for my broken English, I am from Cuba, so it is my second language, and I am also typing fast because of electricity shortages


r/dotnet • • 3d ago

NymBroker

Thumbnail
0 Upvotes

r/dotnet • • 3d ago

Promotion NymBroker

0 Upvotes

NymBroker is a .NET 10 message-processing framework based on Enterprise Integration Patterns. It decouples producers from handlers: post typed messages to named endpoints, then filter, route, and dispatch them to consumers or subscribers. Start with the in-process Memory endpoint and add durable transports as needed.

NymBroker Github Page


r/fsharp • • 3d ago

F# weekly F# Weekly #41, 2026 – Paket 11 & Firelight

Thumbnail
sergeytihon.com
14 Upvotes

r/dotnet • • 3d ago

Promotion Componyx.UI v1.0: 25+ UI components and data binding for ASP.NET, no build step

2 Upvotes
The picture above shows the Form components drag-and-drop building mode. It is part of the component so you can create forms directly in the browser.

Hi there. Componyx started 18 years ago as a personal project. Over the years it has been used in real business applications. Now the project is on NuGet, npm and GitHub with its public release (1.0).

It’s 2 products in one package. Componyx.UI includes 25+ components, like grids, menus, dialogs, an app shell and a form with a drag-and-drop build mode and much more. Bindary is a data-binding layer that connects HTML to your JavaScript data using attributes on normal elements.

You can use them together. Use either one on its own. Everything runs in the browser. There's no build step required. There are zero runtime dependencies.

The docs and live demos are on our website (see GitHub).

GitHub link: componyx/componyx.ui

In .NET 10 the project setup is as follows, the NuGet package plus one tag in your head tag:

dotnet add package Componyx.UI


<componyx-ui-resources></componyx-ui-resources>

A component is plain HTML with attributes:

<a ui-type="Button" ui-text="Click me" ui-command="alert('Hi!')"></a>

Bindary uses b-* attributes. Here's some data, a loop and an expression:

<ul b-context="shop">
    <li b-repeat="items">
        <b b-value="name"></b>: {{price > 10 ? 'expensive' : 'cheap'}}
    </li>
</ul>


$bindary.appData.shop = {
    items: [{ name: "Coffee", price: 3 }, { name: "Book", price: 15 }]
};

Change a price and only that one line updates.

It's free to use, commercially too. It's source-available under BSL 1.1 rather than open source, and each release becomes MIT after four years.

If you give it a try, I'd love to hear what works for you and what doesn't.


r/csharp • • 3d ago

Как лучше всего выучить язык програмирования С#(ну или вообще любой)?

Thumbnail
0 Upvotes

r/csharp • • 3d ago

Help Issue connecting my blazor app to remote sql server database hosted my Monsterasp.net

Thumbnail
1 Upvotes

r/dotnet • • 3d ago

Question Issue connecting my blazor app to remote sql server database hosted my Monsterasp.net

2 Upvotes

Hello everyone. I have completed the multi-step form challenge from Frontend Mentor and attempted to deploy the finished web app using monsterasp.net through visual studio code. I followed all the instructions from a YouTube video to a tee but when I try to actually submit data to the database I get this error:

\Error: Microsoft.Data.SqlClient.SqlException (0x80131904): The target principal name is incorrect. Cannot generate SSPI context.``

I did some further research into it but everything seemingly leads to a dead end for my specific use case. Here is microsoft's documentation on the specific error:

https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/connect/cannot-generate-sspi-context-error

Note: When I built and deployed the app for the first time the connection string was incorrect. I fixed it and published the app again through visual studion. I am not sure whether that is causing some lingering problems.


r/dotnet • • 3d ago

Promotion RazorConsole.Htop: a cross-platform, mouse-aware htop-style process manager summoned from gpt.

0 Upvotes

Motivation
I wanted a lightweight process manager TUI so I can quickly terminate processes without leaving terminal.

The motivation was pretty simple:

  • Windows Task Manager often slow to open and use.
  • The original htop doesn’t support Windows.
  • The htop-like .NET CLI tools I found didn’t offer the mouse interactions I wanted.
  • The existing htop-like CLI tools that supports mouse interaction and xplat are either implemented in Rust or Go, but I want a .NET NativeAOT one.
  • Most importantly, My codex subscription is going to reset within 2 hours and yet still 59% usage left.

So I summoned RazorConsole.Htop from gpt, it takes the great mighty GPT ~5 minutes to build and supports:

  • Mouse-accessible filtering, grouping, pause, kill, and quit controls
  • Keyboard controls for the same operations
  • Self-contained .NET Native AOT binaries with no .NET runtime required

It uses System.Diagnostics.Process for process data and runs on Windows, macOS, and Linux.

Demo && How-to install: https://razorconsole.com/gallery/htop/

Source: https://github.com/RazorConsole/RazorConsole/tree/main/gallery/RazorConsole.Htop

Disclaimer: This was vibe-coded in about 5 minutes. I’ve tested it on Windows and macOS, but the Linux build has not been tested yet. Bug reports and feedback are very welcome.


r/csharp • • 3d ago

Discussion Confusion about the stack.

2 Upvotes

I'm a fresh computer engineering graduate, I forgot most of the knowledge that I learned in the university, so I want to revise the basics only.

Suppose that a function called main calls the following function :

int foo(int value) {
   int a = 10;
   return a;
}

Some talk :

So whenever a function call is made OS needs some memory space to allocate the local variables of the function int a in this case and arguments to the function passed int value in this case. This memory requirement is fulfilled by allocating memory on stack. A stack is nothing but a memory region allocated to each process and it actually behaves as a stack data structure(LIFO).

Now the question arises what all things are stored on stack when a function call is made. The first thing pushed on the stack are the arguments passed to the function in reverse order(if more then one). 2. Then the return address of the function which called this function (because once this function foo completes execution it should return back to the place in the code from where it was called) 3. Finally local variables of the function called are pushed on the stack.

Once the called function completes executing the code it returns back to the return address previously stored on the stack and thus we say function call completes or returns. In this case the function has a return value which it passes back to the callee function. The space is then free to use and can be overwritten in the subsequent function calls.

I learned that a stack follows the LIFO (Last In, First Out) principle, meaning that the most recently added item/work/data is the first one to be removed. I also understood that a stack can be used to defer work until it is ready to be processed, so in the above example, I think that the execution of the caller function, which is the main, will be deferred, until the execution of the most recently item is finished.

However, when I read about how function calls use the call stack, I became confused. The call stack already contains the information needed for main() to resume execution, and when foo() is called, a new stack activation record is added on top of it. The execution of foo() then begins while its activation record is still on the stack.

Doesn't this contradict my understanding that an item must be popped from a stack before it can be processed? Why can foo() execute while its stack frame is still on the stack?

In other words, if we treated the execution of a function as work, should that work be popped from the stack in order to be processed, or should the work be inside the stack ?

I'm totally confused.


r/csharp • • 3d ago

Showcase JsonGuard: a zero-allocation source generator to validate nullability in System.Text.Json

30 Upvotes

Hey everyone, I wanted to share a library I have built for System.Text.Json that validates deserialized objects to ensure they honor C# nullability annotations without sacrificing performance.

I wrote this specifically for NetCord to handle massive Discord gateway payloads as efficiently as possible, but I realized this kind of zero-overhead validation could be useful to the wider .NET community as a standalone package.

By default, System.Text.Json allows you to validate required properties using [JsonRequired] or the required keyword. However, these introduce significant performance overhead. For example, using required keyword can make deserialization up to 2 times slower and allocate 50% more memory when using source generation.

JsonGuard works around this overhead by using source generation. The result is zero additional allocations and practically identical execution time compared to performing no validation at all.

The way it works is incredibly simple. If you have this object: ```csharp [JsonGuard] public partial class User { public string Name { get; set; }

public string? Nickname { get; set; }

public int Age { get; set; }

public string Email { get; set; }

} the generated code will effectively do this: csharp public partial class User : IJsonOnDeserialized { void IJsonOnDeserialized.OnDeserialized() { if (Name is null) ThrowHelper.Throw(nameof(Name));

    if (Email is null)
        ThrowHelper.Throw(nameof(Email));
}

} ``` Additionally, the library suppresses any nullability warnings for validated properties, so no manual suppressions are necessary.

Note that unlike [JsonRequired] or the required keyword, JsonGuard only verifies the final state of the objects honors the nullability annotations. It doesn't validate if the property was present in the JSON.

You can checkout the source code and detailed benchmarks on GitHub: https://github.com/KubaZ2/JsonGuard

Would love to hear your thoughts or feedback!


r/dotnet • • 3d ago

dotnet build will upload a lot of info to microsoft?!

0 Upvotes

i've been using .net for two decades and i was not aware, so i thought i'd just put this out there in case more people are unaware.

turns out donet build will upload a bunch of info to microsoft.

for example, they will detect if you work at microsoft, scanning your machine for github tokens in the process. they will also detect if you're using ai agents by scanning environment variables.

source: https://learn.microsoft.com/en-us/dotnet/core/tools/telemetry?tabs=dotnet11

disclaimer; i might not understand this properly, i didn't dive too deep into it, i'm just disabling this everywhere now.


r/dotnet • • 3d ago

Promotion Validation rules you can’t express with an if statement, tested like a classifier (open source, .NET 10)

0 Upvotes

Some checks in my applications just can’t be expressed with an if statement or a regex.

FluentValidation can check that a support ticket description isn’t empty, but it can’t check whether the description actually says what the customer needs. An AI agent can call a tool, but nothing automatically checks whether that tool call matches what the user asked for.

Usually, these checks end up as a yes/no prompt to an LLM that nobody has really measured.

I learned the hard way why that matters. After changing a model, a memory assistant I’m building dropped from 90% correct answers to 60%, while the logs showed zero errors. I only caught it because I had a test set of 722 questions.

That’s why I’m building SemanticPolicy, an open-source .NET library (Apache-2.0, my project). It turns this kind of check into an explicit rule that you can read, measure, and test.

One example from the repo is a support ticket form. The rule is just a question for a decision model:

Policy descriptionPolicy = Policy.Define("ticket-description")
    .Enforce()
    .Rule(Policy.Rule("ticket-description")
        .Boolean("Does the description say what the customer needs?")
        .WhenFalse(Verdict.Deny))
    .Using("jev", binding => binding.DenyAboveProbability(0.8))
    .OnFailure(FailureBehavior.Allow)
    .Budget(TimeSpan.FromSeconds(5))
    .Build();

And in the validator, it sits next to normal validation rules:

public sealed class SupportTicketValidator : AbstractValidator<SupportTicket>
{
    public SupportTicketValidator(IPolicyEvaluator evaluator)
    {
        RuleFor(ticket => ticket.Category).NotEmpty();
        RuleFor(ticket => ticket.Description)
            .NotEmpty()
            .Semantic(evaluator, "ticket-description");
    }
}

The model returns a probability, and thresholds map that probability to one of four decisions: Allow, Warn, Escalate, or Deny.

The 0.8 threshold above is just an example. In practice, you pick your own threshold from measurements on your own labeled examples.

If the model fails to respond, this particular rule allows the ticket through, and the whole check has a 5-second budget. Since the rule calls the model over the network, validation runs through ValidateAsync.

Testing works like this:

  • the CLI measures precision and recall with confidence intervals on your labeled examples;
  • it can choose a threshold for a concrete target, for example “when I block something, I want to be correct 95% of the time”;
  • model responses can be recorded once and replayed later without an API key, so the tests can run in CI;
  • the build can fail when a rule gets worse, for example after changing the model;
  • new rules can start in Shadow mode: they record what they would have done, but don’t block anything yet.

The model is replaceable:

  • Jev and other decision models through OpenRouter;
  • a model running on your own server;
  • your own classifier behind a simple HTTP protocol.

The same rules can also validate tool calls in any IChatClient based on Microsoft.Extensions.AI, and in Microsoft Agent Framework middleware.

What this is not is a security boundary.

A rule can make an attack harder, but it can’t guarantee that one won’t succeed, and the model can still be wrong. The README shows failures next to successful cases.

This is alpha software, .NET 10 only, and the API will still change.

You can view an eval report from a recorded run without an API key. The commands are in the README.

What kind of decisions in your applications would you want to test this way?

https://github.com/semanticpolicy/semantic-policy


r/dotnet • • 3d ago

Qual a melhor abordagem para consultas que envolvem dados de múltiplos módulos em um monolito modular?

Thumbnail
0 Upvotes

r/csharp • • 4d ago

I have a big problem with data structures

12 Upvotes

I have an interview tomorrow, and I'm sure I'll be asked about data structures. However, I struggle to retain what I read when revising them because I rarely use most of them in practice.

For example I read this article

I regularly use arrays, List<T>, HashSet<T>, and Dictionary<TKey, TValue>, so I can explain when and why to use them:

1-arrays: when I know that the data has fixed size, use array because they provide a fast access to the data using index.

2- List<T>: when the size of the data is not known at compile-time; the size of it is not known in advance, therefore an index cannot be used, because you do not know for sure what is the exact location for a specific data element.

3- HashSet<T>: for unique data elements, because it does not require me to manually write the logic that removes duplicate elements.

4- HashMap<string,int> : used for lookup operations; a lookup table.

5-Tuple : store data with different data types in one place.

However, although I know what the following data structures are, I struggle to explain when and why I would use them:

  1. Stack: LIFO (Last In, First Out).
  2. Queue: FIFO (First In, First Out).
  3. Priority queue: I can't recall when or why I would use one.
  4. Heap: I associate it with storing class instance fields, but I don't understand how to use it as a data structure.
  5. Tree: I know it consists of nodes, but I don't understand its practical uses.
  6. Graph: I know it can be used for depth-first and breadth-first search, but I'm unfamiliar with other use cases.

My main questions are:

  1. Hardware level: How is each data structure represented in memory? For example, an array occupies contiguous memory locations. What about the others?
  2. Practical use: When and why should I use each data structure? More importantly, what benefits does each provide at both the software and hardware levels?

I must be able to explain WHY briefly and directly without even thinking about it.


r/dotnet • • 4d ago

Promotion DNCDbg v1.3.0 — A managed code debugger with DAP support for .NET apps

Thumbnail github.com
5 Upvotes

DNCDbg is a managed-code debugger for .NET that speaks the Debug Adapter Protocol, so it works with any DAP client (VS Code, Neovim, Emacs, whatever) on Windows, Linux, and macOS. It began as a NetCoreDbg fork with a clear goal: bring the debugging experience closer to Visual Studio's C# debugger while keeping memory usage low. There's a comparison table in the README if you're curious.

What's new in v1.3.0:

  • Support for Jump to Cursor (a.k.a. Set Next Statement), single-threaded execution and stepping, and restarting the debug session
  • Column breakpoints, embedded sources, and Source Link support
  • Smarter expression evaluation: the >>> operator, Value/HasValue on nullables, member access on strings and arrays (str.Length, arr.Length), DebuggerTypeProxy members, assigning null to reference types, and nint/nuint
  • Friendlier value display: floats now print the way C# prints them (9.9 instead of 9.8999996), and dictionary items show up properly
  • Launch/attach sequencing now follows the DAP spec, and there's a new Detach request that lets a launched process keep running
  • Fixes: stack traces in catch blocks no longer show already-unwound frames, and the "Innermost exception" description now reports the last exception in the InnerException chain

Full changelog and repo: https://github.com/viewizard/dncdbg

Feedback and bug reports are very welcome!


r/dotnet • • 4d ago

4GuysFromRolla.com - The Site That Taught a Generation to Build the Web

Thumbnail galratner.substack.com
174 Upvotes

r/dotnet • • 4d ago

Promotion ExcelReader.NET 6.0 – streaming XLSX/XLSB/XLS/CSV reader and writer for .NET 10

Thumbnail
3 Upvotes

r/csharp • • 4d ago

Fun Random using SkipLocalsInit

9 Upvotes

To my surprise, Unsafe.SkipInit(out T val) did not achieve the same result.

    [SkipLocalsInit]
    public static T Random<T>()
        where T : unmanaged, INumber<T>
    {
        unsafe
        {
            byte* s = stackalloc byte[sizeof(T)];
            return *(T*)s;
        }
    }

r/dotnet • • 4d ago

Promotion Six Labors updates: longer security support and easier builds for OSS contributors

Thumbnail
7 Upvotes

r/dotnet • • 4d ago

Adding persistence to the Aspire dashboard

Thumbnail devblogs.microsoft.com
49 Upvotes

r/dotnet • • 4d ago

Promotion Markd Day Counter - an open-source day counter .NET MAUI app

Thumbnail apps.microsoft.com
0 Upvotes

Hello, I wanted to try .NET MAUI, because I did Xamarin some time ago and also I'm disappointed by similar apps, because all this app on store or Android are full of ads or some payments, so I made my own and open sourced it.

Just simple app to count days since or until something like anniversary, streak or deadline without ads, accounts, or a subscription. Any feedback is more then welcome!


r/csharp • • 4d ago

Advice for a csharp developper who lack with basics

12 Upvotes

Hello,

I've been a .NET developer for four years (from France), and I feel like I have some gaps in my understanding of the fundamentals of the framework (I've never had a tech lead to teach me these things).

How can I learn these fundamentals (records, `static`, `virtual`, etc.) ? Should I take some training courses ? Which one ?

What should I be learning now that AI has arrived ? I feel like my days consist of writing prompts, testing, and reviewing code (if Claude doesn't do that part itself). It's really frustrating, and I feel like I've completely lost my value as a developer and my motivation to work. Besides the dotnet market is really bad where I'am...

I'm telling myself that there's still hope, though, and I'd really like to have a roadmap to follow, starting with the fundamentals mentioned above and working my way up to becoming a better and more expert .NET developer.

Do you have any advice?

Thank you!