Skip to content

Source-generates implicit conversion operators that map to the respective constructors.

License

Notifications You must be signed in to change notification settings

Emik03/Emik.SourceGenerators.Implicit

Repository files navigation

Emik.SourceGenerators.Implicit

NuGet package License

Source-generates implicit conversion operators that map to the respective constructors.

This project has a dependency to Emik.Morsels, if you are building this project, refer to its README first.



Example

A singularValuesWork = 1; // Valid!
A tuplesWorkToo = (2, 3); // Valid!

// Won't generate: annotated NoImplicitOperator.
// A butThisDoesNot = (4, 5, 6);

// Won't generate: would change visibility of constructor.
// A andNeitherDoesThis = (7, 8, 9, 10); 

// Won't generate: annotated NoImplicitOperator.
// B andNeitherDoesThisToo = 11; 
// B orThis = (12, 13);

public class A(int i)
{
    public A(int i, int j)
       : this(0) { }

    [NoImplicitOperator]
    public A(int i, int j, int k)
       : this(0) { }

    private A(int i, int j, int k, int l)
       : this(0) { }
}

[NoImplicitOperator]
public class B(int i)
{
    public B(int i, int j)
       : this(0) { }
}

Contribute

Issues and pull requests are welcome to help this repository be the best it can be.

License

This repository falls under the MPL-2 license.

About

Source-generates implicit conversion operators that map to the respective constructors.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages