Roozie.AutoInterface
0.6.1
dotnet add package Roozie.AutoInterface --version 0.6.1
NuGet\Install-Package Roozie.AutoInterface -Version 0.6.1
<PackageReference Include="Roozie.AutoInterface" Version="0.6.1" />
paket add Roozie.AutoInterface --version 0.6.1
#r "nuget: Roozie.AutoInterface, 0.6.1"
// Install Roozie.AutoInterface as a Cake Addin #addin nuget:?package=Roozie.AutoInterface&version=0.6.1 // Install Roozie.AutoInterface as a Cake Tool #tool nuget:?package=Roozie.AutoInterface&version=0.6.1
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.
dotnet add package Roozie.AutoInterface --prerelease
Create a class where you want to generate an interface.
public class MyClass
{
public string MyProperty { get; set; }
public void MyMethod()
{
// Do something
}
}
- Add the
[AutoInterface]
attribute to the class. - An interface will be generated in the same namespace as the class.
You can now use the generated interface in your code.
If the class is partial
, the interface will be automatically implemented.
Check out the tests (1, 2) for 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
Andrew Lock's Source Generator series is an excellent resource for learning all aspects of source generators.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
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 |