Sannr.Cli
1.3.0
dotnet tool install --global Sannr.Cli --version 1.3.0
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local Sannr.Cli --version 1.3.0
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Sannr.Cli&version=1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package Sannr.Cli --version 1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Sannr CLI - Migration Tools
The official migration tool for Sannr - the AOT-first validation framework for .NET.
🚀 Quick Start
Installation
Install as a global dotnet tool:
dotnet tool install -g Sannr.Cli
Usage
# Analyze your existing validation code
sannr analyze --input ./src
# Migrate from DataAnnotations
sannr dataannotations --input ./Models --output ./Models
# Migrate from FluentValidation (to attributes)
sannr fluentvalidation --input ./Validators --output ./Models --target attribute
# Migrate from FluentValidation (to Sannr fluent API)
sannr fluentvalidation --input ./Validators --output ./Validators --target fluent
📋 Commands
analyze
Scans your codebase to understand migration complexity and detect validation libraries.
sannr analyze --input <path> [--type auto|fluentvalidation|dataannotations]
Example Output:
📊 Analysis Results:
📁 Files scanned: 42
🏷️ Validation libraries detected: FluentValidation, DataAnnotations
🔄 FluentValidation rules found: 28
📝 DataAnnotations found: 156
🎯 Migration Complexity: Medium
💡 Recommendation: Moderate complexity - review generated code carefully
dataannotations
Automatically migrates DataAnnotations to Sannr attributes.
sannr dataannotations --input <path> --output <path> [--overwrite] [--dry-run]
Supported Conversions:
[Required]→[Required][StringLength]→[StringLength][EmailAddress]→[EmailAddress][Range]→[Range][MaxLength]→[StringLength][MinLength]→[MinLength]
fluentvalidation
Migrates FluentValidation code to Sannr with two output styles.
sannr fluentvalidation --input <path> --output <path> --target <attribute|fluent> [--overwrite] [--dry-run]
Migration Targets:
attribute: ConvertsRuleForchains into Sannr attributes on model properties (recommended for simple models)fluent: Maintains fluent API structure using Sannr's fluent validation (for complex scenarios)
🎯 Migration Strategies
DataAnnotations → Sannr
Before:
using System.ComponentModel.DataAnnotations;
public class User
{
[Required]
[StringLength(100, MinimumLength = 2)]
public string Name { get; set; }
[EmailAddress]
public string Email { get; set; }
}
After:
using Sannr;
public class User
{
[Required]
[StringLength(100, MinimumLength = 2)]
public string Name { get; set; }
[EmailAddress]
public string Email { get; set; }
}
FluentValidation → Sannr (Attribute Style)
Before:
public class UserValidator : AbstractValidator<User>
{
public UserValidator()
{
RuleFor(x => x.Name).NotEmpty().Length(2, 100);
RuleFor(x => x.Email).EmailAddress();
}
}
After:
using Sannr;
public partial class User
{
[Required]
[StringLength(100, MinimumLength = 2)]
public string Name { get; set; }
[EmailAddress]
public string Email { get; set; }
}
FluentValidation → Sannr (Fluent Style)
Before:
public class UserValidator : AbstractValidator<User>
{
public UserValidator()
{
RuleFor(x => x.Name).NotEmpty().Length(2, 100);
RuleFor(x => x.Email).EmailAddress();
}
}
After:
using Sannr;
public partial class UserValidator : ValidatorConfig<User>
{
public override void Configure()
{
RuleFor(x => x.Name).NotEmpty().Length(2, 100);
RuleFor(x => x.Email).Email();
}
}
🛠️ Options
Common Options
--dry-run: Preview changes without modifying files--overwrite: Overwrite existing files in the output directory--help: Show detailed help for any command
Best Practices
- Always analyze first: Run
sannr analyzeto understand the scope - Use dry-run: Test migrations with
--dry-runbefore applying - Backup your code: Commit your changes before running migrations
- Incremental migration: Migrate one module at a time for large codebases
- Review output: Always review generated code before deploying
📖 Documentation
🔄 Updating
Keep the tool up to date:
dotnet tool update -g Sannr.Cli
🤝 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
📄 License
MIT License - see the LICENSE file for details.
Made with ❤️ for the .NET community
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.