Tag: csharp
All the articles with the tag "csharp".
- Discriminated unions in C# before C# 15: the workarounds Before C# 15, C# had no discriminated unions. How ASP.NET Core Results<> fakes one with implicit operators, and when to use OneOf or F# instead.
- Server-Timing Headers in ASP.NET Core: Backend Metrics in Browser DevTools Add Server-Timing headers to an ASP.NET Core app so database and API timings show up in Chrome, Edge and Firefox DevTools next to the request.
- Device Bound Session Credentials in ASP.NET Core Device Bound Session Credentials tie a session cookie to a private key on the device, so stolen cookies go stale. How DBSC works, and why .NET 11 dropped it.
- Using ASP.NET Core Passkeys for Second Factor Authentication Use passkeys as a second factor after password login in ASP.NET Core Identity on .NET 10, with a 2FA token provider and two endpoints to create and verify.
- Keyed Services (Named registrations) in .NET Service Provider Keyed services in .NET 8 let you register several implementations of one interface under a key, and inject the right one without factories or switch statements.
- TimeProvider and the End of Untestable DateTime.Now DateTime.Now is hard to test. Since .NET 8, TimeProvider replaces your own clock wrapper: how to inject it and control time in tests with FakeTimeProvider.
- Discriminated unions in C# 15: the union keyword in .NET 11 C# 15 adds a union keyword for discriminated unions in .NET 11: declaring union types, implicit conversions, exhaustive switch and null handling.
- Provide opt-in to experimental APIs using C#12 ExperimentalAttribute C# 12 adds ExperimentalAttribute so library authors can mark APIs as experimental and make consumers explicitly opt in. How it works and how to suppress it.