Best of .NETApril 2026

  1. 1
    Article
    Avatar of devblogsDevBlogs·7w

    Explore union types in C# 15

    C# 15 introduces the `union` keyword in .NET 11 Preview 2, allowing developers to declare a closed set of case types with compiler-enforced exhaustive pattern matching. Unlike object, marker interfaces, or abstract base classes, union types don't require related types and prevent external extension. The compiler generates a struct with implicit conversions from each case type and a `Value` property. Switch expressions over union types are exhaustive without needing a discard arm, and adding a new case type triggers compiler warnings on incomplete switches. Custom union types are also supported via a `[Union]` attribute for existing libraries, including a non-boxing access pattern for performance-sensitive scenarios. Related proposals for closed hierarchies and closed enums round out a comprehensive exhaustiveness story for C#.

  2. 2
    Article
    Avatar of avalonia-blogAvalonia UI Blog·6w

    Avalonia for Visual Studio Code

    Avalonia has released a preview of a completely rewritten Visual Studio Code extension, built on the same new XAML parser as the Visual Studio extension. Key improvements include dramatically enhanced IntelliSense with richer completions and x:DataType Quick Info, Go To Definition support, overhauled error diagnostics, automatic XAML namespace imports, event handler generation, and a more reliable XAML previewer with better DPI handling and Zoom to Fit. Notably, the extension is now part of the paid Avalonia Accelerate subscription and is no longer open-source, though free community licenses are available for organizations under €1M in revenue.

  3. 3
    Article
    Avatar of wearedotnetWe Are .NET·5w

    Abstractions That Heal, Abstractions That Harm

    Good abstractions reduce cognitive load and isolate change; harmful ones accumulate quietly and turn codebases into labyrinths. Using .NET and ASP.NET examples — interfaces, middleware, dependency injection, generic repositories, and Entity Framework — the post argues that abstractions should be introduced only when there are at least two concrete things to generalize across. Premature abstractions built on assumptions rather than evidence create the illusion of flexibility while actually constraining future change. Leaky abstractions like EF's lazy loading obscure rather than simplify. The quality of an abstraction reflects the depth of domain understanding behind it, and vague names like IServiceManager signal abstractions introduced before the domain was understood. The real danger is cumulative drift: individually reasonable layers that compound over time into a system no longer resembling the problem it solves.

  4. 4
    Article
    Avatar of csharpcornerC# Corner·7w

    What is the Difference Between Task and Thread in C#?

    A beginner-friendly comparison of Thread and Task in C#, explaining the key differences in abstraction level, performance, and usability. Uses a restaurant analogy to illustrate how Tasks leverage the .NET Thread Pool for efficiency versus raw OS threads. Covers return values, exception handling, async/await support, cancellation, and guidance on when to use each approach.

  5. 5
    Article
    Avatar of dotnet.NET Blog·5w

    .NET 11 Preview 3 is now available!

    .NET 11 Preview 3 is now available, bringing improvements across the runtime, SDK, libraries, ASP.NET Core, .NET MAUI, C#, Entity Framework Core, and container images. Key highlights include: System.Text.Json gains more naming and default-ignore control; Zstandard compression moves to System.IO.Compression; runtime async removes the preview-API opt-in requirement; JIT optimizations improve switches, bounds checks, and casts; WebAssembly gets WebCIL and debugging improvements; the SDK adds file-based app splitting across files and `dotnet run -e` for passing environment variables; ASP.NET Core adds Zstandard response compression and earlier HTTP/3 request processing; .NET MAUI adds map clustering, XAML startup improvements, and Android 17/API 37 preview support; and EF Core improves SQL generation, migrations, and DbContext configuration.

  6. 6
    Article
    Avatar of andrewlock.NET Escapades·4w

    Removing byte[] allocations in .NET Framework using ReadOnlySpan<T>

    Using `ReadOnlySpan<byte>` properties instead of `static readonly byte[]` fields can eliminate heap allocations entirely — even on .NET Framework — because the compiler embeds the data directly into the assembly metadata. The optimization works only for byte-sized primitives (byte, sbyte, bool) with constant values, and only when returning `ReadOnlySpan<T>` (not `Span<T>`). For other types like `int[]`, the zero-allocation path requires .NET 7+ via `RuntimeHelpers.CreateSpan`. The post walks through the generated IL to confirm the behavior, highlights dangerous edge cases (non-constant values, mutable Span<T>) that silently cause per-access allocations, and notes that collection expressions provide partial compile-time safety for static properties but not local variables.

  7. 7
    Article
    Avatar of dotnet.NET Blog·5w

    .NET and .NET Framework April 2026 servicing releases updates

    Microsoft has released the April 2026 servicing updates for .NET and .NET Framework, covering versions 10.0.6, 9.0.15, and 8.0.26. The updates include fixes for five CVEs (CVE-2026-26171, CVE-2026-32178, CVE-2026-32203, CVE-2026-32226, CVE-2026-33116) along with non-security improvements. Changelogs are available for ASP.NET Core, the .NET runtime, Entity Framework Core, and WinForms.

  8. 8
    Article
    Avatar of milanjovanovicMilan Jovanović·4w

    The Test Pyramid Is a Lie (and What I Do Instead)

    The classic test pyramid — lots of unit tests, few integration tests — was practical advice for 2009 when spinning up real databases was slow and expensive. With Testcontainers and .NET Aspire, that constraint is gone. The author argues that most real bugs live at the seams (handlers, repositories, HTTP endpoints), where unit tests with mocks fail to catch them. The proposed alternative is a 'testing trophy' shape: a thin base of unit tests for pure domain logic (~15-25%), a thick middle of integration tests against real PostgreSQL/RabbitMQ/Redis (~60-70%), a small cap of E2E tests for critical flows (<10%), and architecture/contract tests as a foundation layer. A concrete example shows how a missing SaveChangesAsync call — undetected by 94% unit test coverage — would have been caught immediately by a single integration test.

  9. 9
    Video
    Avatar of zoranhorvatZoran Horvat·4w

    EF Core Is DDD (Here Is Why)

    EF Core natively supports Domain-Driven Design patterns without requiring custom wrappers. The post walks through configuring aggregates using EF Core's built-in configuration classes, achieving persistence ignorance by moving surrogate keys to shadow properties, implementing strongly-typed public IDs with value converters and alternate keys for cross-aggregate references, and applying CQRS where DbSets act as repositories, DbContext as unit of work, and LINQ to Entities as specifications. The conclusion is that wrapping EF Core to make it 'more DDD-like' is unnecessary since the implementation already exists.

  10. 10
    Article
    Avatar of meziantouMeziantou·4w

    URL Pattern Matching in .NET

    The Meziantou.Framework.Uri NuGet package brings the WHATWG URL Pattern API specification to .NET, enabling standardized URL pattern matching with named parameters, wildcards, optional segments, case-insensitive options, and pattern collections. The UrlPattern class supports both object-based and string-based pattern creation, making it useful for routing, security policies, and content filtering without resorting to custom regex.

  11. 11
    Article
    Avatar of ardalisArdalis·6w

    .NET Conf Most Popular Sessions Tool

    Steve Smith (Ardalis) built a CLI tool using .NET 10's new `dnx` feature to pull and display the most popular .NET Conf sessions from YouTube by view count for each year since 2021. The tool is distributed via NuGet and runnable with `dnx ardalis dotnetconf-stats`. The post also shares the top 10 session rankings for 2021–2025, noting that Clean Architecture sessions have consistently ranked in the top 3 every year. It explains why the author keeps presenting on Clean Architecture (sustained high demand) and introduces `dnx` as a convenient way to distribute and run .NET CLI utilities directly from NuGet without local installation.

  12. 12
    Video
    Avatar of zoranhorvatZoran Horvat·3w

    Your DDD Abstractions Are a Waste of Code

    A pragmatic critique of over-engineered DDD abstractions around Entity Framework Core. Instead of building heavyweight wrapper classes for repository, unit of work, and specification patterns, the author advocates using thin interfaces that delegate directly to DbContext — treating DbSet as the repository, LINQ to Entities as the specification, and DbContext itself as the unit of work. The result is persistence-ignorant, testable application code with minimal boilerplate. For queries, named query classes in the infrastructure layer replace abstract specification hierarchies. The approach keeps DDD's intent (decoupling, clarity) while eliminating unnecessary layers.

  13. 13
    Article
    Avatar of aspnetASP.NET Blog·3w

    Combining API versioning with OpenAPI in .NET 10 applications

    A step-by-step guide to implementing API versioning in .NET 10 applications using the new Asp.Versioning v10 package alongside Microsoft.AspNetCore.OpenApi. Covers both controllers and Minimal APIs, explains versioning strategies (URL, query string, header), and shows how to generate separate OpenAPI documents per version using the new WithDocumentPerVersion() method. Also demonstrates integrating SwaggerUI and Scalar for visualizing versioned API docs, compares the v8 vs v10 setup to highlight reduced boilerplate, and briefly covers API linting with Spectral and oasdiff.

  14. 14
    Video
    Avatar of freecodecampfreeCodeCamp·4w

    Tired of switching between C# for the back end and JS for the front end?

    Blazor is a Microsoft framework that lets developers build full-stack web applications using C# and HTML, eliminating the need to switch between C# for the backend and JavaScript for the frontend. It uses a component-based architecture similar to React or Vue and comes in two flavors: Blazor WebAssembly (code runs client-side in the browser at near-native speed) and Blazor Server (code stays on the server with UI updates pushed via SignalR). A key advantage is code sharing — DTOs, validation logic, and models can be reused across both client and server.

  15. 15
    Article
    Avatar of collectionsCollections·6w

    .NET 11 Preview 1 and 2: what's new across runtime, Blazor, EF Core, and more

    .NET 11 Previews 1 and 2 introduce Runtime Async V2, which moves async/await state machine logic into the runtime for lower overhead and better diagnostics. Native Zstandard compression is now built into the BCL, offering 2–7x faster decompression than GZip or Brotli. Blazor gains TempData for static SSR, IHostedService support in WebAssembly, a new web worker template, relative URI navigation, built-in form label components, an Environment component, a BasePath component, and simplified SignalR configuration. EF Core adds native SQL Server vector search via LINQ with DiskANN indexes. Additional highlights include BFloat16 support for ML, native OpenTelemetry tracing in ASP.NET Core, up to 17% smaller SDK container images, MAUI/Android improvements with CoreCLR as the default runtime, and CLI enhancements.

  16. 16
    Article
    Avatar of wearedotnetWe Are .NET·4w

    ConfigurationIgnoreAttribute in .NET 11

    NET 11 introduces ConfigurationIgnoreAttribute in Microsoft.Extensions.Configuration, filling a long-standing gap where there was no official way to prevent the configuration binder from populating a specific property. Previously, developers had to use a hacky workaround with ConfigurationKeyNameAttribute and a garbage key name. The new attribute is simple to use — just decorate any property you want excluded from binding. Common use cases include computed/derived properties and parsed representations of raw config values. Note that JsonIgnoreAttribute has no effect on the configuration binder and cannot be used as a substitute.

  17. 17
    Video
    Avatar of nickchapsasNick Chapsas·5w

    .NET Scripting is Finally Complete

    .NET 11 Preview 3 introduces the #include directive for file-based apps, enabling multi-file scripting without a full project setup. This feature, which will also be backported to .NET 10 LTS, allows developers to split code across multiple files during rapid prototyping. Two experimental flags must be enabled: one for the include directive itself and another for transitive (nested) includes. The goal is to bridge the gap between quick single-file scripting and graduating into a full C# project.

  18. 18
    Article
    Avatar of milanjovanovicMilan Jovanović·6w

    Implementing the Saga Pattern With Wolverine

    A practical guide to implementing the Saga pattern in .NET using Wolverine, demonstrated through a user onboarding workflow. Covers Wolverine configuration with RabbitMQ and PostgreSQL, defining saga messages including timeout messages, building a complete saga class with Start/Handle/NotFound methods, cascading messages via return values, and handling compensation logic when timeouts occur. Highlights Wolverine's convention-based approach that avoids the state machine DSL ceremony found in MassTransit or Rebus.

  19. 19
    Article
    Avatar of milanjovanovicMilan Jovanović·7w

    Implementing the Inbox Pattern for Reliable Message Consumption

    The Inbox pattern is the consumer-side counterpart to the Outbox pattern, solving the duplicate message processing problem that arises from at-least-once broker delivery. The implementation uses a PostgreSQL inbox_messages table with ON CONFLICT DO NOTHING for idempotent inserts, a generic MassTransit IConsumer that writes incoming messages to the table instead of processing them directly, and a background processor that fetches unprocessed messages in batches using FOR UPDATE SKIP LOCKED for safe concurrent processing. Batch updates use UNNEST to minimize round-trips. The post also covers operational concerns like table growth, poison messages, ordering guarantees, and monitoring, plus a comparison between the Inbox pattern and the Idempotent Consumer pattern explaining when to use each.

  20. 20
    Article
    Avatar of vsVisual Studio Blog·5w

    From AI to .NET: 20 VS Live! Las Vegas Sessions You Can Watch Now

    Microsoft has published 20 sessions from VS Live! Las Vegas 2026 on the Visual Studio YouTube channel, releasing approximately two per day. Topics covered include AI-assisted development with GitHub Copilot, modern .NET and C#, cloud-native apps on Azure, developer productivity, and real-world architecture. Notable sessions include keynotes on Visual Studio 2027 and AI applications, plus talks on ASP.NET Core, GitHub Actions, caching in .NET, and VS Code integration. Upcoming in-person VS Live! events are scheduled through 2027, with discounts available for Visual Studio subscribers.