Let's Generate Some Code! Getting Started with Roslyn Source Generators
KCDC - 2024
Roslyn Source Generators have been around since .NET 5. They are a powerful tool to help improve the efficiency of your development process but can be a daunting process to get started with.
In this ½ day workshop, we’ll dive into how source generators can elevate your workflow by reducing repetitiveness. We’ll build a source generator that can auto-create interface properties on a class; geared towards reducing the amount of code needed to be manually written for entities and DTOs.
Learn about the different approaches that can be taken when creating a source generator. Explore how to approach testing your generator and how to incorporate it into your projects with topics including but not limited to:
- Incremental source generators
- Unit Testing source generators
- Publishing source generators as a NuGet package
- Some of the common pitfalls encountered during development
We’ll also cover some of the resources you can use to ease into the process of getting started with source generators. If time, we’ll also discuss some other ways source generators can be used to reduce your overall code footprint.
This workshop will include some try it yourself elements with a more classroom like environment, so come prepared to write some code! We’ll work through some examples and use cases together.
Stop Copy Pasting Code! Use Source Generators Instead!
KCDC - 2024
A majority of the code we write as software developers is controlling the flow of a data in and out of a database, usually via some kind of API layer. Over time this typically evolves into an N-Tier implementation and as we build, despite our best efforts to abstract and modularize, it is inevitable that we will copy and paste code… so let’s automate that code creation.
In this session we will explore how our development teams were able to take advantage of Roslyn Source Generators to automate the creation of our repeated implementation patterns, allowing us to generate 95% of our JSON API tier and a healthy amount of the underlying logic. This significantly improved our code maintainability, team velocities, and allowed us to deliver a predictable and consistent API design for our customer integrations.
At the end of this session you'll be able to walk away with some practical examples of using Source Generators to reduce your repeatable code.