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);using RecurPixel.EasyMessages;
using RecurPixel.EasyMessages.AspNetCore;
// Program.cs
builder.Services.AddEasyMessages();
// Controller
[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
{
[HttpPost]
public IActionResult Create(CreateUserDto dto)
{
var user = _userService.Create(dto);
return Msg.Crud.Created("User")
.WithData(user)
.ToApiResponse();
}
[HttpGet("{id}")]
public IActionResult GetById(int id)
{
var user = _userService.GetById(id);
if (user == null)
return Msg.Crud.NotFound("User").ToApiResponse();
return Msg.Crud.Retrieved("User")
.WithData(user)
.ToApiResponse();
}
}- β 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
- β
ASP.NET Core Integration -
.ToApiResponse(), logging, DI - β IOptions Pattern - Full configuration support with presets
- β Extensible - Custom messages, formatters, interceptors
- β High Performance - Optimized for .NET 5-10, minimal overhead
| Package | Version | Description | Use For |
|---|---|---|---|
| RecurPixel.EasyMessages | Core library | Console apps, background jobs, class libraries | |
| RecurPixel.EasyMessages.AspNetCore | ASP.NET Core extensions | Web APIs, minimal APIs |
# For console apps, background jobs, class libraries
dotnet add package RecurPixel.EasyMessages --version 0.1.0-beta.*
# For ASP.NET Core web applications
dotnet add package RecurPixel.EasyMessages.AspNetCore --version 0.1.0-beta.*- π 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))
return Msg.Auth.LoginFailed().Log(_logger).ToApiResponse();
var token = _authService.GenerateToken(dto);
return Msg.Auth.LoginSuccessful()
.WithData(new { token })
.Log(_logger)
.ToApiResponse();
}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 (Current)
- v0.2.0-beta - ASP.NET Core package complete
- v1.0.0 - Production-ready, 200+ messages
- v1.x - Additional integrations (Serilog, FluentValidation, etc.)
This is a beta release (v0.1.0-beta.1). APIs are stable and feature-complete. Ready for testing and feedback!
What's Working:
- β Core message system
- β 100+ built-in messages
- β JSON, XML, Console, PlainText formatters
- β Parameter substitution
- β Custom messages, formatters, interceptors
- β ASP.NET Core integration (basic)
What's Coming in Beta:
- π Complete ASP.NET Core package
- π IOptions configuration (β Done!)
- π Enhanced logging integration
- π 150+ messages
- π Comprehensive documentation (β In progress!)
π’ 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 0.1.0-beta.*Your feedback will shape the future of EasyMessages! π