Soenneker.Utils.LazyBools
4.0.30
Prefix Reserved
dotnet add package Soenneker.Utils.LazyBools --version 4.0.30
NuGet\Install-Package Soenneker.Utils.LazyBools -Version 4.0.30
<PackageReference Include="Soenneker.Utils.LazyBools" Version="4.0.30" />
<PackageVersion Include="Soenneker.Utils.LazyBools" Version="4.0.30" />
<PackageReference Include="Soenneker.Utils.LazyBools" />
paket add Soenneker.Utils.LazyBools --version 4.0.30
#r "nuget: Soenneker.Utils.LazyBools, 4.0.30"
#:package Soenneker.Utils.LazyBools@4.0.30
#addin nuget:?package=Soenneker.Utils.LazyBools&version=4.0.30
#tool nuget:?package=Soenneker.Utils.LazyBools&version=4.0.30
Soenneker.Utils.LazyBools
A tiny, allocation-free, publication-only lazy initializer for bools.
Installation
dotnet add package Soenneker.Utils.LazyBools
Quick start
using Soenneker.Utils.LazyBools;
public sealed class Feature
{
private int _isAvailableState;
public bool IsAvailable => LazyBoolUtil.GetOrInit(
ref _isAvailableState,
threadSafe: true,
this,
static feature => feature.CheckAvailability());
private bool CheckAvailability() => /* expensive check */ true;
}
Call the static LazyBoolUtil methods directly; no dependency-injection registration is required.
Semantics
GetOrInit stores its state in the caller-provided int: 0 is uninitialized, 1 is false, and
2 is true. Initialize the field to zero and do not use or mutate it for anything else.
With threadSafe: true, initialization is publication-only. Concurrent callers can run compute
more than once, but one result is published and returned to every caller. Use a side-effect-free
or otherwise concurrency-safe delegate. If the delegate throws before a value is published, the
state remains uninitialized and a later call can retry.
Use threadSafe: false only when calls are single-threaded or protected by external
synchronization. That path avoids the interlocked publication operation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Utils.LazyBools:
| Package | Downloads |
|---|---|
|
Soenneker.Reflection.Cache
The fastest .NET Reflection cache |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.30 | 17,932 | 10/15/2026 |
| 4.0.29 | 4,398 | 10/14/2026 |
| 4.0.24 | 10,032 | 10/13/2026 |
| 4.0.23 | 84 | 10/12/2026 |
| 4.0.22 | 5,390 | 10/11/2026 |
| 4.0.21 | 127,840 | 9/24/2026 |
| 4.0.20 | 37,994 | 9/15/2026 |
| 4.0.19 | 43,337 | 9/12/2026 |
| 4.0.18 | 138,548 | 8/30/2026 |
| 4.0.17 | 6,765 | 8/29/2026 |
| 4.0.16 | 123 | 8/29/2026 |
| 4.0.15 | 196,014 | 7/28/2026 |
| 4.0.14 | 99,071 | 7/16/2026 |
| 4.0.13 | 137,582 | 6/19/2026 |
| 4.0.12 | 119,397 | 6/5/2026 |
| 4.0.11 | 206,189 | 4/23/2026 |
| 4.0.10 | 120,844 | 3/14/2026 |
| 4.0.5 | 47,121 | 3/10/2026 |
| 4.0.4 | 22,744 | 3/9/2026 |
| 4.0.3 | 238 | 3/9/2026 |
Update .NET SDK from 10.0.401 to 10.0.402