Using the wrong DI lifetime is the #1 cause of concurrency bugs in ASP.NET Core. We revisit Singleton, Scoped, and Transient with a focus on thread safety. The Three Lifetimes Lifetime Created… Thread Safety Transient Every time requested Safe (Instance per usage) Scoped Once per HTTP Request Safe (Single thread per request) Singleton Once per […]
Read more →Month: March 2021
Azure Static Web Apps: Now Generally Available
Azure Static Web Apps (SWA) has hit GA. It’s the best way to host Blazor WASM, React, or Vue apps on Azure. Features Global Hosting: Content serves from edge locations. Integrated API: Deploy Azure Functions alongside your frontend in the same repo. Auth: Built-in auth for Azure AD, GitHub, etc. Staging Environments: Every Pull Request […]
Read more →Azure SQL Hyperscale: 100TB Databases
Traditional Azure SQL Database is limited by the disk size of the underlying VM (4TB max usually). **Hyperscale** decouples compute from storage, allowing databases to grow up to 100TB with rapid scaling. Architecture Why use it? **Instant Backups**: Backups are file-snapshots, taking zero IOPS from the compute. **Fast Restore**: Restoring a 50TB database takes minutes, […]
Read more →Integration Testing with Testcontainers
Mocking the database in tests is a lie. In-memory databases (like EF Core InMemory) behave differently than SQL Server. **Testcontainers** allows you to spin up real, throwaway Docker containers for your integration tests. Setup in xUnit Writing the Test Key Takeaways Test against the exact version of the database you use in production. Works for […]
Read more →React Query: Server State vs Client State
Redux is great for client state (is the modal open?), but terrible for server state (is this data fresh?). React Query (now TanStack Query) manages caching, background updates, and stale data automaticallly. The Default Stale-While-Revalidate Strategy React Query assumes data is stale immediately (0ms) but keeps it in cache for 5 minutes. When you request […]
Read more →C# 9 Source Generators: Removing Reflection
Reflection is slow. It happens at runtime, bypasses type safety, and prevents trimming. Source Generators solve this by generating code at compile time. In this guide, we build a generator that automatically implements a `MapTo` method for DTOs, replacing AutoMapper. The Goal The Generator Logic Key Takeaways Source Generators enable **Zero-Overhead abstractions**. They are essential […]
Read more →