RZ.Foundation
7.0.0-beta.3
See the version list below for details.
dotnet add package RZ.Foundation --version 7.0.0-beta.3
NuGet\Install-Package RZ.Foundation -Version 7.0.0-beta.3
<PackageReference Include="RZ.Foundation" Version="7.0.0-beta.3" />
<PackageVersion Include="RZ.Foundation" Version="7.0.0-beta.3" />
<PackageReference Include="RZ.Foundation" />
paket add RZ.Foundation --version 7.0.0-beta.3
#r "nuget: RZ.Foundation, 7.0.0-beta.3"
#:package RZ.Foundation@7.0.0-beta.3
#addin nuget:?package=RZ.Foundation&version=7.0.0-beta.3&prerelease
#tool nuget:?package=RZ.Foundation&version=7.0.0-beta.3&prerelease
RZ Functional library for C#
This library is an add-on to LanguageExt library. It tries to provide some syntactic sugar for more natural expression.
Option[T] Extension (RZ.Foundation)
Convert between C# nullable value and Option[T]
Prelude module provides conversion functions for C# nullable and Option[T]. Unfortunately, Value Type/Ref Type semantic differences make creating generic functions to support both meta-types tedious and, in some case, confuse the compiler and generating a warning.
using static LanguageExt.Prelude;
int? x = 123;
Option<T> y = Some(x); // convert a nullable value to Option<T>
int? z = y.ToNullable(); // convert an Option<T> to a nullable value
// this should also work with nullable ref value
string? a = "Hello";
Option<string> b = Some(a);
string? c = b.ToNullable();
Getting a value out of Option[T]
Suppose that we have follow option values:
using static LanguageExt.Prelude;
var some = Some(123);
var none = Option<int>.None;
Get
var x = some.Get(); // 123
var y = none.Get(); // an exception is thrown!
GetOrThrow
In case you want to specific an exception.
var x = some.GetOrThrow(() => new MyException()); // 123
var y = none.GetOrThrow(() => new MyException()); // MyException is thrown!
GetOrDefault
var x = some.GetOrDefault(); // 123
var y = none.GetOrDefault(); // 0, int's default value
Replace None value
using static LanguageExt.Prelude;
var x = Option<int>.None;
var y = x.OrElse(123); // Option<int> of 123
var z = x.OrElse(Some(456)) // Option<int> of 456
var a = x.OrElse(() => None); // stay None
var b = await x.OrElseAsync(() => Task.FromResult(999)); // Option<int> of 999
Perform action (Side effect)
Then is the operation to perform an action. The method returns the original value.
using static LanguageExt.Prelude;
var x = None<int>();
x.Then(v => Console.WriteLine("Value = {0}", v));
x.Then(v => Console.WriteLine("Value = {0}", v), () => Console.WriteLine("No value"));
// async versions
await x.ThenAsync(v => Task.Run(() => Console.WriteLine("V = {0}", v)));
await x.ThenAsync(v => Task.Run(() => Console.WriteLine("V = {0}", v)),
() => Task.Run(() => Console.WriteLine("No value")));
Type casting
Option<object> x = Some((object) "I am string");
Option<string> y = x.TryCast<object,string>();
Option<int> z = x.TryCast<object,int>(); // None!
TaskOption[T]
LanguageExt's OptionAsync should be a wrapper of Task<Option<T>>, but its recent async/await handler
has been implemented in way that consumes all exceptions as None value. This makes sense when we don’t
want any side-effect. But in case of exception handling, I find that by allowing exceptions as the side-effect,
would simplify error handling code when writing in functional paradigm.
So TaskOption<T> is made to work similar to OptionAsync but with async/await pattern that allows
exceptions to be escalated normally, as well as, support None returning value.
| 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 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 was computed. 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. |
-
net8.0
- LanguageExt.Core (>= 4.4.8)
NuGet packages (13)
Showing the top 5 NuGet packages that depend on RZ.Foundation:
| Package | Downloads |
|---|---|
|
RZ.Foundation.NewtonsoftJson
RZ.Foundation extension for Newtonsoft.JSON |
|
|
RZ.Foundation.Blazor
Package Description |
|
|
RZ.Linq.RelationalDatabase
Transform LINQ to SQL text |
|
|
RZ.AspNet.Bootstrapper
Package Description |
|
|
RZ.Foundation.Blazor.MudBlazor
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 8.2.15 | 117 | 4/26/2026 |
| 8.2.14 | 143 | 3/29/2026 |
| 8.2.13 | 120 | 3/28/2026 |
| 8.2.12 | 119 | 3/27/2026 |
| 8.2.11 | 133 | 3/24/2026 |
| 8.2.10 | 108 | 3/23/2026 |
| 8.2.9 | 470 | 2/7/2026 |
| 8.2.6 | 258 | 1/30/2026 |
| 8.1.0 | 209 | 1/28/2026 |
| 7.0.5 | 529 | 6/12/2025 |
| 7.0.4 | 288 | 4/24/2025 |
| 7.0.2 | 357 | 3/9/2025 |
| 7.0.0 | 280 | 2/4/2025 |
| 7.0.0-beta.26 | 121 | 10/15/2024 |
| 7.0.0-beta.12 | 118 | 9/25/2024 |
| 7.0.0-beta.11 | 130 | 9/22/2024 |
| 7.0.0-beta.3 | 143 | 6/23/2024 |
| 7.0.0-alpha.3 | 139 | 6/22/2024 |
| 6.5.0-beta.1 | 132 | 5/9/2024 |
| 6.4.0 | 639 | 4/22/2024 |
Embrace LanguageExt lib.