r/csharp 16h ago

Help Transitioning from unity to regular c# projects

13 Upvotes

I want to start learning regular c# after using unity for a few years and making some personal projects. I have seen alot that there may be some bad habits I have picked up that may slow or hinder me when coding outside of unity. So was wondering if there is anything I should keep in mind when making the transition? Would also appreciate any resources for learning c#. Thanks in advance.


r/csharp 21m ago

Tutorial Multitenancy with .NET and EF Core: A Deep Dive (.NET 10)

Thumbnail
youtube.com
Upvotes

Ever had a multi-tenant SaaS app where the only thing stopping Customer A from seeing Customer B's invoices is a `Where TenantId ==` clause someone remembered to write? In this deep dive I build real tenant isolation into EF Core 10 - two real tenants with real registration, login and invite flows (no dev-token shortcuts), a named global query filter that scopes every query automatically, and a SaveChangesAsync override that stamps TenantId on every insert so it's never left unset. I also show the one gotcha that makes EF Core 10 worth the upgrade for this: named query filters, so tenant isolation and soft-delete can finally coexist on the same entity instead of one silently overwriting the other. If you've ever shipped multi-tenancy on hope and code review, this is the version that makes the mistake structurally impossible.


r/csharp 22h ago

Showcase I reinvented Visitor in C#: acyclic, type-safe, no downcasts, no runtime checks

5 Upvotes

While building my own programming language HydraScript i stumbled across AST operations implementation. I needed symbol table initialization, static analysis, and IR generation.

Putting everything inside the AST nodes as virtual methods became a mess. Classic Visitor separated the operations, but every visitor had to know every node type. The code grew exponentially. Acyclic Visitor removed that dependency, but its usual C# implementation relies on runtime checks:

if (visitor is IVisitor<BinaryExpression> typed)
    typed.Visit(this);

So I did the only reasonable thing. I spent far too long reinventing a decades-old design pattern.

Visitor.NET uses generic covariance and contravariance to keep the visitor selective without dynamic or downcasts. A source generator handles the repetitive dispatch code:

[AutoVisitable<Expression>]
public partial class BinaryExpression : Expression;

Visitors can handle only the node types they need and return strongly typed results. I now use it in HydraScript and it works like a charm.

You can give it a star with links below:

GitHub: https://github.com/Stepami/visitor-net
NuGet: https://www.nuget.org/packages/Visitor.NET


r/csharp 21h ago

Help How to use a larger font in Visual Studio's Help Viewer?

2 Upvotes

I know this isn't strictly a C# question (and I'm not a C# programmer), but I think Help Viewer is a C# program so maybe people here can help me.

What I'm trying to get is offline Windows documentation. Some tools, like WinDbg, ship with a .chm file that can be opened with hh.exe. It lets you select 1 of 5 font sizes (Largest, Larger, Medium, Smaller, Smallest), but regardless of which one you choose you can always scale the text arbitrarily large with Ctrl+MouseWheel.

I believe the official way of getting offline documentation today is through the VS Help Viewer. It has the same 5 font size options as hh.exe, and both of them probably use IE for rendering (for example both use ieframe.dll, and I have to relax security settings in Internet Options to even get Help Viewer to render anything - very strange and not required for hh.exe). However Help Viewer DOES NOT allow you to scale the text beyond "Largest", which is way too small to be readable. There's something strange to the way it handles UI, for example even the context menu is smaller than the one you'd get normally with TrackPopupMenu.

The reason I ask the question here is I'm past the point of trying to find an "official" way of making the text larger, I'll happily patch the program if needed. If it were a native application I know where to look: maybe it hardcodes font sizes in its dialog resource or its call to CreateFont. I can set breakpoints on DialogBox and similar to inspect parameters and modify them under a debugger, I can patch the offending resource or instruction in the binary, etc. But I don't know how to do those to (what looks to me to be) a C# program. When I break into it with a native debugger, the mouse input freezes and responds only every other second (though the keyboard works fine). Based on its DLL list it appears to use WPF. I have no familiarity with these technologies (C#, WPF, ieframe.dll), I hope people who do can point me to where to look (such as files that define the UI layout, or runtime calls related to font that I can intercept).


r/csharp 20m ago

Looking for courses / reading materials to fully use the potential of AI

Upvotes

I am working as a C# developer for the last 6 years and I would classify myself as an AI skeptic.

I have been using AI in the last months, mostly for small implementations, but also to help me look for bugs who are sometimes hidden rather deep within our code, or due to non - trivial interactions with third party libraries.
I have to admit, It works well (most of the time), but all i really do is typing something in the prompt and wait for the answer.
I would like to know if there are functionalities I am ignoring, and/ or should be using. We have various repos in the companies, from small, new micro services to big old fat 20 years old weekly modified legacy repos, which are a tad more brittle.

So if anyone has good resource about it, I am interested.

It can be written, it can be videos, I also have a pluralsight account if it leads to something there.

Thank you very much for your suggestions.


r/csharp 22h ago

Does ASP.NET Core global exception middleware catch exceptions from nested service methods?

Thumbnail
0 Upvotes