Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 574 Bytes

Readme.md

File metadata and controls

32 lines (25 loc) · 574 Bytes

Empty constructor generator

A simple C# source generator that generates an empty constructor for a class if it is marked with the EmptyConstructor.EmptyConstructorAttribute attribute.

using EmptyConstructor;

[EmptyConstructor]
public partial class ClassName()
{
    private string _name { get; set;}
    public ClassName(string name)
    {
        this._name = name;
    }
}

Generates

using EmptyConstructor;

partial class ClassName()
{
    public ClassName()
    {
    }
}

It does nothing if the class already has an empty constructor.