Blake11.AutoInterface
1.0.18
dotnet add package Blake11.AutoInterface --version 1.0.18
NuGet\Install-Package Blake11.AutoInterface -Version 1.0.18
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Blake11.AutoInterface" Version="1.0.18" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Blake11.AutoInterface" Version="1.0.18" />
<PackageReference Include="Blake11.AutoInterface" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Blake11.AutoInterface --version 1.0.18
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Blake11.AutoInterface, 1.0.18"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Blake11.AutoInterface@1.0.18
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Blake11.AutoInterface&version=1.0.18
#tool nuget:?package=Blake11.AutoInterface&version=1.0.18
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
AutoInterface
Yet another source generator that creates interfaces for implementations and auto-implements the said interface.
How it works
Define a partial class with some public methods
public class MyService
{
public void HelloWorld()
}
Add [AutoInterface] attribute and make it partial
[AutoInterface]
public partial class MyService
{
public void HelloWorld()
}
Now you can use the interface
IMyService service = new MyService();
How it works
Scanning
Source generator will scan the project for partial classes with [AutoInterfaceAttribute]
Found classes will be analyzed for public methods, generic arguments and generic argument constrains
Generation
For matching types there will be generated 2 components:
- An interface with the classes name
- A partial class implementing your interface
Supports:
- public methods
- methods with parameter modifiers
- generic class arguments
- generic class type constrains
- generic method arguments
- generic method type constraints
Not supported yet:
- docs
- explicit interface name, namespace
- nullable parameters
- probably a bunch more
FAQ:
1. Should I use AutoInterface?
A: Probably not but in some cases it would help.
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.Common (>= 4.12.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.12.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.12.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.