C# Weekly #9: Union Types Land in C# 15, DocumentExtractionClient Opens Preview

C# · Weekly #9

C# Weekly #9: Union Types Land in C# 15, DocumentExtractionClient Opens Preview

csharpC#Weeklyunion-typesAI Abstraction Layer

Sources:GitHub Releases + 官方博客 + HN

📦 Version News

The current stable language version is C# 15, which is the default language version targeting .NET 11. On the runtime side, .NET 11.0 went GA on 2026-11-10 as an STS release, with support running through 2028-11-14 — choosing STS means you’ll need to plan an upgrade to the next version as soon as support ends. The latest patch for the LTS .NET 10.0 is 10.0.15, and staying on 10.x remains a reasonable choice for projects that want a long support window. This week (2026-11-23 to 2026-11-30) saw no new runtime or language releases; the official blog focused on new API previews and AI-related content, covered in the next section.

The standout addition in C# 15 is Union types: a value can be one of the declared set of case types, comes with implicit conversions from those types, and participates in exhaustiveness checking in switch expressions — miss a case and the compiler errors out immediately. The official example is “look up an item and either find it or report that it wasn’t found,” with the success and failure states each carrying their own data, instead of being shoehorned into exceptions or nullables. To express this “result is either A or B” semantics in the past, teams improvised: some used a base class with two subclasses, others a result tuple with a status flag, and exhaustiveness was enforced purely by human discipline. Union types hand that constraint to the compiler — forgetting a switch branch is a compile error, and when refactoring adds a new case type, every handling site surfaces instantly. For a systematic recap of the previous language release, see my earlier C# 14 deep dive.

📝 Deep Dive

DocumentExtractionClient Preview: File Parsing Finally Gets a Unified Abstraction

On 2026-11-24, Microsoft shipped DocumentExtractionClient, a preview API in the Microsoft.Extensions.DocumentExtraction package, written by Luis Quintanilla (Senior Program Manager). The main method, ExtractAsync, takes a stream and returns an ExtractionDocument — a tree of sections whose nodes contain text, tables, and images, with every element carrying a source reference back to the page/region it came from, making citations and highlighting downstream easy. It solves a real problem: until now, every parser/service had its own SDK and object model, so switching tools meant rewriting the code that consumes the results, and migrating the parsing layer was effectively a rewrite. Even just comparing the recognition quality of two OCR services side by side during evaluation required writing separate consumption code for each. With a single abstraction, providers become swappable and you can stack middleware. Anyone who has used IChatClient / IEmbeddingGenerator will recognize the pattern immediately: one abstraction, swappable providers, stackable middleware. Teams building RAG and document processing pipelines are the direct beneficiaries, and the preview stage is exactly the window to give feedback and shape the API.

Five Starter Providers, Covering Text-Layer PDFs to Scanned Documents

There are five launch providers, all in the .NET AI Community Toolkit, and together they span the full spectrum from lightweight to heavyweight:

ProviderMechanismBest For
PdfPigRuns in-processPDFs that already have a text layer
VisionLanguageModelBacked by any IChatClient with image input, local or hosted modelsScanned documents, photos
Azure Content UnderstandingAzure hosted serviceCloud parsing
Azure AI Document IntelligenceAzure hosted serviceStructured documents
Mistral OCRFast, converts OCR results directly to MarkdownSpeed-focused OCR

The selection logic is clear: if the document has its own text layer, go with PdfPig — in-process, zero service dependencies. Scans and photos go to the VLM or OCR routes. The companion samples repo (https://github.com/luisquintanilla/dotnet-document-extraction-samples) contains single-file C# examples you can dotnet run directly, keeping the onboarding cost minimal. My advice: run the samples first before deciding which provider route to take.

Where It Sits in the .NET AI Stack: the “Read” of the Context Layer

Microsoft has been explicit about where this API fits in the stack: DocumentExtraction handles reading files → Microsoft.Extensions.DataIngestion handles chunking and enrichment → Microsoft.Extensions.VectorData handles storing the results so they’re searchable. Together, the three steps form the foundation for supplying context to RAG / agentic workflows, with DocumentExtraction occupying the most upstream “read” step. Two things are worth noting. First, the source back-reference design makes citation tracing part of the data structure itself, so downstream code doesn’t need post-processing to guess “which page did this passage come from” — saving a layer of glue code when building question-answering systems with citations. Second, Microsoft stresses the API works standalone without AI: it’s equally valid as a plain document parsing abstraction, and traditional projects that just extract text from PDFs can adopt it too — which will determine whether it survives in non-AI projects.

Running Models Locally: .NET + Llama on Windows

The official blog post from 2026-11-23, “Run local models in your .NET apps with Llama on Windows,” continues this week’s ”.NET × AI” throughline. It shipped one day before DocumentExtractionClient: one brings documents into the pipeline, the other runs models on local Windows devices. For teams with data-sovereignty requirements — common in healthcare, finance, and legal — the two paths combine into a complete skeleton for a fully local solution: Llama processes scans locally, and the parsed results stay in-process. This line complements rather than replaces the Azure cloud services; for the trade-offs, see the Community Buzz section.

.NET 11 Tooling Recap: dotnetup and .NET Skills

The surrounding tooling announced alongside .NET 11’s release (2026-11-10) is still worth revisiting this week. dotnetup is a user-space toolchain manager for installing/updating the .NET SDK and runtime, in public preview, focused on side-by-side version management and keeping up with servicing updates — a direct fix for managing multiple SDK versions on CI machines and multi-project dev machines. It requires no administrator privileges, meaning non-admin developers can control their own SDK versions in restricted environments. .NET Skills (https://github.com/dotnet/skills) gives coding agents guidance on .NET tasks so agents know how to correctly invoke the .NET toolchain. Announced in the same batch: the official MCP C# SDK v2.0, the AG-UI .NET SDK (client/server APIs for agentic UI), and the AI cross-platform decision matrix published on 2026-11-20. Toolchain and agent ecosystem work are the two lines Microsoft invested most heavily in during the .NET 11 cycle — the former aims to reduce install/upgrade friction, the latter to make AI agents first-class citizens.

🔥 Community Buzz

Zero Hits on HN; Discussion Stays on the Official Blog

This week (11-23 to 11-30), HN saw zero hits for the csharp / dotnet / C# keywords (Algolia search window nbHits=0). With no external community debate, discussion concentrated in the official blog comments, where the DocumentExtractionClient provider abstraction was the main topic and the local-models route the second. From Llama on Windows on Monday to the DocumentExtractionClient preview on Tuesday, Microsoft bet on ”.NET as an AI application runtime” two days in a row, and this week’s discussion was largely driven by those two posts; the other tooling announcements (dotnetup, MCP SDK v2.0) drew little response in the comments.

Point of Contention: Will the Abstraction Layer Repeat the “Unified Interface” Problem?

The core disagreement around DocumentExtractionClient is the abstraction’s coverage. Supporters argue the IChatClient pattern is already proven, that swappable providers + stacked middleware is the right direction, and that the five starter providers from PdfPig to Mistral OCR already establish a capability gradient — during evaluation, swapping providers means changing one line of registration code. Skeptics question whether the ExtractionDocument model of a section tree + source back-references can accommodate the differences between services, or whether providers will ultimately be forced into a Procrustean bed — after all, PdfPig’s in-process model and the return structure of Azure hosted services differ considerably, and the abstraction layer will sooner or later pay a price between “generic enough” and “specific enough.” In preview, the API shape still has room to change — now is the best time for feedback.

Point of Contention: Local Models vs. Cloud Services

With “Llama on Windows” and the Azure-based providers landing in the same week, the trade-off between “running a VLM locally to process scans” and “plugging directly into Azure AI Document Intelligence” was the second discussion point. The former keeps data in-house, at the cost of depending on local compute and model quality — recognition quality on scanned documents is capped by the local model. The latter is easier and works well, but introduces service dependencies and per-call costs that grow linearly with volume in high-throughput pipelines. The AI cross-platform decision matrix from 2026-11-20 reads as the official, direct response, laying out the applicable scenarios for each path side by side. In community discussion, both sides have legitimate use cases, and the emerging consensus is to draw the line by data sensitivity.

Looking Ahead

DocumentExtractionClient is still in preview, and the API shape and provider lineup may keep changing; the samples repo is the direct entry point for tracking its evolution. Also watch for whether .NET 11.0’s first servicing update lands within this cycle, and whether dotnetup’s public preview updates along with it.