src/Humanizer.Analyzers/README.md
A Roslyn analyzer and code fix provider to help migrate code from Humanizer v2 to v3.
Humanizer.Core ships analyzer assets per Roslyn version so compatible analyzers are selected automatically by modern SDK/IDE hosts.
Humanizer v3 consolidates all sub-namespaces into the root Humanizer namespace. This analyzer:
Humanizer.Bytes, Humanizer.Localisation)HumanizerThe following namespaces have been consolidated into Humanizer:
Humanizer.BytesHumanizer.LocalisationHumanizer.Localisation.FormattersHumanizer.Localisation.NumberToWordsHumanizer.DateTimeHumanizeStrategyHumanizer.ConfigurationHumanizer.Localisation.DateToOrdinalWordsHumanizer.Localisation.OrdinalizersHumanizer.InflectionsHumanizer.Localisation.CollectionFormattersHumanizer.Localisation.TimeToClockNotationThe analyzer will highlight old namespace usages with warnings. You can:
Before:
using Humanizer.Bytes;
using Humanizer.Localisation;
public class Example
{
public void Method()
{
var size = ByteSize.FromKilobytes(10);
var formatter = new DefaultFormatter();
}
}
After (automatic fix):
using Humanizer;
public class Example
{
public void Method()
{
var size = ByteSize.FromKilobytes(10);
var formatter = new DefaultFormatter();
}
}
You can also use the .NET CLI to apply fixes:
# Analyze and show diagnostics
dotnet build /p:TreatWarningsAsErrors=false
# Apply code fixes (requires dotnet format or IDE)
dotnet format analyzers --diagnostics HUMANIZER001
cd src/Humanizer.Analyzers
dotnet build
# from the repository root
cd tests/Humanizer.Analyzers.Tests
dotnet test