- What is Maestria.Extensions?
- What is Maestria Project?
- Where can I get it?
- How do I get started?
- Data Types
- Settings
- Full usage documentations
- Extra documentations
If my contributions helped you, please help me buy a coffee :D
Extension function pack to increase productivity and improve source code writing. By default, all extension methods are safe.
This library is part of Maestria Project.
Maestria is a project to provide productivity and elegance to your source code writing.
Install the Maestria.Extensions using the command line:
dotnet add package Maestria.ExtensionsFirst, 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(); // "<tag>"Value" & More</tag>"
// 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)The library ships with two expressive result types that eliminate boilerplate error handling:
// 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> — 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.
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.UTF8There 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 |
See additional documentations at docs folder.
- changelog.md: List of changes by version and breaking changes.
- ci-workflow.md: Description of the CI workflow used in the project.
- contributing.md: How to contribute to the project.
If my contributions helped you, please help me buy a coffee :D


