FluentSharp 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package FluentSharp --version 1.0.0
NuGet\Install-Package FluentSharp -Version 1.0.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="FluentSharp" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FluentSharp --version 1.0.0
#r "nuget: FluentSharp, 1.0.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.
// Install FluentSharp as a Cake Addin
#addin nuget:?package=FluentSharp&version=1.0.0

// Install FluentSharp as a Cake Tool
#tool nuget:?package=FluentSharp&version=1.0.0

FluentSharp for .Net Standard 2.0

FluentSharp is a simple set of extension methods that will helps you creating code in a fluent style way. Minimizing the amount of code lines written for common behaviors.

FluentSharp has the intention of remain small, not trying to solve every possible need or re invent already existing functionality and extensions. It will keep it simple!

Conditionals

It is common in coding to use conditions to derive the code execution. Most of these implementations are usually to validate input function parameters or executing one line after the condition is evaluated.

if (myVariable == 10) {
    DoSomething();
}

The previous is a common scenario in which, after a validation, a function (Or another line of code) is executed. Even though is easy to read, a fluent writing (And reading) could help describing our code better.

(myVariable == 10)
    .IfTrue()
    .Then(() => DoSomething());

IfTrue function

Validates if the result of the boolean expression is true and returns a concrete Operations object.

The following operations will have effect only if IfTrue evaluates as true.

true.IfTrue()...;

From an expression

object obj = null;

(obj == null).IfTrue()...;

For any other boolean expression

(10 < 20).IfTrue()...;

IfFalse function

Validates if the result of the boolean expression is false and returns a concrete Operations object.

The following operations will have effect only if IfFalse evaluates as false.

false.IfFalse()...;

From an expression

object obj = null;

(obj != null).IfFalse()...;

For any other boolean expression

(10 > 20).IfFalse()...;

IfNull function

Validates if the object is null and returns a concrete Operations object.

The following operations will have effect only if IfNull evaluates as true.

null.IfNull()...;

From an expression

object obj = null;

obj.IfNull()...;

Exceptions

Propagating malformed data across our code usually requires validations to be propagated too. In particular, input function parameters that are required by the subsequent code, can be reason enough to stop the code execution and fails with a controlled exception.

Throw function

Throw will throw the defined instance exception if IfNull(), IfFalse() or IfTrue() validates as expected.

[true|false|null].[IfFalse|IfTrue|IfNull].Throw(new Exception());

From an expression

public void ValidateUser(User user) 
{
    user.IfNull().Throw(new ArgumentNullException("User cannot be null"));
}

For any other boolean expression

(10 > 20).IfFalse().Throw(new Exception());

Iterators

Operations

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.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
1.0.6 390 6/16/2021
1.0.5 295 5/20/2021
1.0.4 394 8/20/2020
1.0.3 442 8/15/2020
1.0.2 485 8/5/2020
1.0.1 382 8/4/2020
1.0.0 429 7/28/2020