In this project I tried to demonstrate some C# 9 source generator features from basic up to advanced.
For testing this sample you need the latest VS2022 updates (However, you can try it on VS2019 by changing target of console apps to .NET 5)
Microsoft > .NET Compiler Platform SDK > Source Generators
New C# Source Generator Samples
Reselyn Source Generators Cookbook