Skip to content

martinrhan/SingletonSourceGenerator

Repository files navigation

SingletonSourceGenerator

This source generator helps you to automatically implement a singleton pattern. To use this, simply add [Singleton] attribute to your partial class.

using SingletonSourceGenerator.Attributes;

namespace MyNamespace;

[Singleton]
public partial class MyClass{
}

This will generate

namespace MyNamespace;

partial class MyClass{
	private static MyClass? instance;
	public static MyClass Instance => instance ??= new();
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages