Skip to content

Add lightweight Native AOT essentials sample - #20

Merged
balajibashyam merged 4 commits into
mainfrom
feature/native-aot-essentials-sample
Aug 7, 2026
Merged

Add lightweight Native AOT essentials sample#20
balajibashyam merged 4 commits into
mainfrom
feature/native-aot-essentials-sample

Conversation

@balajibashyam

Copy link
Copy Markdown
Contributor

Summary

Adds a minimal .NET 10 companion sample for the .NET 8 Essentials: Core Features & Getting Started tutorial.

What's included

  • New sample: dotnet-8-essentials/core-features-get-started/ — 10 files

    • WebApplication.CreateSlimBuilder AOT-friendly hosting
    • AOT-compatible singleton DI service (ITextTransformer / TextTransformer)
    • Minimal API endpoints: fixed sample metadata (/), runtime capability (/runtime), typed echo POST (/echo)
    • Source-generated System.Text.Json metadata via AppJsonSerializerContext (all 5 body types registered)
    • Explicit input validation with typed bad-request responses
    • PublishAot=true in the project file (analysis participates during development)
    • 8 managed tests covering JSON context, transformer behavior, endpoints, validation, and 404
    • Zero direct NuGet packages in the application project
  • Root README: New sample row + updated .NET 8 Essentials tree (3 siblings)

  • GitHub Actions: New test-native-aot-essentials job — installs clang/zlib1g-dev, publishes linux-x64 Native AOT, fails on AOT/trim warnings, executes the native binary directly (not via dotnet), verifies dynamicCodeSupported=false / dynamicCodeCompiled=false, exact JSON responses, and 400 on invalid input

Deliberately omitted (stays in the full tutorial)

Todo CRUD, controllers/MVC, EF Core/databases, Swagger/OpenAPI, reflection fallbacks, benchmarking, performance claims, Docker, authentication, cloud deployment

Versions

  • .NET SDK: 10.0.302
  • Microsoft.AspNetCore.Mvc.Testing: 10.0.10
  • Microsoft.NET.Test.Sdk: 18.8.1
  • xunit.v3: 3.2.2
  • xunit.runner.visualstudio: 3.1.5
  • Application NuGet dependencies: none (only auto-referenced AOT toolchain packages)

Validation

  • dotnet restore — passed
  • dotnet build --configuration Release — passed (0 errors, 0 warnings)
  • dotnet test --configuration Release — passed (8/8)
  • Native AOT publish (linux-x64) — passed, no IL2026/IL3050/other warnings
  • Native binary executed directly: root JSON exact match; dynamicCodeSupported=false, dynamicCodeCompiled=false; echo {"message":"HELLO NATIVE AOT","length":16}; invalid input → 400
  • Application package count: 0
  • Security scan — clean
  • YAML validation — passed

@balajibashyam
balajibashyam merged commit 183f864 into main Aug 7, 2026
22 checks passed
@balajibashyam
balajibashyam deleted the feature/native-aot-essentials-sample branch August 7, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant