A collection of C# source generators that automatically generate boilerplate code at compile time, reducing manual coding and improving code maintainability.
This package provides sixteen powerful source generators:
- Abstraction Generator - Interface and implementation generation for static classes
- ActionCommand Generator - Compile-time
ICommandproperty generation (sync, async, parameterized, cancellable) for MVVM - AutoMapper Generator - Compile-time property-to-property mapping method generation
- Assembly Information Generator - Compile-time assembly metadata constants without reflection
- Builder Generator - Fluent builder pattern generation for classes and structs
- Cloneable Generator - Compile-time
Clone()andDeepClone()method generation with collection and struct support - Decorator Generator - Compile-time decorator pattern generation with full interface delegation, generic methods, events, and partial method hooks
- Disposable Generator - Compile-time
IDisposable/IAsyncDisposablepattern generation with ordered resource cleanup - Enumerator Extensions Generator - Fast, allocation-free extension methods for enums
- Equality Generator - Compile-time
Equals,GetHashCode, and operator generation - Factory Generator - Compile-time factory pattern generation with automatic implementation discovery
- INI File Generator - Compile-time INI file serialization and deserialization
- Notification Properties Generator - Configurable
INotifyPropertyChanged/INotifyPropertyChangingimplementation - Singleton Generator - Thread-safe singleton pattern generation with lazy or eager initialization
- ToString Generator - Compile-time
ToString()override generation - Validator Generator - Compile-time data annotation validation
Each generator has its own page covering why to use it, its benefits and usage examples. See the documentation index for an overview.
Install the package via NuGet:
dotnet add package BB84.SourceGeneratorsOr via Package Manager Console:
Install-Package BB84.SourceGeneratorsIn the project where you want to use the generators, add a reference to the package and include the appropriate using directive for the attributes:
using BB84.SourceGenerators.Attributes;If the attributes are not recognized, make sure that the EmitCompilerGeneratedFiles property is set to true in the project file:
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>- .NET Standard 2.0 or higher
- C# 7.3 or higher
- Supports .NET Framework 4.7.2+, .NET Core 2.0+, .NET 5+, .NET 6+, .NET 7+, .NET 8+
Source generators run during compilation and generate additional C# source files that are compiled alongside your code. This means:
- Zero runtime overhead - All code is generated at compile time
- IntelliSense support - Generated code appears in Visual Studio IntelliSense
- Debuggable - You can step through generated code during debugging
- No reflection - Generated code uses direct method calls
Contributions are welcome! If you have an idea for a new feature, improvement, or bug fix, please follow these steps:
- Have a look at the Issues to see if your idea has already been discussed.
- If you want to work on an existing issue, please comment on the issue to let others know you're working on it.
- Fork the repository and create a new branch for your contribution.
- Make your changes and commit them with clear and descriptive messages.
- Push your changes to your forked repository and submit a pull request to the main repository.
We expect all contributors to adhere to the Code of Conduct.
This project is licensed under the MIT License - see the LICENSE file for details.
Robert Peter Meyer (BoBoBaSs84)
- GitHub: @BoBoBaSs84
- Repository: BB84.SourceGenerators
See releases for version history and changelog.