KutCode.Optional.Core 0.0.3

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package KutCode.Optional.Core --version 0.0.3
NuGet\Install-Package KutCode.Optional.Core -Version 0.0.3
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="KutCode.Optional.Core" Version="0.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add KutCode.Optional.Core --version 0.0.3
#r "nuget: KutCode.Optional.Core, 0.0.3"
#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.
// Install KutCode.Optional.Core as a Cake Addin
#addin nuget:?package=KutCode.Optional.Core&version=0.0.3

// Install KutCode.Optional.Core as a Cake Tool
#tool nuget:?package=KutCode.Optional.Core&version=0.0.3

.NET library that allows you to easily handle null values in C#.

⚙ī¸ Features

  • Handle nullable value and reference types
  • Easy "from value" creation or static .None stub
  • Built-in Json support System.Text.Json as Serialization and Deserialization

📜 Install

KutCode.Optional is designed to work with net7.0 and higher.

Install KutCode.Optional using NuGet Package Manager:

Install-Package KutCode.Optional.Core

Or via the .NET CLI:

dotnet add package KutCode.Optional.Core

All versions can be found here.

⌨ī¸ Basic usage

  • Wrap all types for easy nullabillity checks
public Optional<Person> GetPerson()
{
    Person? person = _context.GetPerson();
    return Optional.From<Person>(person);
}

public static void Main()
{
    var person = GetPerson();
    if (person.HasValue) Console.WriteLine(person.Name);
    else Console.WriteLine("Person is not presented");
}
  • Stop use null return - prevent NullReferenceException
public Optional<Person> GetAnyPerson()
{
    try {
        // anything wrong...
    }
    catch {
        return Optional<Person>.None; // .HasValue will return false
    }
}
  • Cast Optional type to TValue implicitly if you need
public void Main()
{
    Optional<Person> person = Optional.From(new Person());
    HandlePerson(person); // implicit casting
}

public void HandlePerson(Person person)
{
    // some actions
}

đŸ“Ļ JSON

KutCode.Optional allows you to use Optional<T> in JSON-models.

ℹī¸ Additional info

🗨ī¸ Telegram

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.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