Menu

1 / 2

C# 14 Extension Members: The Shadowing Bug the Compiler Won't Warn You About

DEV Community: dotnet·Adrián Bailador·15 days ago
#71W5gMwv
#devtodotnet#devto#dev#extension#order
Reading 0:00
15s threshold

Code

Every claim below is backed by a test — the full extension syntax, the two compiler diagnostics, and the silent shadowing behavior, each verified against the .NET 10 SDK rather than quoted from documentation: csharp14-extension-members-dotnet10 . 8 tests pass, and dotnet build produces 0 warnings — which is itself part of the point.

A Property That Stopped Being Called, and Nothing Said So

A team extends Order , a record they don't want to touch directly because it's shared across three services, with a computed property for a shipping promotion:

extension ( Order order ) { public bool IsEligibleForFreeShipping => order . Total >= 50m && order . Region == "EU" ; }

Enter fullscreen mode

Exit fullscreen mode

It ships. It's used at a dozen call sites, reading exactly like a real property because syntactically it is one now.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.