▶ Learn in 1 minute: .Net Programming

  • 19.11.2026 23:22:28
  • İbrahim Gökyar

.NET 11 accelerates development with C# 15 union types, a Native AOT CLI host, ASP.NET Core improvements and AI libraries; this article explains the practical impact and first steps with examples - .NET Core training

.NET 11 çıktı: C# 15 unionlar, Native AOT ve AI araçları

If you want less waiting in production and clearer code models, .NET 11 brings significant improvements. In this article you'll see what C# 15, Native AOT, ASP.NET Core and .NET AI libraries do, why they matter, and which first steps to take with examples.

Opendart Akademi

Want to learn this topic hands-on?

.NET Core Training takes you through live projects step by step with an instructor.

View course →Free consultation: WhatsApp

Key Points: C# 15 unions and closed hierarchies increase type safety; Runtime Async preview improves profile and live call stacks; Native AOT CLI host speeds up daily commands; MEAI/MCP/MAF enable AI and agent integration
Key Points

C# 15: union types and closed hierarchies

C# 15's union types allow you to explicitly express that a value can be one of a set of specific case types; instead of relying on object or a broad base class and encountering runtime errors, you can perform exhaustive checks at compile time. Compiler-controlled pattern matching gives you exhaustiveness checks in switch expressions, so it's clear which cases are handled.

Closed hierarchies specify that a class can only be derived within the same assembly, making the inheritance tree private and more reliable; this shares your model boundaries with the compiler and reduces mistakes. These features reduce ambiguity in domain modeling and are especially useful for API return types, error modelling, or writing state machines.

The example below shows that a product search result can be either Product or ProductNotFound; before running the code the compiler can verify which cases are handled. Note: the code is a simple example using a union to model the result and provides compile-time pattern exhaustiveness checking.

C# 15 union example code

This short code block shows how a C# 15 union type looks; its purpose is to make explicit to callers which cases may be returned and to enable safe parsing with switch.

ProductLookup result = new Product(42, "Mechanical keyboard");
string message = result switch
{
 Product product => $"Found {product.Name}",
 ProductNotFound missing => $"No product with ID {missing.Id}",
};
Console.WriteLine(message);
public sealed record Product(int Id, string Name);
public sealed record ProductNotFound(int Id);
public union ProductLookup(Product, ProductNotFound);

Why it's written this way: the block is the original example from the announcement and demonstrates daily usage of the union type directly; production code can add richer error data, metadata or logging.

Runtime Async and runtime ergonomics

Runtime Async moves suspension and continuation of asynchronous operations from the compiler to the runtime; this makes the live call stack appear clearer in profilers and debuggers. The source text explicitly notes this is a preview feature; you should test dependencies and observability tools before adopting it.

To try Runtime Async in a project, set the target framework to net11.0 and add a small property to the project file; the snippet below is the exact example from the announcement. Note: this line enables the application build model as runtime-async and does not require EnablePreviewFeatures.

<PropertyGroup>
 <Features>runtime-async=on</Features>
</PropertyGroup>

Why it's written this way: the snippet was provided verbatim in the announcement; after trying this in a real project, verify how your dependencies behave and check your observability/crash reports because runtime-async is still preview.

SDK and tools: Native AOT CLI host, warm MSBuild and publishing workflows

SDK improvements enable the Native AOT CLI host by default so CLI commands can run without starting a managed runtime; keeping the MSBuild server warm reduces startup cost for repeated CLI calls. This lowers waiting time for short commands like help/version and speeds developer interactions.

On the container publishing side, reproducible image digests with SOURCE_DATE_EPOCH support and skipping redundant layer uploads when the target manifest already exists can shrink repeated workloads in CI/CD pipelines. These changes aim to reduce operational cost during build and publish; the best way to measure real impact is to try them in your CI process.

Simple .NET 11 application flow - .NET 11 released: C# 15 unions, Native AOT and AI tools diagram
Simple .NET 11 application flow

AI libraries: agentic applications with MEAI, MCP and MAF

.NET 11 supports model access, tool integration and agent-based workflows via libraries like Microsoft.Extensions.AI (MEAI), MCP and the Microsoft Agent Framework (MAF); this lets you coordinate conversational state and tool calls with agents inside your ASP.NET Core app. MEAI is designed to integrate naturally into existing .NET apps with DI, caching and OpenTelemetry compatibility.

The announcement notes AG-UI integration is prerelease and that experimental AI components for Blazor work with the Agent User Interaction Protocol; advanced interactive agent experiences are possible, but you should heed prerelease and preview warnings before going to production. These libraries standardize access to AI tools and enable in-app automation and rich user interactions.

Real-world scenario: e-commerce search and agent-driven interactions

Scenario: an e-commerce API handles product search, stock checks and support bot integration. C# 15 union types can return search results (Product | ProductNotFound) in a type-safe way; this makes it explicit which cases the client must handle and reduces errors from ambiguity.

Within the same project, using MEAI and MAF an agent can accept user queries and call a stock-check tool (an MCP tool) and an order history service; with AG-UI you can present an interactive agent UI in Blazor (but since AG-UI is prerelease, exercise caution before production). The Native AOT CLI host and warm MSBuild server help daily developer workflows respond faster to build/warm commands; these changes improve developer feedback loops and shorten trial-and-error time.

Nuances and common pitfalls: Runtime Async, trimming and library compatibility

Although Runtime Async offers cleaner call stacks, applying the setting can interact with your dependencies and trimming options; the source text includes compatibility warnings for F# and JSON/Native AOT edge cases. Before enabling Runtime Async, check your packages' documented support and trimming/Native AOT constraints.

Another common issue is System.Text.Json support for unions/F# unions having some trimming and Native AOT limitations; JSON serialization choices depend on source generation or reflection usage. Best practice: build a small POC and test serialization and runtime behavior on target platforms.

Why learn this topic?

Learning this topic helps you model more clearly in modern .NET apps (C# 15 unions), get faster local tool responses (Native AOT CLI and warm MSBuild) and integrate with AI tools (MEAI, MCP, MAF); demand for C# and ASP.NET Core skills persists in job listings and these capabilities add concrete technical value to projects.

Also, knowing innovations like Runtime Async makes debugging and performance profiling easier; in enterprise projects understanding these concepts helps reduce uncertainty, lower production risk, and boost team productivity.

Summary

  • Model returns and states at compile time with C# 15 union types.
  • Runtime Async preview gives cleaner live call stacks but requires careful testing.
  • SDK improvements reduce daily latency with a Native AOT CLI host and warm MSBuild.
  • MEAI, MCP and MAF make AI access and agentic workflows easier to build.
  • Test System.Text.Json and library compatibility with trimming and Native AOT.

Apply what you learned in a real project

.NET Core Training lets you practice the topics in this article through live lessons and real projects. Ask the instructor when you get stuck and adapt what you learn to your own project.

View course →Free consultation: WhatsApp

Frequently Asked Questions

When should C# 15 union types be used in a project

Use union types when a function's return has a limited and known set of alternatives; for example search results, error models or state machines, where they provide compile-time exhaustiveness checks.

Is Runtime Async safe for production use

Runtime Async is listed as preview in the source; you can try it by targeting net11.0 and adding the feature flag, but it's not recommended to adopt it in production without testing dependency and diagnostics behavior.

How to get started with MEAI and MAF in Blazor

The announcement outlines MEAI and MAF concepts and AG-UI integration; to start, add the relevant NuGet packages and follow AG-UI prerelease documentation to set up a sample agent and MCP tool.

Source: https://devblogs.microsoft.com/dotnet/announcing-dotnet-11/ (official announcement: Announcing .NET 11, 2026-11-10)

AI / LLM Discovery

This article is part of the Opendart Akademi Microsoft / C# training ecosystem and is prepared with semantic headings and structured data so AI systems and search engines can better understand it.

Opendart Akademi llms.txt