MikuLib.Utils
10.1.39
dotnet add package MikuLib.Utils --version 10.1.39
NuGet\Install-Package MikuLib.Utils -Version 10.1.39
<PackageReference Include="MikuLib.Utils" Version="10.1.39" />
<PackageVersion Include="MikuLib.Utils" Version="10.1.39" />
<PackageReference Include="MikuLib.Utils" />
paket add MikuLib.Utils --version 10.1.39
#r "nuget: MikuLib.Utils, 10.1.39"
#:package MikuLib.Utils@10.1.39
#addin nuget:?package=MikuLib.Utils&version=10.1.39
#tool nuget:?package=MikuLib.Utils&version=10.1.39
MikuLib.Utils
A comprehensive utility library for .NET 10 containing essential tools for object mapping, command line argument parsing, and more.
"The world is mine... to code!" - Hatsune Nemas
Powered by CV01 energy since 2007
Features
MikuMapper - Object Mapping
- Property mapping between objects with automatic type conversion
- Support for nullable primitives (e.g.,
int ↔ int?,bool ↔ bool?) - Property exclusion during mapping
- Collection mapping support
- High-performance reflection-based mapping
CommandLineHelper - Argument Parsing
- Modern, LINQ-based command line argument parsing
- Automatic detection via
Environment.GetCommandLineArgs() - Support for multiple parameter formats:
--param value,--param:value,--param=value - Multi-value parameter support
- Environment variable integration
- Case-insensitive by default
Installation
dotnet add package MikuLib.Utils
Or add to your .csproj:
<PackageReference Include="MikuLib.Utils" Version="10.1.39" />
Quick Start
MikuMapper
using Miku.Utils;
// Map object properties
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public bool? IsActive { get; set; }
}
public class UserDto
{
public int Id { get; set; }
public string Name { get; set; }
public bool IsActive { get; set; }
}
var user = new User { Id = 1, Name = "Miku", IsActive = true };
// Simple mapping
var userDto = MikuMapper.MapProperties<UserDto>(user);
// Exclude properties
var userDto = MikuMapper.MapProperties<UserDto>(user, true, "Password");
// Map collections
var users = new List<User> { user1, user2 };
var userDtos = MikuMapper.MapProperties<UserDto>(users);
CommandLineHelper
using Miku.Utils;
// Automatic detection (uses Environment.GetCommandLineArgs())
if (CommandLineHelper.IsReleaseConfiguration())
{
// Use release settings
}
var outputPath = CommandLineHelper.GetParameterValue("--output") ?? "./default";
// Modern parsing with ParsedArguments
var parsed = CommandLineHelper.Parse();
var includes = parsed.GetValues("--include"); // Multi-value support
var verbose = parsed.HasParameter("--verbose");
MikuMapper Examples
Basic Mapping
var source = new SourceClass { Id = 1, Name = "Test" };
var target = MikuMapper.MapProperties<TargetClass>(source);
Exclude Properties
var dto = MikuMapper.MapProperties<UserDto>(user, true, "Password", "Salt");
Nullable Primitives
// Automatically handles nullable conversions
// int? -> int, bool -> bool?, etc.
var mapped = MikuMapper.MapProperties<TargetType>(source);
Update Existing Object
var existingUser = dbContext.Users.Find(1);
MikuMapper.MapProperties(updateDto, existingUser, true, "Id");
await dbContext.SaveChangesAsync();
CommandLineHelper Examples
Configuration Detection
var connectionString = CommandLineHelper.IsReleaseConfiguration()
? releaseConnectionString
: debugConnectionString;
Parameter Values
// Single value
var output = CommandLineHelper.GetParameterValue("--output");
// Multiple values
var includes = CommandLineHelper.GetParameterValues("--include");
// With default
var port = CommandLineHelper.GetParameterValue("--port") ?? "8080";
Advanced Parsing
// For: --include *.cs --include *.txt --output ./build --verbose
var parsed = CommandLineHelper.Parse();
// Get all includes
var includes = parsed.GetValues("--include"); // ["*.cs", "*.txt"]
// Get single value
var output = parsed.GetValue("--output"); // "./build"
// Check flag
if (parsed.HasParameter("--verbose"))
{
// Enable verbose logging
}
Environment Detection
// Checks command line args AND environment variables
if (CommandLineHelper.IsEnvironment("Production"))
{
// Production configuration
}
var env = CommandLineHelper.GetEnvironment(); // Returns: Development, Production, etc.
API Reference
MikuMapper
Map to new object:
T MapProperties<T>(object source, bool ignoreNull = true, params string[] excludeProperties)
Map collections:
IEnumerable<T> MapProperties<T>(IEnumerable<object> source, bool ignoreNull = true, params string[] excludeProperties)
Map to existing object:
void MapProperties<T>(object source, in T target, bool ignoreNull = true, params string[] excludeProperties)
CommandLineHelper
Configuration checks:
IsReleaseConfiguration(args?)- Check for release buildIsDebugConfiguration(args?)- Check for debug build
Parameter access:
HasParameter(parameter, args?)- Check if parameter existsGetParameterValue(parameter, args?)- Get single valueGetParameterValues(parameter, args?)- Get multiple values
Parsing:
Parse(args?)- ReturnsParsedArgumentsobjectParseArguments(args?)- ReturnsDictionary<string, string>ParseArgumentsWithMultipleValues(args?)- ReturnsDictionary<string, List<string>>
Environment:
IsEnvironment(environment, args?)- Check environmentGetEnvironment(args?, defaultEnvironment)- Get environment name
Migration from 10.0.39
♪ Even Miku makes typos sometimes! ♪
The MapPropertys methods have been renamed to MapProperties (correct spelling). The old methods are still available but marked as [Obsolete] and will be removed in version 10.2.39.
Before:
var dto = MikuMapper.MapPropertys<UserDto>(user); // Typo in name
After:
var dto = MikuMapper.MapProperties<UserDto>(user); // Correct spelling
Performance
- MikuMapper: Reflection-based with cached property info for optimal performance
- CommandLineHelper: LINQ-optimized for efficient parsing
- Thread-Safe: All operations are thread-safe
Requirements
- .NET 10.0 or higher
- C# 14.0
Documentation
Full XML documentation is included for IntelliSense support. See EXAMPLES.md for detailed usage scenarios.
Contributing
Contributions are welcome! Please open an issue or pull request on GitHub.
License
MIT License - See LICENSE file for details.
Credits
Created by Hatsune Nemas with inspiration from:
- Hatsune Miku (初音ミク) - CV01, born August 31st, 2007
- Crypton Future Media
- The global Vocaloid community
Repository
https://github.com/DjNemas/MikuLib
"The future of voice, the future of code!"
Version: 10.1.39 (Mi-Ku Edition)
Series: CV01 Developer Tools
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MikuLib.Utils:
| Package | Downloads |
|---|---|
|
MikuLib
Main Miku library aggregating all Miku sub-libraries: Core (MikuRgbColor, MikuAnsiCodes, MikuColorHelper), Console (MikuConsole, MikuConsoleAnimation), Utils (MikuMapper, MikuCommandLineHelper), and Logger (with SSE and TrueColor support). The future of voice, the future of code! |
GitHub repositories
This package is not used by any popular GitHub repositories.