今日已更新 305 条资讯 | 累计 19865 条内容
关于我们

This week in Cursor + .NET — 7 rules (week ending June 21, 2026)

Agentic Architect 2026年06月21日 20:21 2 次阅读 来源:Dev.to

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 14: Sealed By Default Sun 21 Jun Mark every class sealed unless inheritance is explicitly planned. Stops Cursor inventing accidental inheritance hierarchies "for flexibility." Small but measurable virtual-call perf wins too. → Permalink on the blog Rule 13: Strongly-Typed IDs Sat 20 Jun OrderId as record struct OrderId(Guid Value) beats raw Guid everywhere. Stops the AI passing a CustomerId where an OrderId was expected — a bug the compiler can't catch with primitive obsession but catches instantly with domain primitives. → Permalink on the blog Rule 12: IOptionsSnapshot Over Raw Config Fri 19 Jun Business code should never call IConfiguration directly. Strongly-typed IOptions or IOptionsSnapshot bindings only. The AI loves to "just grab the config value" — refuse it and force a settings class with validation attributes. → Permalink on the blog Rule 11: Rethrow, Don't throw ex Thu 18 Jun throw ex resets the stack trace. throw preserves it. Cursor gets this wrong about 40 percent of the time when generating catch blocks. Rewrite any naked throw ex to throw unless the exception has been explicitly wrapped. → Permalink on the blog Rule 10: AsNoTracking for Reads Wed 17 Jun Every read-only EF Core query should call AsNoTracking. Add a rule that recognises query methods returning DTOs (not entities) and inserts the call. Cursor never does this by default and your read perf degrades silently across releases. → Permalink on the blog Rule 9: Scoped Capture in Singleton Tue 16 Jun The single most expensive .NET runtime bug: a Singleton holding a Scoped service. Cursor cheerfully writes this without warning. Audit constructor parameters of any class registered as Singleton — if any are typically Scoped (DbContext, repositories, MediatR sender), flag it before merge. → Permalink on

本文内容来源于互联网,版权归原作者所有
查看原文