Explains the .NET Garbage Collector's mark, relocate, and compact phases on the managed heap and its Gen 0/1/2 generational model, showing why short-lived objects like loop variables are reclaimed cheaply in Gen 0 while longer-lived objects get promoted to slower, less frequent collections. ...
Uses BenchmarkDotNet with MemoryDiagnoser to measure boxing a plain int into object, unboxing it back, and comparing both against an unboxed baseline, then extends the test to ArrayList versus List<int> to quantify how boxing's hidden heap allocations and GC pressure outweigh simple stack usage. ...
Shows how to build and compile C# expression trees at runtime using ParameterExpression, ConstantExpression, and Expression.Lambda to generate a working Func<int,int> delegate, then extends the technique to filter a Building entity's properties dynamically based on user-chosen search conditions. ...
Demonstrates with runnable C# code why an exception thrown inside an async void method crashes the app instead of being caught by a surrounding try/catch, unlike async Task, then walks through the compiler-generated state machine and AsyncTaskMethodBuilder that make Task methods exception-safe. ...
Walks through installing LINQPad, created by Joe Albahari in 2007, connecting it to PostgreSQL and SQL Server databases, and using its interactive Database Explorer to drill into related tables like Albums and Tracks while inspecting the exact SQL generated behind an EF Core LINQ query. ...
Benchmarks JSON serialization of Blog and Course models three ways in C# using BenchmarkDotNet: a reflection-based serializer, a Roslyn source generator, and the .NET 6 incremental source generator, showing how caching compilation results cuts the overhead of repeated code generation. ...
Applies 16 measured optimizations to a single ASP.NET Core PostsController endpoint over a 10,000-row PostgreSQL table, benchmarking each step from EF Core's AsNoTracking (up to 30% faster) through field projection and Skip/Take pagination to reach a cumulative 70% cut in response time. ...
Builds audit logging into a PostgreSQL-backed ASP.NET Core job-portal API using an IAuditableEntity interface with CreatedAtUtc, UpdatedAtUtc, CreatedBy, and UpdatedBy on Applicant and Company entities, noting EF Core's shadow properties as an alternative that avoids adding those fields directly. ...
Builds a Roslyn-based C# source generator from scratch, implementing ISourceGenerator's Initialize and Execute methods in a netstandard2.0 class library so a HelloSayenGenerator injects a working Console.WriteLine method into the compilation at build time with zero runtime cost. ...