Maestria.Extensions 4.0.2

dotnet add package Maestria.Extensions --version 4.0.2
                    
NuGet\Install-Package Maestria.Extensions -Version 4.0.2
                    
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="Maestria.Extensions" Version="4.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Maestria.Extensions" Version="4.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Maestria.Extensions" />
                    
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 Maestria.Extensions --version 4.0.2
                    
#r "nuget: Maestria.Extensions, 4.0.2"
                    
#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 Maestria.Extensions@4.0.2
                    
#: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=Maestria.Extensions&version=4.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Maestria.Extensions&version=4.0.2
                    
Install as a Cake Tool

Maestria.Extensions

NuGet Version NuGet Downloads Apimundo



buy-me-a-coffee smile.png

If my contributions helped you, please help me buy a coffee 😄

donate


What is Maestria.Extensions?

Extension function pack to increase productivity and improve source code writing. By default, all extension methods are safe.


What is Maestria Project?

This library is part of Maestria Project.

Maestria is a project to provide productivity and elegance to your source code writing.


Where can I get it?

Install the Maestria.Extensions using the command line:

dotnet add package Maestria.Extensions

How do I get started?

First, import "Maestria.Extensions" reference:

using Maestria.Extensions;

Then in your application code, use fluent syntax:

// 1. Numeric rounding
using Maestria.Extensions;
decimal value = 3.14159m;
var rounded = value.Round(2); // 3.14
// Detailed: [Number extensions](docs/usage/number.md)

// 2. Range check
int score = 85;
bool isGradeB = score.Between(80, 89); // true
// Detailed: [Comparable extensions](docs/usage/comparable.md)

// 3. Enum display name
DayOfWeek day = DayOfWeek.Monday;
string name = day.GetDisplayName(); // "Monday"
// Detailed: [Enum extensions](docs/usage/enum.md)

// 4. Collection has items
var list = new[] { 1, 2, 3 };
bool has = list.HasItems(); // true
// Detailed: [Enumerable extensions](docs/usage/enumerable.md)

// 5. String trimming
string path = "/folder/";
var trimmed = path.TrimEnd("/"); // "/folder"
// Detailed: [String extensions](docs/usage/string.md)

// 6. XML escaping
string xml = "<tag>\"Value\" & More</tag>";
var escaped = xml.EscapeXml(); // "&lt;tag&gt;&quot;Value&quot; &amp; More&lt;/tag&gt;"
// Detailed: [String extensions](docs/usage/string.md)

// 7. Base64 encoding
string text = "hello";
var b64 = text.ToBase64(); // "aGVsbG8="
// Detailed: [String extensions](docs/usage/string.md)

// 8. Guid handling
Guid guid = Guid.Empty;
var newGuid = guid.IfEmpty().Then(Guid.NewGuid());
// Detailed: [Other extensions](docs/usage/other.md)

// 9. Pipeline example
var result = "12345"
    .OnlyNumbers()
    .Format("{0:###-##}"); // "123-45"
// Detailed: [String extensions](docs/usage/string.md)

Data Types

The library ships with two expressive result types that eliminate boilerplate error handling:

Result and Result<TValue>

// Result — implicit conversions keep method signatures clean
public Result Save(Order order)
{
    if (order == null) return "Order cannot be null"; // implicit failure
    // ...
    return true; // implicit success
}

var result = Save(order);
if (result) Console.WriteLine("Saved!");
else        Console.WriteLine(result.Message);

Try<TSuccess, TFailure>

// Try<TSuccess, TFailure> — distinct types for success and failure
public Try<OrderCreated, ValidationError> Submit(Order order) { ... }

var r = Submit(order);
if (r) Console.WriteLine($"Order ID: {r.Value.Id}");
else   Console.WriteLine($"Error {r.Failure.Code}: {r.Failure.Message}");

See docs/usage/datatypes.md for full documentation, implicit conversion rules, Result<T>, and advanced usage.


Settings

It's possible set default settings for library:

MaestriaExtensionsSettings.Configure(config => config
    .FloatingPointTolerance(<default-float-and-double-comparasion-tolerance>) // Default is 0.00001f
    .DefaultEncoding(<encoding>) // Default if Encoding.UTF8

Full usage documentations

There are many more extension methods available. See the full documentation:

Topic Samples methods
Comparable & fluent expressions Between, In, LimitToMin, LimitToMax, fluent If...Then, NullIf
Data types Result, Try<TSuccess, TFailure>
Enum extensions GetDisplayName, GetDescription, GetValues
Enumerable & collection extensions HasItems, IsNullOrEmpty, Iterate, TryGetValue, WithIndex
Number extensions Round, RoundUp, Truncate for numeric types
Other extensions OutVar and pipeline helpers
String extensions Trimming, substring, hashing, Base64, encoding, and more

Extra documentations

See additional documentations at docs folder.


buy-me-a-coffee smile.png

If my contributions helped you, please help me buy a coffee 😄

donate

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  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 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 is compatible.  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. 
.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.

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
4.0.2 86 7/21/2026
4.0.1 94 7/20/2026
4.0.0 94 7/20/2026
3.9.1 87 7/18/2026
3.9.0 93 7/17/2026
3.8.13 124 7/1/2026
3.8.12 91 7/1/2026
3.8.11 90 7/1/2026
3.8.10 96 7/1/2026
3.8.9 105 6/30/2026
3.8.8 120 6/27/2026
3.8.7 116 6/23/2026
3.8.6 116 6/23/2026
3.8.5 114 6/23/2026
3.8.4 103 6/23/2026
3.8.3 116 6/23/2026
3.8.2 105 6/23/2026
3.8.1 108 6/23/2026
3.8.0 211 4/24/2026
3.7.2 701 11/12/2025
Loading failed