Skip to main content

MakeInterface.Generator by Frederik

NuGet / site data​

Nuget GitHub last commit GitHub Repo stars

Details​

Info​

info

Name: MakeInterface.Generator

Generates interfaces for classes

Author: Frederik

NuGet: https://www.nuget.org/packages/MakeInterface.Generator/

You can find more details at https://github.com/Frederik91/MakeInterface

Source: https://github.com/Frederik91/MakeInterface

Original Readme​

note

MakeInterface

Creates an interface of a class using source generator

.NET

Usage​

Add the attribute to the class you want to generate the interface for

[GenerateInterface]
public class MyClass
{
public string MyProperty { get; set; }
public void MyMethod() { }
}

The generated interface will then be generated as IMyClass.g.cs

public interface IMyClass
{
string MyProperty { get; set; }
void MyMethod();
}

You can then implement the interface in your class

public class MyClass : IMyClass
{
public string MyProperty { get; set; }
public void MyMethod() { }
}

Installation​

Install the NuGet package MakeInterface

You can either create the attribute yourself or use the one provided in the package MakeInterface.Contracts

License​

MIT

About​

note

Generating interface from class definition

How to use​

Example (source csproj, source files)​

This is the CSharp Project that references MakeInterface.Generator

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MakeInterface.Contracts" Version="0.4.0" />
<PackageReference Include="MakeInterface.Generator" Version="0.4.0" OutputItemType="Analyzer" >
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>

Generated Files​

Those are taken from $(BaseIntermediateOutputPath)\GX

using MakeInterface.Contracts.Attributes;

// <auto-generated/>
#pragma warning disable
#nullable enable
namespace Class2Interface;
public partial interface IPerson
{
int ID { get; set; }

string FirstName { get; set; }

string LastName { get; set; }

string Name { get; }

string FullName();
}

Useful​

Download Example (.NET C#)​

Share MakeInterface.Generator​

https://ignatandrei.github.io/RSCG_Examples/v2/docs/MakeInterface.Generator

aaa

Category "Interface" has the following generators:​

1 AutoInterface Nuget GitHub Repo stars 2025-07-25

2 Biwen.AutoClassGen Nuget GitHub Repo stars 2023-11-16

3 CopyCat Nuget GitHub Repo stars 2024-01-09

4 Farskeptic.AutoCompose Nuget GitHub Repo stars 2024-03-16

5 MakeInterface.Generator Nuget GitHub Repo stars 2024-01-19

6 Matryoshki Nuget GitHub Repo stars 2023-08-03

7 Minerals.AutoInterfaces Nuget GitHub Repo stars 2024-04-17

8 NetAutomaticInterface Nuget GitHub Repo stars 2024-01-29

9 ProxyGen Nuget GitHub Repo stars 2023-08-06

10 Roozie.AutoInterface Nuget GitHub Repo stars 2023-08-26

11 RSCG_CompositeProvider NugetNuget GitHub Repo stars 2025-02-18

12 rscg_Interface_to_null_object NugetNuget GitHub Repo stars 2025-01-18

13 RSCG_Static Nuget GitHub Repo stars 2023-04-16

14 ShadowWriterNullobjects Nuget GitHub Repo stars 2025-07-29

See category​

Interface