Urgent.News

What's breaking now, across thousands of outlets.

Tech

This week in Cursor + .NET — 7 rules (week ending September 13, 2026)

Every weekday a single, opinionated rule for senior C#/.NET engineers using Cursor. Here's the full week in one read — canonical posts live on the Agentic Architect blog . 7 daily senior rules Rule 23: No Bool Flag Parameters Sun 13 Sep SendEmail(string to, bool isHtml) should be SendHtmlEmail and SendPlainEmail. Bool flags hide branching that belongs in the type system. Flag any method signature…

Every weekday, Cursor + .NET provides a single opinionated rule for senior C#/.NET engineers. The full week's worth of rules is compiled into one read, with canonical posts available on the Agentic Architect blog. Seven daily senior rules are outlined, including:

1. Rule 23: Avoid using boolean flag parameters in method signatures, as they hide branching that should be part of the type system. Flag any method with two or more boolean parameters for potential refactoring.

2. Rule 22: For long-running tasks in ASP.NET Core, use a BackgroundService instead of Task.Run inside a controller. Cursor may execute Task.Run and call it asynchronous work, but the request thread may terminate mid-execution, leading to unexpected results. Catch Task.Run outside of test code and propose a hosted service as an alternative.

3. Rule 21: Use System.Threading.Channels for producer-consumer patterns instead of BlockingCollection or custom queues combined with SemaphoreSlim. Cursor often resorts to ConcurrentQueue, which requires manual stitching together. A rule that identifies producer-consumer patterns and suggests Channel can save time and effort.

4. Rule 20: Opt for source-generated JSON serialization (JsonSerializable) for hot paths and ahead-of-time compilation (AOT) rather than reflection-based System.Text.Json. Cursor doesn't typically suggest this approach, so adding a rule that flags new DTO classes and asks whether they should be source-generated is recommended.

5. Rule 19: Architectural rules belong in tests, not in code reviews. Encode these rules as NetArchTest assertions, ensuring they fail the build instead of being caught during standups. Whenever a new layer or project is introduced, add the corresponding test to maintain the architectural boundaries.

6. Rule 18: Utilize WebApplicationFactory with Testcontainers (SQL Server, Postgres) for integration tests instead of relying on in-memory EF Core providers. In-memory EF Core providers are unreliable and can introduce bugs to production. Detect the use of in-memory providers in test projects and flag them for correction.

7. Rule 17: In non-ASP.NET libraries, ConfigureAwait should be set to false on every awaited Task. ASP.NET Core code should not follow this convention. Cursor often mixes both contexts in the same solution, so detecting the project type and enforcing the appropriate default is essential.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Sunday 13 September →