Exploring Pattern Matching Variety
Course Content
0 / 146 completedOverview
Working on legacy projects
The compilation pipeline
Who is this course for and prerequisites
Welcome
What will you learn in this course
Multi-targeting
Adding multi-targeting
What is target framework moniker (TFM)
Using init-only and required properties in .NET Framework
C Language version vs. Target framework
Compiler language specific types
PolySharp- source-only polyfills for C Language
Using PolySharp for init-only and required properties
Choosing the right C Language version
'latest' vs. specific C Language version
Conclusion
Overview 2
Using Directory.Build.props
Module Overview
Storage Model- Inline vs. Indirection
Exploring Storage
Analyzing Storage Model with Benchmarks
Inspecting Type Layout (part 2)
Exploring Access Patterns with Benchmarks
Copy Semantics- Assignment
Analyzing Access Patterns Benchmark Results
Copy Semantics- Parameter Passing
Equality Semantics
Summary
Overview 3
Object Initialization
Analyzing Object Construction Order
Using Analyzers to Avoid Making Virtual Calls in Base Constructors
A Custom Factory Method and Error Handling
Virtual Calls in the Base class Constructor
Exploring a Custom Factory Method Behavior at Runtime
Benchmarking the new() Constraint
Overview 4
The Readonly Field Trap
Conclusion 2
Boxing and Indexers
Exploring Different Kind of Copies
Why the Compiler Makes a Copy
Defensive Copy Overview
Manual Value-based Equality
Overview 5
How to Avoid Defensive Copies for Structs
Conclusion 3
Referential and Value-based Equality
Records Under the Hood
Issues With the Default Structs Equality
Overview 6
Records Limitations
Record Structs vs. Default Structs
System.Tuple vs. System.ValueTuple
Knowing the Limits- When to Move to Actual Types
Union Types- Why Do We Need Them
Union Types- the Basics
Union Types Under the Hood
Tuples in C
Overview 7
UnionTypes - Recap
Section Overview
Argument Validation and Nullable Reference Types
Conclusion 4
Union Types- the Deep Dive
Argument Null Checks in C
Checking for Null in C
Implementing Custom String Validation
Recreating ThrowIfNull Manually
Issues With Nullable Strings in .NET Framework
Analyzing ThrowIfNull Boxing Allocations
Overview 8
Summary 2
The issue with Multi-Targeting
Refactoring to Extension Everything
Extension Methods
Creating Polyfills for Argument Validation
Overview 9
Summary 3
Lambdas Are Ubiquitous
Extending the C Language
Lambdas Under the Hood
Benchmarking Lambda Expressions
NET 10 Delegate De-Abstraction
Profiling Closure Allocations
Method Group Conversion vs. Lambda Expressions
Issues With Capturing Loop Variables
Scope-based Code Generation for Lambda Expressions
Method Group Conversion vs. Lambda Expressions in Action
Overview 10
Exploring Pattern Matching Variety
Imperative vs. Declarative Code
Pattern Matching Exhaustiveness
Recursive Patterns Explained
Two Dimensions of Pattern Matching
Exhaustiveness Checks in Action
Open and Closed Hierarchies
Exhaustiveness Checks for Classes and Unions
Know When to Stop
Section Overview 2
Iterator Design Pattern in C
Overview 11
The Cost of Boxed Iterators
Foreach Under the Hood
Foreach and IEnumerable
Iterator as a State Machine
Enumerable De-Abstraction in .NET 10
Iterator as a Mutable Struct
Overview 12
Manual Iterator Implementation
Summary 4
Refactor To Use Iterator Blocks
Iterator Block Execution Semantics
Lowered C Code for Generated State Machines
State Machine Under the Hood
Benchmarking State Machine Allocations
State Machine Allocations
Resources in Iterator Blocks
De-Abstracting Iterator Blocks in .NET 10
Error Handling in Iterator Block
Overview 13
Two Syntaxes, One Model
Query Comprehensions vs. Method Calls
What Is IEnumerable-T-
Multiple Enumerations with IEnumerable-T-
Overview 14
LINQ Deferred Execution Model
Using Static Analysis to Avoid Multiple Enumerations
Summary 5
LINQ Performance Reputation
Analyzing Enumerable.Any Performance
LINQ vs. Manual Loop Performance Analysis
Mastering LINQ Performance
Performance Optimization Loop
Spanification in LINQ
LINQ Performance Improvements in .NET 10
Iterator Fast Path Overrides
LINQ Performance Optimization Patterns
Iterator Fusion
Type-based Specialization
For loop vs. Enumerable.SequenceEquals
Vectorization in .NET Framework
Conclusion 5
Summary 6