Dotnet10 csharp14

From CamiloAndresGTRUniandes/lucy-ai · View interactive version

Dotnet10 csharp14 is an AI agent skill from the GitHub repository CamiloAndresGTRUniandes/lucy-ai. Project-agnostic .NET 10 and C# 14 best practices: field keyword, null-conditional assignment, extension members, unbound generic nameof, runtime improvements, ASP.NET Core, and EF Core guidance. Trigger: When using .NET 10, C# 14, ASP.NET Core 10, EF Core 10, or deciding whether to adopt new langua

How to use this skill

Skill file

.NET 10 + C# 14 Best Practices

When to Use

Use this skill when:

Always combine this with the repo's own docs/STANDARDS.md and the generic csharp-dotnet skill when broader .NET architecture guidance is needed.

Adoption Rule

Use .NET 10 / C# 14 features only when they improve clarity, safety, maintainability, or performance. Do not rewrite working code just to use new syntax.

Before adopting new features, verify:

C# 14 Features Worth Using

1. `field` keyword — validated properties without explicit backing field

Use when a property needs simple validation or normalization in the setter.

public string Name
{
    get;
    set => field = string.IsNullOrWhiteSpace(value)
        ? throw new ArgumentException("Name is required.", nameof(value))
        : value.Trim();
}

Good fits:

Avoid when:

2. Null-conditional assignment — `?.=`

Use when assigning only if the target exists; right-hand side is not evaluated if the receiver is null.

currentUser?.LastSeenAt = clock.UtcNow;

Good fits:

Avoid when:

3. Extension members — extension properties and static extension methods

Use for tiny, broadly useful helpers where fluent/readable syntax matters.

public static class CollectionExtensions
{
    extension<T>(IReadOnlyCollection<T> source)
    {
        public bool IsEmpty => source.Count == 0;
    }
}

Good fits:

Avoid when:

4. `nameof(List<>)` — unbound generic `nameof`

Use when referring to generic type names without inventing a type argument.

var collectionType = nameof(List<>);        // "List"
var mapType = nameof(Dictionary<,>);        // "Dictionary"

Good fits:

5. Partial constructors and partial events

Use to split generated and handwritten code safely.

public partial class ReportBuilder
{
    partial void OnBuildFailed(Exception exception);
}

Good fits:

Avoid when:

6. Lambda parameter modifiers without explicit types

Use when delegates need out, ref, or in parameters and the type is obvious.

TryParse<int> parser = (text, out result) => int.TryParse(text, out result);

Good fits:

Avoid when:

.NET 10 Runtime Guidance

JIT inlining and devirtualization

Small methods and interface calls may perform better without code changes. Prefer clear code first; measure before introducing micro-optimizations.

NativeAOT improvements

Consider NativeAOT for:

Avoid NativeAOT when the app relies heavily on reflection, dynamic loading, or libraries that are not AOT-friendly unless tested carefully.

Vectorization improvements

Use built-in APIs (System.Numerics, spans, memory APIs) before custom SIMD code. Only optimize numerical hot paths after profiling.

ASP.NET Core 10 Guidance

EF Core 10 Guidance

Named query filters

Use named filters when the project needs independently disabled filters, such as soft-delete plus tenant or region filtering.

modelBuilder.Entity<Order>()
    .HasQueryFilter(o => !o.IsDeleted, "SoftDeleteFilter")
    .HasQueryFilter(o => o.TenantId == tenantContext.TenantId, "TenantFilter");

Rules:

LINQ translation improvements

Prefer clear LINQ, but inspect generated SQL for complex queries, aggregation, pagination, or string operations.

Review Checklist

Imported Backend Reference Pack

Additional backend-specific .NET 10/C# 14 references were imported under references/backend-pack/:

Use these as supporting references only. Project docs/STANDARDS.md, SDD approvals, and the main skill guidance remain authoritative.

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.