Requisite.CSharp 0.1.0

dotnet add package Requisite.CSharp --version 0.1.0
                    
NuGet\Install-Package Requisite.CSharp -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Requisite.CSharp" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Requisite.CSharp" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Requisite.CSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Requisite.CSharp --version 0.1.0
                    
#r "nuget: Requisite.CSharp, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Requisite.CSharp@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Requisite.CSharp&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Requisite.CSharp&version=0.1.0
                    
Install as a Cake Tool

Requisite for .NET

Requisite is a compact library for carrying data-handling requirements in C# types:

  • Untrusted<T> reaches Trusted<T> only through an explicit policy.
  • Probability, ConfidenceThresholds, and Confident<T> validate confidence data before an exhaustive three-way gate.
  • the highest confidence handler receives an opaque Certain capability with no public construction or inheritance path.
  • Fresh<T> checks each value's TTL on every read and preserves stale metadata and the expired value for recovery.

The runtime library targets .NET 8 and .NET 10, uses C# 14 with nullable annotations, and has no runtime dependencies.

Install

dotnet add package Requisite.CSharp --version 0.1.0

Example

using Requisite;

static bool TryId(string text, out int id) => int.TryParse(text, out id);
static void Approve(Certain _, Trusted<int> id) { /* sensitive action */ }

var raw = Untrusted.From(request.CustomerId);
if (!Trust.TrySanitize(raw, TryId, out Trusted<int>? customerId))
    return Results.BadRequest();

var quote = Fresh.Fetch(4.99m, TimeSpan.FromSeconds(30));
quote.Read().Switch(
    current => Charge(customerId, current),
    stale => Refresh(stale.Value, stale.Metadata));

Confident.Create(model.Approves, model.Confidence).Gate().Switch(
    (proof, approved) => { if (approved) Approve(proof, customerId); },
    _ => QueueReview(customerId),
    _ => RecordOnly(customerId));

Gate<T>.Match and Gate<T>.Switch require handlers for high, likely, and unsure outcomes. Custom thresholds may raise the certain boundary but cannot lower it below 0.95.

Sanitization outputs are constrained to notnull; a policy that violates that contract at runtime is rejected rather than producing Trusted<T> containing null.

var thresholds = ConfidenceThresholds.Create(likely: 0.75, certain: 0.99);
string action = forecast.Gate(thresholds).Match(
    (proof, value) => Execute(proof, value),
    value => Review(value),
    value => Record(value));

For deterministic freshness tests, pass a TimeProvider. Custom providers must keep GetTimestamp() monotonic; wall-clock time is used only to establish the initial age in FetchedAt. A stale read exposes StaleValue<T>.Value and Metadata.

Must-use diagnostics

The package includes a focused analyzer. RQ0001 warns when Gate() or Read() is used as a bare expression statement, because that silently skips confidence or freshness handling.

forecast.Gate(); // RQ0001
quote.Read();    // RQ0001

Handling the result removes the warning. Assigning to _ is the explicit opt-out when discarding is intentional. The analyzer does not attempt to make all C# return values must-use, which would create noise.

Scope

Requisite complements rather than replaces Vogen and LanguageExt. Use Vogen for rich domain primitives and LanguageExt for general result/effect composition; Requisite focuses on transitions and capabilities required by receiving APIs.

The Rust library's Live/with_live API is intentionally omitted. C# cannot enforce the same compile-time non-escape guarantee, so a similar-looking API would overstate what the type system proves.

Build

The repository uses .NET 10. global.json accepts newer .NET 10 feature bands but does not roll into a later major version.

dotnet restore Requisite.slnx --locked-mode
dotnet format Requisite.slnx --verify-no-changes --no-restore
dotnet build Requisite.slnx --configuration Release --no-restore
dotnet test tests/Requisite.Tests/Requisite.Tests.csproj -c Release -f net8.0 --no-build
dotnet test tests/Requisite.Tests/Requisite.Tests.csproj -c Release -f net10.0 --no-build
dotnet pack src/Requisite/Requisite.csproj -c Release --no-build --no-restore

Tests include runtime coverage, analyzer coverage, Roslyn positive controls, and compile-negative contracts for trusted sinks, capabilities, validated construction, freshness metadata, closed gates, and confidence use.

See MAINTAINING.md for package and release checks.

License

Licensed under either Apache-2.0 or MIT, at your option.

Product 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 107 8/4/2026