Runtime
news

26stories

Stories

System.Text.Json
JSON Lines

Stop Hand-Rolling JSON Lines With WriteLine: .NET 11 Writes Them for You

.NET 11 gives System.Text.Json the writer that JSON Lines (JSONL) always lacked: new SerializeAsyncEnumerable overloads take an IAsyncEnumerable<T> and write it to a Stream or a PipeWriter in one call. With topLevelValues: true every record is emitted compactly followed by an LF, so the malformed files produced by hand-rolled WriteLine loops disappear. It ships in .NET 11 RC 2, not yet GA.

Performance
File I/O

Sync vs Async File I/O in .NET: Throughput, Scalability and Buffer Size

In this bonus post to his async/await series, Gérald Barré argues that the standard advice to prefer async file I/O only tells half the story. For single-operation latency the synchronous path measures faster, while the real advantage of async shows up as scalability when many operations run concurrently. The post also looks at buffer size and FileOptions flags as tuning knobs.

CBOR · .NET
Reading partial binary data
CCC# Corner Aarav Patel Oct 29

Reading CBOR Data Incrementally in .NET

C# Corner walks through reading CBOR data with the System.Formats.Cbor package, from a basic CborReader example to buffering partial network reads. It stresses separating incomplete input from malformed data, enforcing size limits and defining message boundaries. Useful for services that receive binary payloads from devices or APIs.

.NET 11 Native AOT
Domain model under AOT

Publishing a C# 15 Domain Model with Native AOT on .NET 11

NimblePros published its Tiles & Tokens sample, which relies on C# 15 unions and closed hierarchies, as a Native AOT binary on the .NET 11 RC1 SDK. The domain and serialization code produced no trimming or AOT warnings, and the native app ran correctly. The publish errors came from a reflection-based converter, an anonymous type and EF Core, which is a useful checklist for anyone planning a Native AOT app.

.NET 11
Async under the hood
HBHabr C# (ru) sproshchaev (OTUS) Oct 28

Where Runtime Async in .NET 11 saves memory and where it doesn't

.NET 11 moves async method suspension from compiler-generated state machines to the runtime, with the JIT optimizing the boundaries between async methods. The author reruns the official benchmarks on RC2 and compares allocations, stack traces and assembly size. The gains are real in synchronous await chains and exception-heavy paths, but measurement setup changes the picture.

C# performans
When optimization pays off
PGDaniel Marbach (planetgeek) Daniel Marbach Oct 27

When low-level .NET performance optimization is worth the complexity

Daniel Marbach draws on his pull requests to the Azure .NET SDK to explain when low-level performance work pays off. He argues that in library code, small allocation decisions multiply across every caller, yet added complexity carries a maintenance cost. The post offers a practical decision framework for library authors and application developers alike.

BenchmarkDotNet
Measure before optimizing
DVDEV Community: #csharp Henrique Mauri Oct 25

Measuring .NET performance with AI help using BenchmarkDotNet

The author optimizes a .NET reporting method step by step with BenchmarkDotNet, measuring each change separately. The final version drops from about 1.55 s to 11.9 ms and allocations fall from 33.1 MB to 0.23 MB. It is a useful case for anyone who wants to check AI-proposed optimizations with benchmarks and output comparisons before merging them.

.NET 11
Shell calls without deadlock

.NET 11 Process.RunAndCaptureText avoids the classic stdout/stderr deadlock

.NET 11 RC2 adds Process.RunAndCaptureText, which runs an external command, drains stdout and stderr together and returns both strings with the exit code. It removes the deadlock that the classic redirect-and-ReadToEnd pattern can hit on noisy tools. Anyone who shells out to git, ffmpeg or internal CLIs will want to know the new helpers and their timeout behavior.

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message