Myce.Response 1.0.5

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

Myce.Response

A lightweight and robust .NET library implementing the Result Pattern to standardize API responses, handle business logic flow, and manage complex messaging with frontend-driven internationalization support.

Supports net6.0, net7.0, net8.0, net9.0, and netstandard2.0.

Features

  • Unified Result Envelope: Standardized Result and Result<T> classes for consistent API contracts.

  • Rich Messaging System: Support for multiple message types (Information, Warning, Error).

  • Dynamic Variable Interpolation: Messages support placeholders (using {} or []) for runtime data injection.

  • Frontend-Ready i18n: Messages carry unique codes and variable dictionaries, allowing the frontend to handle translations.

  • Lean Payloads: Internal logic properties are marked with [JsonIgnore] to keep JSON responses small and efficient.

  • Smart Fallback: The Title property automatically defaults to the text of the first message if not explicitly set.


Installation

dotnet add package Myce.Response

Usage

  1. Basic Result

Use the Result class for operations that report status without returning a data payload.

public Result UpdateSystemSetting(string key, string value)
{
  if (string.IsNullOrEmpty(key))
   return Result.Failure(new ErrorMessage("KEY_REQUIRED", "Setting key is mandatory"));
 
  // Business logic execution...
  return Result.Success("Setting updated successfully");
}
  1. Returning Data with Result<T>

Use Result<T> to wrap the return value of your services.

public Result<User> GetUser(int id)
{
    var user = _repository.Find(id);
    
    if (user == null)
        return Result<User>.Failure(new ErrorMessage("USER_NOT_FOUND", "The requested user does not exist"));

    return Result<User>.Success(user);
}
  1. Messaging with Variables (i18n Support)

Placeholders in messages allow the frontend to perform translation using a dictionary while maintaining dynamic context.

var message = new ErrorMessage("INSUFFICIENT_FUNDS", "You need at least {Required} to complete this, but you have {Current}");
message.AddVariable("Required", "50.00");
message.AddVariable("Current", "10.50");

return Result.Failure(message);

Architecture

The Result Object

  • Title: (string) A high-level summary. If null, it returns Messages.FirstOrDefault()?.Text.
  • IsValid: (bool) Returns true only if no ErrorMessage is present.
  • Messages: (IReadOnlyCollection) A list of Information, Warning, or Error objects.
  • Data: (T) The generic payload (specific to Result<T>).

Message Types

  1. InformationMessage: Used for non-critical status updates.
  2. WarningMessage: Used for alerts that do not block the operation.
  3. ErrorMessage: Critical failures. Presence of this type makes IsValid return false.

Frontend Integration (Internationalization)

This library follows a Client-Side Translation strategy. The backend provides the structural data, and the frontend applies the locale based on the Code. | Property | Purpose |Example| |---|---|---| |Code|Unique translation key|"VALIDATION_ERROR"| | Text | Default fallback (English) |"Invalid input"| |Variables|Key-value pairs for interpolation|[{"Name": "Field", "Value": "Email"}]|

Best Practices

  1. Explicit Titles: Set the Title property when you want a specific summary for the UI that differs from individual error messages.
  2. ToResult Mapping: Use .ToResult<V>(map) to convert between types (e.g., Entity to DTO) while preserving all messages and state.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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 is compatible.  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 was computed.  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 (2)

Showing the top 2 NuGet packages that depend on Myce.Response:

Package Downloads
Myce.FluentValidator

MYCE (Makes Your Coding Easier) FluentValidator is fluent validation class

Myce.Validation

MYCE (Makes Your Coding Easier) Validation is fluent validation class

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 0 3/12/2026
1.0.4 113 3/7/2026
1.0.3 297 2/23/2026
1.0.1 138 2/12/2026
1.0.0 102 2/7/2026
0.1.2 440 3/29/2023
0.1.1 455 1/21/2023
0.1.0 356 1/21/2023