Jiří Činčura

C# 9 Source Generators - let the machine do the programming

Stop writing boilerplate code. Learn how C# 9 source generators let the machine do the programming for you at compile time.

C# 9 Source Generators - let the machine do the programming
#1about 2 minutes

What are C# source generators and how they work

Source generators are a metaprogramming feature that adds new source code to your project during the compilation phase.

#2about 6 minutes

Exploring common use cases for source generators

Source generators are ideal for replacing reflection, creating high-performance parsers, generating strongly-typed APIs, and producing AOT-friendly code.

#3about 3 minutes

Understanding the limitations and capabilities of generators

Source generators can only add new code, not modify existing code, and they run in a non-deterministic order but can produce compiler diagnostics.

#4about 6 minutes

Demo: Building a simple hello world generator

A step-by-step walkthrough shows how to create a basic source generator that adds a static class and method to the compilation.

#5about 7 minutes

Demo: Generating a C# class from a CSV file

This demonstration shows how to read an external file during compilation and dynamically generate a C# class based on its contents.

#6about 10 minutes

Demo: Automating the INotifyPropertyChanged pattern

Learn how to use attributes and a syntax receiver to automatically generate the boilerplate code for the INotifyPropertyChanged interface.

#7about 6 minutes

Demo: Creating a high-performance custom serializer

This example demonstrates building a source generator that creates a fast, custom serialization method for a class marked with an attribute.

#8about 4 minutes

Managing dependencies and producing compiler diagnostics

Understand the two types of dependencies for source generators and learn how to report custom warnings or errors back to the developer.

#9about 2 minutes

Summary and key takeaways for source generators

Source generators are a powerful tool for library authors to reduce boilerplate, improve performance, and create better developer experiences.

Related jobs
Jobs that call for the skills explored in this talk.
Name of

Name of

Remote
Intermediate
PHP
Java
+1

Featured Partners

Related Articles

View all articles
DC
Daniel Cranney
How to Use Generative AI to Accelerate Learning to Code
It’s undeniable that generative-AI and LLMs have transformed how developers work. Hours of hunting Stack Overflow can be avoided by asking your AI-code assistant, multi-file context can be fed to the AI from inside your IDE, and applications can be b...
How to Use Generative AI to Accelerate Learning to Code
DC
Daniel Cranney
10+ Free Tools Built on Top of the Bluesky API
Bluesky has been making waves recently, and the chances are you've heard the noise.Although it launched back in 2021, the platform saw a massive surge in popularity following the US presidential elections in November 2024, as millions of users withdr...
10+ Free Tools Built on Top of the Bluesky API

From learning to earning

Jobs that call for the skills explored in this talk.