Technology

.NET Without the Ceremony

Single-file C# apps you run like a script, a `field` keyword that kills backing-field boilerplate, and Native AOT grown up enough to ship. .NET has been quietly shedding ceremony, and it's getting interesting again.

12 Oct 2026

I spend most of my hobby time in Rust and Go these days. Everything on the server behind this site is a small container built from one of those two. But .NET is my day job, and has been for a long time, and .NET 10, the current long-term-support release, has three features that go straight at the things that used to annoy me most: the ceremony around tiny programs, the boilerplate around properties, and the weight of the runtime you have to ship.

Single-file apps: C# as a scripting language

Until .NET 10, even a ten-line utility needed a project: a .csproj, a folder, a dotnet new. Now a single .cs file is enough:

#:package Humanizer@2.14.1

using Humanizer;

var started = DateTime.UtcNow.AddHours(-3);
Console.WriteLine($"Build started {started.Humanize()}");

dotnet run app.cs builds and runs it. The #: lines are directives that replace the project file: #:package pulls a NuGet package, #:sdk picks the SDK, #:property sets any MSBuild property, and #:project references another project. That means a complete web API fits in one file too:

#:sdk Microsoft.NET.Sdk.Web

var app = WebApplication.Create(args);
app.MapGet("/", () => "Hello from one file");
app.Run();

On Linux and macOS it goes one step further. Add a shebang (#!/usr/bin/env -S dotnet --) as the first line, chmod +x app.cs, and you run it like any other script: ./app.cs. It's the kind of thing I've been using Python and shell for, with a real type system on top.

The part I like most is that there's no dead end. When the script grows up, dotnet project convert app.cs turns it into a normal project with a .csproj that carries over every directive. You start small and graduate when you need to, instead of choosing up front.

The field keyword

C# has had auto-properties forever, but the moment you needed one line of logic in a setter (a null check, trimming, validation) you were back to declaring a private backing field by hand and writing both accessors. C# 14 fixes that with the contextual keyword field, which refers to the compiler-generated backing field:

public class Story
{
    public string Header
    {
        get;
        set => field = string.IsNullOrWhiteSpace(value)
            ? throw new ArgumentException("A story needs a header")
            : value.Trim();
    }

    // Lazily created on first use, no separate field needed
    public List<string> Tags => field ??= [];
}

It's a small feature, but it removes exactly the kind of noise that makes C# classes longer than they need to be. One thing to watch when upgrading: if a class already has a member called field, references to it inside property accessors now mean the keyword instead. Write @field or this.field to keep the old meaning, or better, rename it.

Native AOT has grown up

Native AOT compiles a .NET app ahead of time into a single native executable: no JIT, no runtime to install, fast startup and a small memory footprint. It arrived for console apps in .NET 7. .NET 8 brought it to ASP.NET Core minimal APIs, with WebApplication.CreateSlimBuilder and a webapiaot template. And in .NET 10 it's the default for file-based apps: dotnet publish app.cs produces a native binary unless you opt out with #:property PublishAot=false.

For a regular project it's one property:

<PropertyGroup>
  <PublishAot>true</PublishAot>
</PropertyGroup>

The price is that nothing can be decided at runtime. There's no Reflection.Emit, no loading assemblies on the fly, and reflection-heavy code gets trimmed away unless you tell the compiler what you need. In practice that means source generators. JSON is the typical example:

[JsonSerializable(typeof(Story))]
internal partial class AppJsonContext : JsonSerializerContext { }

var builder = WebApplication.CreateSlimBuilder(args);
builder.Services.ConfigureHttpJsonOptions(o =>
    o.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonContext.Default));

The trimming warnings are the real gatekeeper: if your app and its dependencies publish without them, it will run. A lot of the ecosystem has caught up, but older libraries built around runtime reflection still won't make it, so check your dependencies before you commit.

Why this matters to me

These three together change what .NET is good for. A single file you can run like a script, a language that keeps getting less verbose, and a native binary at the end. That's the same deployment story that makes Go so pleasant: one executable in a minimal container image. I'm not moving this site off Rust, but for the next small tool or service I write, C# is back on the shortlist.