Skip to content

budgetdevv/NoParamlessCtor

Repository files navigation

NoParamlessCtor

Source generator for blocking use of parameterless constructors! E.x. new SomeStruct() will result in a compile error.

image

Installation

https://www.nuget.org/packages/NoParamlessCtor

How to use

Declare a partial struct with the [NoParamlessCtor] attribute

Example:

[NoParamlessCtor]
public ref partial struct RefCtor(ref PrimaryCtor value)
{
    public ref PrimaryCtor Value = ref value;
}

Usecases

  • Structs that will have an invalid state if new()-ed. Note that it is still possible for the end-user to declare default(SomeStruct).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages