Roozie.AutoInterface
0.1.0-beta
See the version list below for details.
dotnet add package Roozie.AutoInterface --version 0.1.0-beta
NuGet\Install-Package Roozie.AutoInterface -Version 0.1.0-beta
<PackageReference Include="Roozie.AutoInterface" Version="0.1.0-beta" />
paket add Roozie.AutoInterface --version 0.1.0-beta
#r "nuget: Roozie.AutoInterface, 0.1.0-beta"
// Install Roozie.AutoInterface as a Cake Addin #addin nuget:?package=Roozie.AutoInterface&version=0.1.0-beta&prerelease // Install Roozie.AutoInterface as a Cake Tool #tool nuget:?package=Roozie.AutoInterface&version=0.1.0-beta&prerelease
Roozie.AutoInterface
What is it?
Roozie.AutoInterface is a C# source generator that generates an interface for a class. The generated interface contains the XML-doc comments, public properties, and public methods.
Why?
Interfaces are great for keeping your code loosely coupled and unit testable. But, they add some maintenance overhead. This source generator will keep your interfaces up to date.
How to use it?
- Add the NuGet package to your project.
- Add the
[AutoInterface]
attribute to the class you want to generate an interface. - Build your project.
- That's it! The interface will be automatically generated, and you set the class to implement it.
- The generator will automatically implement the interface if you set your class to partial.
Check out the tests (1, 2) if you need some examples.
Configuration
You can configure the generator in the [AutoInterface]
attribute. The following options are available:
Option | Default Value | Description |
---|---|---|
Name | "I" + Class name | Set the interface to whatever name you want. |
IncludeMethods | true |
Set to false , the generator will automatically include methods in the interface. You can mark a method as included by adding the [AddToInterface] attribute. |
IncludeProperties | true |
Same as IncludeMethods |
ImplementOnPartial | true |
When true, the interface will be automatically implemented if the class is marked as partial. |
Contributing
Please open an issue if you find a bug or have a feature request. If you'd like to contribute, please open a pull request.
Kudos
Shout out to Andrew Lock's Source Generator series. It was an excellent resource for learning all aspects of source generators.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.6.1 | 455 | 7/15/2023 |
0.6.0 | 571 | 4/17/2023 |
0.5.0 | 199 | 4/16/2023 |
0.4.0-beta | 178 | 1/27/2023 |
0.3.0-beta | 166 | 1/22/2023 |
0.2.0-beta | 170 | 1/17/2023 |
0.1.1-beta | 292 | 12/15/2022 |
0.1.0-beta | 228 | 12/12/2022 |