Skip to content

tom-englert/Lazy.Fody

Repository files navigation

Build status NuGet Status

Icon

Automates the plumbing around System.Lazy

This is an add-in for Fody; it is available via NuGet:

PM> Install-Package Lazy.Fody

Your code

class Sample
{
    [Lazy(LazyThreadSafetyMode.ExecutionAndPublication)]
    public double Value => GetValue();

    private double GetValue()
    {
        return 3.14;
    }
}

What gets compiled:

class Sample
{
    private Lazy<double> Value_lazy;

    public Sample()
    {
        Value_lazy = new Lazy<double>(GetValue, LazyThreadSafetyMode.ExecutionAndPublication);
    }

    public double Value => Value_lazy.Value;

    private double GetValue()
    {
        return 3.14;
    }
}

Icon

Sloth by Chanut is Industries from the Noun Project

About

Automates the plumbing around System.Lazy

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages