Tired of writing the same error messages over and over? EasyMessages gives you 100+ pre-built, standardized messages with a fluent API that just works.
// β Inconsistent, scattered, hard to maintain
return BadRequest(new { message = "Invalid credentials" });
return Unauthorized(new { error = "Not authorized" });
return NotFound("User not found");// β
Standardized, fluent, discoverable, consistent
Msg.Auth.LoginFailed().ToJson();
Msg.Auth.Unauthorized().ToApiResponse();
Msg.Crud.NotFound("User").ToApiResponse();using RecurPixel.EasyMessages;
// Works immediately - no setup needed!
Msg.Auth.LoginFailed().ToConsole(useColors: true);
var json = Msg.Crud.Created("User").ToJson();
Console.WriteLine(json);// No setup needed β just install RecurPixel.EasyMessages
[HttpPost("login")]
public IActionResult Login(LoginDto dto)
{
if (!_authService.ValidateCredentials(dto))
{
var msg = Msg.Auth.LoginFailed();
return StatusCode(msg.HttpStatusCode ?? 401, msg.ToJsonObject());
}
var success = Msg.Auth.LoginSuccessful()
.WithData(new { token = _authService.GenerateToken(dto) });
return StatusCode(success.HttpStatusCode ?? 200, success.ToJsonObject());
}- β 100+ Pre-built Messages - Authentication, CRUD, Validation, System errors
- β Type-Safe - IntelliSense-driven API, compile-time safety
- β Multiple Formats - JSON, XML, Console, Plain Text
- β Zero Configuration - Works immediately out of the box
- β Fluent API - Chainable methods for clean, readable code
- β
ILogger Integration -
.Log(logger)chains into anyILogger - β Extensible - Custom messages, formatters, interceptors
- β High Performance - Optimized for .NET 5-10, minimal overhead
| Package | Version | Description |
|---|---|---|
| RecurPixel.EasyMessages | Works in console apps, background jobs, web APIs, and class libraries |
dotnet add package RecurPixel.EasyMessages --version 1.0.0- π Getting Started in 5 Minutes
- π Core Concepts
- π ASP.NET Core Integration
- π Configuration Guide
- π‘ Examples
- π API Reference
// Manual, inconsistent, scattered across codebase
public IActionResult Login(LoginDto dto)
{
if (!_authService.ValidateCredentials(dto))
{
_logger.LogWarning("Login failed for user {Email}", dto.Email);
return Unauthorized(new
{
success = false,
message = "Invalid credentials",
timestamp = DateTime.UtcNow
});
}
var token = _authService.GenerateToken(dto);
_logger.LogInformation("User {Email} logged in", dto.Email);
return Ok(new
{
success = true,
message = "Login successful",
data = new { token },
timestamp = DateTime.UtcNow
});
}// Clean, consistent, discoverable
public IActionResult Login(LoginDto dto)
{
if (!_authService.ValidateCredentials(dto))
{
var msg = Msg.Auth.LoginFailed().Log(_logger);
return StatusCode(msg.HttpStatusCode ?? 401, msg.ToJsonObject());
}
var success = Msg.Auth.LoginSuccessful()
.WithData(new { token = _authService.GenerateToken(dto) })
.Log(_logger);
return StatusCode(success.HttpStatusCode ?? 200, success.ToJsonObject());
}EasyMessages is optimized for .NET 5-10 with minimal overhead:
| Operation | .NET 8.0 | .NET 10.0 | Memory |
|---|---|---|---|
| Baseline: Convert to API response | 111.0 ns | 106.0 ns (4.5% faster) | 256 B |
| Simple message with parameters | 1,630 ns | 1,592 ns (2.4% faster) | 560 B |
| Add single metadata | 176.9 ns | 169.4 ns (4.2% faster) | 320 B |
| Chained operations | 2,170 ns | 2,120 ns (2.3% faster) | 1.5 KB |
Key Findings:
- β Ultra-fast conversions: ~106ns for API response (9.4M ops/sec on .NET 10)
- β .NET 10 is 2-4.5% faster across all operations
- β Low memory overhead: 256B-1.5KB per operation
- β Predictable performance with low standard deviation
β
Registry lookups: 10,000 operations in ~10-20ms (100-200ns each)
β
JSON formatting: 1,000 operations in ~3ms (3ΞΌs each)
β
API conversion: 1,000,000 operations in ~119ms (119ns each)
- Span<T> and Memory<T> for zero-allocation string operations
- ArrayPool<T> for temporary buffers
- ValueStringBuilder for efficient string concatenation
- Lazy initialization patterns
- Object pooling for frequently used instances
π Detailed Benchmarks & Performance Analysis
Works immediately without setup. Configuration is optional, not required.
Exceptions are descriptive with helpful context for quick debugging.
Thread-safe operations with predictable, reliable behavior.
Easy to add custom messages, formatters, interceptors, and stores.
| Category | Prefix | Count | Examples |
|---|---|---|---|
| Authentication | AUTH_* |
10 | Login failed, Unauthorized, Token expired |
| CRUD Operations | CRUD_* |
15 | Created, Updated, Deleted, Not found |
| Validation | VAL_* |
12 | Required field, Invalid format, Out of range |
| System | SYS_* |
8 | Error, Processing, Maintenance |
| Database | DB_* |
5 | Connection failed, Query timeout |
| Files | FILE_* |
10 | Uploaded, Invalid type, Size exceeded |
| Network | NET_* |
8 | Timeout, Service unavailable |
| Custom | * |
β | Your own messages |
Total: 100+ built-in messages
// ASP.NET Core - appsettings.json
{
"EasyMessages": {
"Logging": {
"AutoLog": true,
"MinimumLogLevel": "Warning"
},
"Storage": {
"CustomMessagesPath": "messages/custom.json"
},
"Localization": {
"DefaultLocale": "en-US",
"EnableLocalization": true
}
}
}
// Program.cs - Use configuration presets
builder.Services.AddEasyMessages(builder.Configuration, options =>
{
// Or configure manually
options.Logging.AutoLog = true;
options.Storage.CustomMessagesPath = "custom.json";
});
// Or use presets for common scenarios
builder.Services.AddEasyMessages(
builder.Configuration,
EasyMessagesPresets.Production // or Development, Testing, Staging, Api
);π Complete Configuration Guide
- v0.1.0-beta - Core functionality, 100+ messages
- v1.0.0 - Production-ready, stable API, ILogger integration (Current)
- v1.x - Additional integrations (Serilog, FluentValidation, etc.)
APIs are stable and under semantic versioning. Ready for production use.
What's included:
- β 100+ built-in messages across 10 categories
- β JSON, XML, Console, PlainText formatters
- β
ILogger integration (
.Log(logger)) - β Parameter substitution, custom messages, interceptors
- β Tested on .NET 8, 9, 10
π’ Report Issues | Give Feedback
We welcome contributions! Please see our Contributing Guide for details.
- π Report Bugs
- π‘ Request Features
- π Improve Documentation
EasyMessages is licensed under the MIT License.
Built with β€οΈ by RecurPixel
Special thanks to:
- Early beta testers
- The .NET community
- Everyone who provides feedback
If you find EasyMessages useful:
- β Star the repository
- π Report bugs
- π‘ Suggest features
- π’ Share with others
# Get started now!
dotnet add package RecurPixel.EasyMessages --version 1.0.0Your feedback will shape the future of EasyMessages! π