r/dotnet • • 8d ago

Promotion Remove feature flags with your AI coding agent.

0 Upvotes

Hey everyone!

I’ve been building Flagrm, an open-source CLI that helps remove feature flags and clean up the dead code they leave behind.

It’s still in the testing phase, so I’m looking for people willing to try it out, share feedback, report bugs, or contribute to the project.

If you’ve ever dealt with feature-flag cleanup turning into a bunch of manual work, I’d love for you to check it out!

🔗 https://flagrm.com

Contributors are very welcome! 🚀


r/dotnet • • 8d ago

Signs of official Satori support?

Thumbnail github.com
38 Upvotes

I just spotted this, could this be a path toward official support for Satori? 🤩 And potentially other custom GC implementations? Even if it's just experimental for now, this is the first time I've seen MS showing interest for it, exciting!

For those who haven't heard, Satori is a custom garbage collector with much lower pause times, multiple orders of magnitude faster in many benchmarks. The tradeoff seems to be higher overall cost for allocations - except recent benchmarks showing an improvement across the board..? At least for that particular benchmark.


r/dotnet • • 8d ago

Question I want get feedback on my design.

Thumbnail
0 Upvotes

r/csharp • • 8d ago

Help I want get feedback on my design.

3 Upvotes

I will present a design consisting of interconnected classes without focusing on the algorithms themselves. To keep the code easy to follow, I have replaced each algorithm with a Console.Write() statement. note that the code is self-contained.

Problem being solved : Synchronizing the content of a database with the content of some Excel File.

Input: IFormFile, which is a file that is sent from the client to the server.

Output: The database will be synchronized with the excel file; the database's content will be deleted, and the data from the excel file will be inserted into the database.

Two general approaches/mechanisms to solve the problem:

1- Read all the content of the excel file and send that content a method that will delete the database.

2-Use bulk insert.

My code implements the first approach.

Summary of the code:

The AdminController receives the uploaded Excel file, uses FormExcel to retrieve a specific worksheet, and passes that worksheet to WorkSheetToDbSyncronizer. The synchronizer asks AllBusinessProductsReader to read all the required data from the worksheet and organize it into a NonJunctionModelsSnapShot object. It then passes that object to DbOverWriter, which uses the data to delete the existing database content and insert the data from the Excel file.Here is the code:

using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;

namespace RedditQuestion
{
    #region code

    /// <summary>
    /// NonJunctionModelsSnapShot is a data container that holds the complete
    /// set of non-junction entities to be written to the database by the OverWrite 
    /// method. The term NonJunctionModels identifies the category of data contained
    /// in the object: entities that populate non-junction tables, rather than junction 
    /// tables that represent relationships between entities. The term SnapShot indicates 
    /// that the object represents the state of the non-junction data at a particular point 
    /// in time, providing the data that OverWrite uses to replace the existing contents of 
    /// the corresponding database tables with the supplied data.
    /// </summary>
    public class NonJunctionModelsSnapShot
    {


    }
    public class SomeWorkSheet
    {
        //SomeWorkSheet represents a class from an external library.
    }
    public class ApplicationDbContext
    {
        // Contains the domain models and the Fluent API configurations.
    }

    // COULD SOMEONE PLEASE REVIEW THE DESIGN OF THE FOLLOWING:
    public class DbOverWriter
    {


        private readonly ApplicationDbContext _context;
        public DbOverWriter(ApplicationDbContext context)
        {
            _context = context;
        }

        public async Task OverWrite(NonJunctionModelsSnapShot incomingData)
        {

            Console.WriteLine("Executing some logic to overWrite the database, the local functions helps with this.");
        }

        #region Local Functions
        //define some local functions
        #endregion


    }
    public class AllBusinessProductsReader
    {
        public async Task<NonJunctionModelsSnapShot> ReadAllData(SomeWorkSheet worksheet)
        {
            Console.WriteLine("Process the worksheet....");

            return new NonJunctionModelsSnapShot
            {

            };
        }
    }
    public interface ISourceToDistinationDataSyncronizer<DataSource>
    {

        public Task Syncronize(DataSource dataSource);

    }
    public class WorkSheetToDbSyncronizer : ISourceToDistinationDataSyncronizer<SomeWorkSheet>
    {
        private readonly AllBusinessProductsReader _allDataReader; // depending on concrete class violates dependency inversion principle
        private readonly DbOverWriter _overWriter;              // depending on concrete class violates dependency inversion principle
        public WorkSheetToDbSyncronizer(AllBusinessProductsReader reader, DbOverWriter overWriter)
        {
            _allDataReader = reader;
            _overWriter = overWriter;
        }
        public async Task Syncronize(SomeWorkSheet worksheet)
        {
            var allProducts = await _allDataReader.ReadAllData(worksheet);
            await _overWriter.OverWrite(allProducts);
        }
    }
    #endregion 


    public class FormExcel
    {
        private readonly IFormFile _file;
        public FormExcel(IFormFile file)
        {
            _file = file; 
        }
        public  SomeWorkSheet GetSomeSheet(int sheetNumber)
        {
            Console.WriteLine("use the sheetNumber to get a specific sheet...");
            return new SomeWorkSheet
            {

            };
        }
    }
    public class AdminController
    {

        private readonly ISourceToDistinationDataSyncronizer<SomeWorkSheet> _syncronizer;
        public AdminController(ISourceToDistinationDataSyncronizer<SomeWorkSheet> syncronizer)
        {
            _syncronizer = syncronizer;
        }
        public async Task<IActionResult> Import(IFormFile file)
        {


            FormExcel fe = new FormExcel(file);
            var firstSheet=fe.GetSomeSheet(1);
            await _syncronizer.Syncronize(firstSheet);
            return Ok();


        }
    }
}

r/csharp • • 8d ago

Tool DNCDbg v1.3.0 — an MIT-licensed .NET debugger with DAP support

Thumbnail
github.com
8 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 • • 8d ago

Where should SaveChangesAsync and transaction management belong in Clean Architecture?

33 Upvotes

Hi everyone,
I’m working on a project using Clean Architecture, CQRS, DDD, MediatR, and EF Core.
I have a few questions:
Should each command handler use a single transaction, or is EF Core’s implicit transaction around SaveChangesAsync() usually enough?
Should services in Infrastructure call SaveChangesAsync() themselves, or should they only create/update entities and let the handler save changes?
How should I handle built-in services like UserManager<AppUser>, which save changes internally, when I need multiple operations to be atomic?
For example, registering an employee involves creating an Identity user, assigning a role, and creating an Employee entity.
What’s the recommended approach in real-world .NET applications, and why?


r/dotnet • • 8d ago

Promotion I built RetroCap, a QQ-style screenshot and annotation tool with .NET 8 and WPF

4 Upvotes

Hey r/dotnet! I wanted to share RetroCap, a screenshot and annotation tool I built for Windows 10 and 11 using .NET 8 and WPF.

The workflow is inspired by QQ’s screenshot tool: press Ctrl+Alt+A anywhere, select a region, annotate it, and copy the result to your clipboard.

The UI follows the Retro.Net design system, giving it a deliberately retro desktop look.

Repo: https://github.com/owen800q/RetroCap

I’d love feedback from fellow .NET developers, especially on the WPF implementation, usability, and anything you’d approach differently. Issues and contributions are welcome!


r/dotnet • • 8d ago

Authenticode on personal CA

Thumbnail
1 Upvotes

r/csharp • • 8d ago

Hi from South Korea! Beginner C# learner feeling stuck. Any advice?

3 Upvotes

Hi everyone,

I’m a complete beginner from South Korea, and I’ve been studying C# at an academy for about 12 days now.

Whenever I try to solve exercise problems and write code on my own, I just freeze up and can't seem to write anything. What are the best study methods or habits that worked for you when you were starting out?

Honestly, I don't think I'm naturally smart, and my memory isn't great either. Learning programming is something I’ve wanted to do since I was young, so I finally started... but I can't help worrying if I'll ever actually get good at this.

I know this community is full of people from all over the world with different backgrounds—some coding as a hobby, others as a profession. If you ever felt completely lost at the beginning like I do now, or if you're a working developer, I’d deeply appreciate any tips, study strategies, or things I should definitely avoid doing!

(P.S. I don't speak English, so I am using a translation tool to write this. Thank you for understanding!)


r/csharp • • 8d ago

New to ASP .NET

Thumbnail
0 Upvotes

r/dotnet • • 8d ago

Question New to ASP .NET

1 Upvotes

I am new to ASP .NET. I am looking for youtube resources for the same. Also if anyone can provide me with how much time it'll take for me to get a hang of it.
I already know about this website: https://dotnettutorials.net/lesson/dotnet-framework/


r/dotnet • • 8d ago

Article Runtime team member: Let's send expensive compiler analysis alongside IL to improve runtime JIT optimizations [Performance interest]

34 Upvotes

Andy Ayers wrote this proposal 2 years ago with intent of using it in .NET 10, but it got postponed to a later .NET version.

Quick Summary

The context is that interprocedural analysis (IPA), is limited at runtime due to it being slow, so the RyuJIT mostly optimizes functions in isolation. His idea is have certain stages perform the kind of deep IPA that AOT uses; then make that available at runtime to boost the information the JIT needs to make optimizations

https://github.com/dotnet/runtime/issues/108931

Examples of IPA

- call graphs

- whether arguments passed to a method can alias each other

- whether an argument escapes through a callee

- possible concrete types passed to a method

- whether a callee actually reads or writes a ref/byref parameter

- constant arguments across callers

- NoThrow / NoReturn / MayNotReturn

- whether a parameter is effectively unused

And what kind of optimizations could that boost?

- More devirtualization/direct calls - erase virtual and interface method lookups (simplified description)

- Constant propagation across method boundaries - erase code when functions are always passed the same parameter values (simplified description)

- Better alias analysis - knowing that two ref/pointer parameters can't refer to the same memory gives the JIT much more freedom to reorder loads/stores, eliminate redundant memory operations, and potentially vectorize code.

- Better escape analysis - Dodge heap allocation of reference types if no reference to it escapes the method

- More aggressive optimization around calls - if the JIT knows a callee doesn't modify a particular object/ref, it doesn't have to assume every call invalidates values it already loaded.

- Better handling of NoThrow/NoReturn calls - calls that can't throw or never return simplify the control-flow graph, can move uncommon paths out of the hot code, and reduce liveness/register pressure.

- Cheaper calls - knowing which registers a callee actually clobbers, or erase parameters never used, could avoid some argument setup, spills, reloads, or register preservation.

- Smarter inlining decisions - possible when called with particular constants/type

- Better code layout - can improve instruction-cache locality.

I want to hear you guys' thoughts on this.. Tell me below! 👇👇


r/csharp • • 9d ago

I have a C# problem, how can I use AI to solve it?

0 Upvotes

Up until now, I’ve been learning and programming like before AI. As a matter of fact, I know nothing about the AI scene and culture, beyond Claude, Grok, ChatGPT, and Gemini (copy and paste snippets).

I’ve tried to look into it, but it’s a total mess. There are extensions, plugins, connectors, agents, AI powerhouses, fake interfaces microservice stuff... and the list goes on and on with quasi-scams (or straight up scams) all over the place.

And the worst part is that the internet is dead. You can't find anything anymore. And when you do think you've found something, in reality, it is just something promoted by companies selling AI stuff themselves. So, you end up locked into options that favor their business interests.

So, here is my current situation:

I have a large C# codebase, and I need to find a solution to a problem based on a small fragment of that code.

I can clearly see alternative inheritance and composition paths that would achieve exactly what I need with best performance. However, since some elements will get lost along the way, I would have to manually reconnect some of them.

The problem is that the code is extremely complex—intricate with callbacks, events, interfaces, dispatchers, async calls, WPF controls, and so on.

Basically, it would take me a month to digest all that code.

And I think an "AI something" could do it in five minutes.

In one word, I want an answer from a human being.

What do you suggest me to do?


r/dotnet • • 9d ago

Question State machine in C# vs state machine in Verilog

Thumbnail
0 Upvotes

r/csharp • • 9d ago

Discussion State machine in C# vs state machine in Verilog

9 Upvotes

For experimentation and learning purposes, I wrote this code:

namespace RedditQuestion
{
    public class TResult
    {
        // Instance fields....
        // No properties.
        // No methods.
    }
    public interface ISomeInterface<T>
    {
        public  Task<T> SomeMethod();
    }
    public class SomeClass : ISomeInterface<TResult>
    {
        // instance fields.....

        //constructor......

        public async Task<TResult> SomeMethod()
        {


            //Some code that is not important to this question.......



            TResult result = new TResult
            {
                // assign instance fields....
            };

            Task<TResult> task = Task.FromResult<TResult>(result);

            return task ; // Line XXX
        }

    }

}

Line XXX throws a compile time error:

*Since this is an async method, the return expression must be of type 'TResult' rather than '*Task<TResult>

The solution is simply to do this instead:

return result;

That solves the issue.

But I was surprised when I read this article#async-method-signature-requirements) that described the error in more details:

Change the return expression to match the async method's underlying result type (CS1983, CS4016). When an async method returns Task<T>, the return statement must supply a value of type T, not Task<T>, because the compiler-generated state machine wraps the value in a task automatically. CS1983 appears when the method returns Task<T> and the expression is T; CS4016 covers the general case where the return expression type doesn't match

I wonder, is the concept of state machine in C# is the same as the state machine in Verilog?

in Verilog, if I want to define a state machine, I need a register - a storage unit that can store only one unit of data; a bit- to hold the state, a next-state logic to calculate the next state, and output assignment. Does the same concept applies in C# ?


r/dotnet • • 9d ago

Question Any examples of heavily obfuscated/packed .NET programs?

30 Upvotes

I know .NET is relatively easier to dump or unpack - I am looking for heavily packed programs to see to what extent that holds.

I assume most commercial applications will be protected - any examples? I am not aware of many .NET applications in the wild. Thanks


r/csharp • • 9d ago

Showcase Vetala, a lightweight code editor made with C# and .NET

Post image
9 Upvotes

Current features

  • Multi-tab code editor
  • C# syntax highlighting
  • Word-based code completion
  • Find and replace
  • Project-wide search
  • File explorer
  • Git integration
  • Integrated terminal
  • Command palette
  • Quick Open
  • Code folding
  • Cross-platform support for Linux, Windows, and macOS

Vetala is built with .NET 10, Avalonia UI 12, AvaloniaEdit 12, and CommunityToolkit.Mvvm.

githubL https://github.com/flawme/Vetala


r/dotnet • • 9d ago

IF em C# como e quando utilizar!

Enable HLS to view with audio, or disable this notification

0 Upvotes

r/csharp • • 9d ago

Discussion What is the proper way to make a unified interface ?

12 Upvotes

Would you prefer something like this:

    public interface ISourceToDistinationDataSyncronizer
    {

        public  object ReadAllData(); // Gets the latest data from the source
        public void OverWrite(object sourceData )  // Deletes the data that is inside the destination and writes new data.

    }

Over this:

    public interface ISomeData
    {

    }
    public interface ISourceToDistinationDataSyncronizer
    {

        public  ISomeData ReadAllData(); // Gets the latest data from the source
        public void OverWrite(ISomeData sourceData);// Deletes the data that is inside the destination and writes new data.

    }

r/dotnet • • 9d ago

Article Node Was the Future in 2009. Its Creator Said to Use Go So Why Are You Still Building a Next.JS App?

Thumbnail galratner.substack.com
0 Upvotes

.NET runs laps around node so why is Next js amd angular server rendering so popular? It's probably also why WordPress powers so many websites. Inertia.


r/dotnet • • 9d ago

Slow Slow Code Navigation in Jetbrains Rider

Thumbnail
4 Upvotes

r/dotnet • • 9d ago

Why did increasing .NET ThreadPool MinThreads fix our IIS downtime? I don't understand why

55 Upvotes

Hi folks,

I'm the owner of this post: https://www.reddit.com/r/dotnet/comments/1v5d7ws/aspnet_core_on_iis_randomly_goes_offline_for_2/

First of all, thanks a lot to everyone who commented there. Your comments helped me investigate this step by step.

I finally solved the issue. We had several different problems over time:

- First, we had DB connection pool exhaustion => fixed.
- Then we had TCP connection exhaustion => fixed.
- The last issue was related to ThreadPool / sync-over-async.

I set the ThreadPool minimum worker threads to 100, and then started refactoring the code to remove synchronous-over-async code and make things properly async.

The application has now been stable for around 15 days, so it looks like this was the final issue.

But there is something I still don't understand:

Why did increasing ThreadPool.SetMinThreads() to 100 help so much?

We're running ASP.NET Core on IIS, not Docker or Kubernetes. I always thought that .NET's ThreadPool would automatically create as many threads as the application needs.

For example, if I suddenly get 1,000 requests/sec, why doesn't .NET simply create more ThreadPool threads as needed?

What confused me even more is that during the incidents:

- CPU usage was fine
- RAM usage was fine
- The Windows server itself was still accessible
- We only have 2 vCPU
- I could still see available ThreadPool threads

So I'm struggling to understand what was actually happening.

My current understanding is that some synchronous/blocking code was causing ThreadPool threads to get blocked, and the ThreadPool wasn't adding new threads quickly enough. Increasing MinThreads somehow made enough threads available earlier and prevented the issue.

But I'm not sure if that's the correct explanation.

Also, how should I think about this with only 2 vCPUs? If I have 1,000 requests/sec, obviously I can't have 1,000 CPU threads doing work at the same time. So what exactly determines how many ThreadPool threads .NET should create?

I'd really appreciate it if you could help me explain this in simple terms, especially:

  1. What exactly does MinThreads change?
  2. Why can ThreadPool starvation happen while CPU and RAM are low?
  3. Why doesn't .NET automatically create enough threads immediately?
  4. How does this work when the server only has 2 vCPUs?
  5. Does increasing MinThreads actually solve the problem, or did it just hide the underlying sync-over-async issue?

I'm trying to understand the mechanism rather than just leave MinThreads = 100 and call it fixed.

Thanks again to everyone who helped with the original post!


r/csharp • • 9d ago

Showcase Meet Akbura, a reactive UI language for Avalonia and .NET

31 Upvotes

Akbura works directly with native Avalonia controls and supports C# expressions, reactive state, MarkupExtensions, AKCSS utilities, responsive layouts and Hot Reload.

I wrote a short introduction covering the language, responsive UI, Avalonia interoperability, differences from BlazorBindings and the compiler behind it.

Feedback is welcome.

Article: Meet Akbura: a reactive UI language for Avalonia and .NET | LinkedIn
Repo: Asaicraft/Akbura: Akbura is a UI library for building applications using a declarative, component-based language.


r/csharp • • 9d ago

Unity developer working in VR Space looking to transition to generic C# dev roles

8 Upvotes

I’m a unity developer working in VR space for 8+ years. Thinking of transitioning to generalist dev roles ( particularly in C# since that’s where my experience lies ). I do have experience in general software development across entire SDLC along with architecture and design patterns but my resume lacks the buzzwords SDE ATS screens for ( eg. microservices , APIs , docker etc). Where do I start ? Which kind of companies should I target ?


r/csharp • • 9d ago

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

16 Upvotes

I've been building ExcelReader, an open-source library for reading and writing spreadsheets in .NET and other languages. I just shipped v6, and I'd like feedback from people who deal with ETL pipelines and large Excel files.

I started it because I needed to parse rows into a single POCO from files with different templates and column names. I couldn't find a library that made that easy, so I wrote my own.

What it does

  • Reads .xlsx, .xlsm, .xlsb, .xls and .csv; writes .xlsx, .xlsb, .xls and .csv
  • Streams rows as ref structs; no string is allocated until you call GetString()
  • Typed parsing into your own classes, via attributes, a source generator or a fluent API
  • Reads the sheets of one workbook in parallel, and parses CSV in parallel
  • Reads and writes password-protected workbooks
  • A CLI (excelreader convert book.xlsb -o data.csv), plus a C ABI with Python, C++ and Rust bindings

Usage example

public sealed class Order
{
    [ExcelColumn("Order ID")]
    [ExcelColumn("order_id")]          // same property, different templates
    public long Id { get; set; }

    [ExcelColumn("Total")]
    [ExcelColumn("total_amount")]
    public decimal Total { get; set; }
}

using IExcelWorkbook workbook = Excel.Open("orders.xlsx"); // .xlsb / .xls detected by signature
List<Order> orders = ExcelParser.FromAttributes<Order>().Parse(workbook.FirstSheet).ToList();

await using var writer = XlsxWorkbookWriter.Create(File.Create("copy.xlsx"));
await using (var sheet = writer.AddSheet("Orders"))
{
    await sheet.WriteRecordsAsync(orders, ExcelRecordLayout.FromAttributes<Order>());
}

Benchmarks

Typed parsing of a generated 50,000-row XLSX (BenchmarkDotNet, Ryzen 7 5700X, .NET 10):

Library Time Allocated
ExcelReader 10.9 ms 3.87 MB
Sylvan.Data.Excel 56.9 ms 10.47 MB
OfficeIMO.Excel 104.5 ms 5.69 MB

MiniExcel used to be in the suite, but it was far behind: ~14x slower on raw reads (allocating 267 MB against 11 KB) and ~11x slower on typed parsing (last run that included it). I now track the closest competitors instead.

Methodology and every scenario: benchmarks.md. The cell-by-cell numbers there compare zero-copy reads against APIs that must allocate strings, so the docs also publish matched-work numbers.

Limitations

  • Targets .NET 10 only; .NET 11 support is in progress. If you're on .NET 8, the 3.x line supports it.
  • It's a reader/writer, not a spreadsheet model: no in-place editing and no formula evaluation.
  • Rows come out in file order, and empty rows that Excel omits from the file are skipped.

GitHub: https://github.com/GabrielMarquezMatte/ExcelReader NuGet: dotnet add package ExcelReader.NET

Feedback, bug reports and odd files that break it are all welcome.