~/talk

Pattern-based C#: if it quacks like a duck…

Talkat NDC Oslo 2025 · 2025-05-19..05-23· [dotnet]
links:none on file
slides:none on file

Live coding shows exactly what shapes the Roslyn compiler recognizes and how to teach it new ones: a source generator and a manual Deconstruct method enable tuple deconstruction for a plain class, adding an Add method plus collection builder attribute gives collection and span-backed initialization, custom GetEnumerator and ref struct enumerator enable foreach without IEnumerable, an own custom awaiter and async enumerator let await and await foreach work, a bespoke async method builder and interpolated string handler are implemented, and a benchmark proves interface enumeration boxes and allocates.

AI-written summary · about

  1. 0:00Compiler patterns in C#
  2. 1:58Deconstructing without interfaces
  3. 7:17Method shape for deconstruction
  4. 10:03Collection initialization patterns
  5. 11:50Collection initializer support
  6. 13:13Dictionary initialization with Add
  7. 15:23Optimizing with CollectionBuilder
  8. 19:42Indexing with implicit syntax
  9. 21:50Enabling implicit indexing
  10. 24:17Slicing with Range and FromEnd
  11. 26:45Slice method for collections
  12. 28:30Foreach without IEnumerable
  13. 30:58Custom enumerators for foreach
  14. 34:52Async disposal for ref structs
  15. 35:55Awaiting any type
  16. 41:01Extending awaitable types
  17. 43:35Custom awaiters for await
  18. 47:33Returning values from awaiters
  19. 48:36Live quiz
  20. 48:57Async method builder patterns
  21. 51:24Interpolated string handlers
  22. 53:08Custom string handlers example
  23. 54:31Non-extendable patterns
  24. 57:46Performance impact of static typing
  25. 59:54Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.