Tyne.Core
Core functionality for other Tyne packages.
Common types:
Result<T>(and extensions)Option<T>(and extensions)Error(and extensions)
Installation
dotnet add package Tyne.Core --version 4.0.0-rc1
Prelude
Tyne's common core types can be shortened using Tyne's prelude system, which is designed to make using common types more ergonomic.
Tyne's core prelude is enabled by default, but can be controlled with the TynePrelude property:
<PropertyGroup>
<!-- Disables the Tyne prelude -->
<TynePrelude>disable</TynePrelude>
<!-- Enables the Tyne prelude (default setting) -->
<TynePrelude>enable</TynePrelude>
</PropertyGroup>
Preludes come enabled by default. When enabled:
Unit.Valueis imported statically asunit:// Without prelude return Unit.Value; // With prelude return unit;Resultcreation methods are imported statically:// Without prelude var okResult = Result.Ok<int, string>(42); var errorResult = Result.Error<int, string>("some error"); // With prelude var okResult = Ok<int, string>(42); var errorResult = Error<int, string>("No value");Optioncreation methods are imported statically:// Without prelude var some = Option.Some(101); var none = Option.None<int>(); // With prelude var some = Some(101); var none = None<int>();