Automates the plumbing around System.Lazy.


Keywords
AOP, Cecil, Fody, ILWeaving
License
MIT
Install
Install-Package Lazy.Fody -Version 1.11.0

Documentation

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