10

C# Source Generators in Action, by Andrey Dyatlov

 3 years ago
source link: https://www.youtube.com/watch?v=052xutD86uI
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

C# Source Generators in Action, by Andrey Dyatlov

260 views
•May 14, 2021

138K subscribers

C# 9 introduced the long-awaited compiler integrated code generation capability. If you've dreamed of getting rid of thousands of lines of code or have always wanted to try metaprogramming, now it's easier than ever!

In this talk, you will learn not only how to write your own source generator from scratch, but also how to provide the user with the necessary configuration flexibility and clear messages about problems. When using source generators, it's difficult to look at the resulting code, debug and troubleshoot, and write tests. This keeps many programmers from using it and in this talk, you will learn how generators cope with these problems.

As metaprogramming isn't new to C#, this talk will also cover how a source generators' approach is different from other technologies such as Fody, PostSharp, T4, and so on. Do they still have unique niches and advantages, or is the future with generators?

0:00 - Introduction 1:01 - Why and what are Source Generators? 4:12 - Demo: INotifyPropertyChanged Source Generator 22:53 - Source Generators vs. ... 23:20 - Source Generators vs. IL weaving 30:30 - Source Generators vs. IL generation 31:32 - Source Generators vs. Reflection 33:26 - How will generators change metaprogramming? 34:32 - Common problems and best practices 35:02 - Sharing source generators with Nuget 36:27 - How do source generators fit together? 1:00:50 - Best practices 1:01:18 - Summary 1:03:25 - Q&A

Source code for the first demo: https://github.com/TessenR/NotifyProp... Source code for the second demo: https://github.com/TessenR/BestPracti... Useful links (existing generators, tutorials, how-to's, etc): https://gist.github.com/TessenR/ab40d...

Speaker: Andrey Dyatlov, ReSharper Software developer at JetBrains

Andrey started his programming career with SCADA systems and industry equipment. He joined JetBrains 5 years ago, and works on the C# language support in ReSharper/Rider on everything from parser implementation to static analysis and refactorings. He is interested in static program analysis, type theory, and metaprogramming.

Twitter: https://twitter.com/a_tessenr


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK