dotnet-csharp-source-generators

Create and consume Roslyn source generators in .NET with incremental design patterns.

71|10|Updated Feb 11, 2026
One-click install
npx skills add https://github.com/wshaddix/dotnet-skills --skill dotnet-csharp-source-generators-wshaddix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-csharp-source-generators
Source: https://github.com/wshaddix/dotnet-skills/tree/main/skills/dotnet-csharp-source-generators
Command: npx skills add https://github.com/wshaddix/dotnet-skills --skill dotnet-csharp-source-generators-wshaddix

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill simplifies and optimizes .NET development by leveraging Roslyn source generators to automate repetitive coding tasks, reduce boilerplate, and improve runtime performance.

Core Features & Use Cases

  • Create Custom Generators: Build your own source generators using IIncrementalGenerator for incremental, cache-aware code generation.
  • Consume Built-in Generators: Utilize [GeneratedRegex], [LoggerMessage], and System.Text.Json source generators for compile-time optimizations.
  • Use Case: Automatically generate INotifyPropertyChanged implementations for ViewModel properties, or use [GeneratedRegex] to eliminate the runtime cost of compiling regular expressions.

Quick Start

Use the dotnet-csharp-source-generators skill to create a new source generator that automatically implements INotifyPropertyChanged for fields marked with a specific attribute.

Frequently Asked Questions about dotnet-csharp-source-generators

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use Roslyn source generators to reduce C# boilerplate?

Roslyn source generators reduce C# boilerplate by automatically generating code at compile time. You can build custom `IIncrementalGenerator` implementations or consume built-in generators like `[LoggerMessage]` to eliminate repetitive coding tasks.

What is the difference between IIncrementalGenerator and standard source generators in .NET?

IIncrementalGenerator provides incremental, cache-aware code generation in .NET. Unlike standard generators, it only re-executes when underlying syntax nodes change, optimizing Roslyn build performance by avoiding unnecessary regeneration of unchanged code.

How do I implement INotifyPropertyChanged automatically using C# source generators?

You can implement INotifyPropertyChanged automatically by creating a custom Roslyn source generator that targets fields marked with a specific attribute. The generator parses the syntax provider and emits the necessary property change notifications during compilation.

Does [GeneratedRegex] improve AOT compatibility in .NET applications?

Yes, [GeneratedRegex] improves AOT compatibility in .NET by compiling regular expressions at compile time. This source generator eliminates the runtime cost of parsing regex patterns and avoids using dynamic IL emission, which is incompatible with ahead-of-time compilation.

What is the best way to test and debug custom C# source generators?

Testing and debugging custom C# source generators involves utilizing specific testing strategies to verify generated syntax and validating diagnostic reporting. You can debug generators by attaching the debugger to the Roslyn compiler process during build execution.

Can I use System.Text.Json source generators for compile-time serialization in C#?

Yes, you can use System.Text.Json source generators for compile-time serialization in C#. They generate highly optimized serialization code at build time, which improves runtime performance and ensures your JSON processing remains AOT-compatible.