Mastering Argument Validation
TechGuys
0:00 / 0:00
Mastering Argument Validation
0 просмотров · 4 часа назад
TechGuys
11 подписчиков
0 просмотров · 4 часа назад
Nullable reference types give you a compiler warning. They don't stop null from showing up at runtime — and a lot of developers don't realize that until it bites them in production. In this chapter, we look at what actually enforces null checks, build ArgumentNullException.ThrowIfNull from scratch to understand CallerArgumentExpression, and catch a real, measurable cost hiding inside it — boxing, when you pass it a value type instead of a reference type.
📌 What we cover:
Why nullable reference types compile and run fine even with a warning
ArgumentNullException.ThrowIfNull, and how it knows your parameter's name
Recreating it manually with CallerArgumentExpression
The boxing allocation ThrowIfNull triggers on value types — benchmarked
Why nullable string annotations never did anything at runtime, on any framework
Writing your own ThrowIfNullOrEmpty using the same trick
Every claim in this video is backed by real, live-run output — no hand-waved numbers.
#csharp #dotnet #programming #softwareengineering #csharpperformance #dotnetinternals #benchmarkdotnet #nullablereferencetypes #jetbrainsrider