Readable but slow. WhyAllocations and deferred execution. FixUse loops in critical sections.
Category: C#
C# async void Causes Invisible Crashes
No stack trace. WhyExceptions cannot be awaited. FixAvoid async void except event handlers.
ASP.NET Core Requests Hang Randomly
No exceptions thrown. WhyThread starvation due to sync-over-async. Fix await Task.Run(() => AsyncMethod()).ConfigureAwait(false);
Static State Causes Test Flakiness
Tests pass alone, fail together. WhyShared static state leaks between tests. Fix Avoid statics in business logic.
List.ForEach Hides Exceptions
Errors vanish. WhyExceptions thrown inside delegates are harder to trace. Fix Use explicit loops for critical logic.
Task.Run Inside ASP.NET Core Hurts Scalability
Seems async, kills throughput. WhyConsumes thread pool threads. Fix Use async APIs instead of offloading.
IEnumerable Executes More Than Once
Unexpected duplicate work. WhyDeferred execution. Fix var data = query.ToList();
Boxing Happens Without You Noticing
Performance drops mysteriously. WhyInterfaces cause value types to box. Fix Use generics to avoid boxing.
async void Swallows Exceptions
Errors disappear. Whyasync void cannot be awaited. Fix async Task MethodAsync()
ASP.NET Core Thread Pool Starves Under Load
Requests queue endlessly. WhyLong-running sync tasks block threads. Fix await Task.Run(LongRunningWork);
DateTime.Now Breaks Distributed Logic
Same code, different results. WhyLocal time zones and daylight saving. Fix DateTimeOffset.UtcNow π₯ Why DateTime.Now Breaks Distributed Logic (And What to Use Instead) Same code. Different results.If youβve ever seen time-based logic randomly fail in production, DateTime.Now might be the silent culprit. In distributed systems, local time is a trap. π¨ The Core Problem […]
LINQ Looks Clean but Allocates Heavily
Readable code, hidden cost. WhyMultiple enumerations. Fix var list = items.ToList();
Async Methods Still Block the Thread Pool
Looks async, behaves sync. WhyCPU-bound work inside async methods. Fix await Task.Run(Compute);
ASP.NET Core Memory Usage Keeps Growing
GC runs, memory stays high. WhyObject pooling misused or ignored. Fix services.AddPooledDbContextFactory<AppDbContext>();
Exceptions Used for Control Flow
Works until scale. WhyExceptions are expensive. Fix if (!TryParse(…)) return;
Events Cause Memory Leaks
Even in managed code. WhyUnsubscribed event handlers. FixAlways unsubscribe or use weak events.
Structs Can Be Slower Than Classes
Surprising but true. WhyLarge structs copied by value. Fix void Process(in MyStruct data)
ASP.NET Core Requests Hang Under Load
CPU low, threads exhausted. WhyBlocking calls inside async pipeline. Fix await SomeAsyncMethod();
Exceptions Used for Flow Control
Works⦠until scale. WhyExceptions are expensive. Fix Use Try-patterns instead.
LINQ Causing Hidden Allocations
Clean code, slow runtime. WhyDeferred execution + boxing. Fix Materialize once when needed.
C# Async Methods Still Block Threads
Looks async, isnβt. WhyCPU-bound work inside async. Fix Offload CPU work explicitly. await Task.Run(() => HeavyCalculation());
Events Can Cause Memory Leaks
Even in managed code. Why it happensUnsubscribed event handlers. FixAlways unsubscribe or use weak events.
DateTime.Now Can Break Distributed Systems
Time is harder than it looks. Why it happensTime zones + daylight saving. FixUse DateTimeOffset.UtcNow.
C# Value Types Copied More Than You Think
Structs arenβt always faster. Why it happensLarge structs passed by value. FixUse in parameters.
C# β GC.Collect() Hurts More Than It Helps
Manual GC kills performance. Rule Let the runtime decide.
C# β async void Event Handlers Swallow Exceptions
Crashes disappear silently. Fix Wrap logic with try/catch and logging.
C# β Equals Without Operator Overload Is Inconsistent
== and Equals() behave differently. Fix Override both consistently.
C# β Stopwatch Is More Accurate Than DateTime
Measuring performance with DateTime lies. β Fix Stopwatch sw = Stopwatch.StartNew();
C# β async Lambdas Capture Variables Unexpectedly
Loop variables are captured by reference. β Bug Perfectly compiled, logically broken code. β Fix Create a local copy inside the loop.
C# β string.Equals() Without ComparisonType Is a Bug
Default comparison is culture-sensitive. string.Equals(a, b) β Risk Unexpected results in different locales. β Fix string.Equals(a, b, StringComparison.Ordinal)

