Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redundant private #1381

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Humanizer.Tests.Shared/CollectionHumanizeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void HumanizeUsesOxfordComma()
Assert.Equal("A String, Another String, or A Third String", collection.Humanize("or"));
}

private readonly List<SomeClass> _testCollection =
readonly List<SomeClass> _testCollection =
[
new() { SomeInt = 1, SomeString = "One" },
new() { SomeInt = 2, SomeString = "Two" },
Expand Down Expand Up @@ -126,6 +126,6 @@ public void HumanizeTrimsItemsByDefault() =>
/// <summary>
/// Use the dummy formatter to ensure tests are testing formatter output rather than input
/// </summary>
private static readonly Func<string, string> dummyFormatter = input => input;
static readonly Func<string, string> dummyFormatter = input => input;
}
}
8 changes: 4 additions & 4 deletions src/Humanizer.Tests.Shared/DateHumanize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{
public class DateHumanize
{
private static readonly object LockObject = new();
static readonly object LockObject = new();

private static void VerifyWithCurrentDate(string expectedString, TimeSpan deltaFromNow, CultureInfo culture)
static void VerifyWithCurrentDate(string expectedString, TimeSpan deltaFromNow, CultureInfo culture)
{
var utcNow = DateTime.UtcNow;
var localNow = DateTime.Now;
Expand All @@ -13,15 +13,15 @@ private static void VerifyWithCurrentDate(string expectedString, TimeSpan deltaF
VerifyWithDate(expectedString, deltaFromNow, culture, localNow, utcNow);
}

private static void VerifyWithDateInjection(string expectedString, TimeSpan deltaFromNow, CultureInfo culture)
static void VerifyWithDateInjection(string expectedString, TimeSpan deltaFromNow, CultureInfo culture)
{
var utcNow = new DateTime(2013, 6, 20, 9, 58, 22, DateTimeKind.Utc);
var now = new DateTime(2013, 6, 20, 11, 58, 22, DateTimeKind.Local);

VerifyWithDate(expectedString, deltaFromNow, culture, now, utcNow);
}

private static void VerifyWithDate(string expectedString, TimeSpan deltaFromBase, CultureInfo culture, DateTime baseDate, DateTime baseDateUtc)
static void VerifyWithDate(string expectedString, TimeSpan deltaFromBase, CultureInfo culture, DateTime baseDate, DateTime baseDateUtc)
{
Assert.Equal(expectedString, baseDateUtc.Add(deltaFromBase).Humanize(utcDate: true, dateToCompareAgainst: baseDateUtc, culture: culture));
Assert.Equal(expectedString, baseDate.Add(deltaFromBase).Humanize(false, baseDate, culture: culture));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[UseCulture("en-US")]
public class DateTimeHumanizePrecisionStrategyTests
{
private const double DefaultPrecision = .75;
const double DefaultPrecision = .75;

[Theory]
[InlineData(1, "now")]
Expand Down
4 changes: 2 additions & 2 deletions src/Humanizer.Tests.Shared/DehumanizeToEnumTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void HonorsLocalizedDisplayAttribute()
Assert.Equal(EnumUnderTest.MemberWithLocalizedDisplayAttribute, EnumTestsResources.MemberWithLocalizedDisplayAttribute.DehumanizeTo(typeof(EnumUnderTest)));
}

private struct DummyStructWithEnumInterfaces : IComparable, IFormattable
struct DummyStructWithEnumInterfaces : IComparable, IFormattable
{
public int CompareTo(object obj) =>
throw new NotImplementedException();
Expand Down Expand Up @@ -140,7 +140,7 @@ public object ToType(Type conversionType, IFormatProvider provider) =>
throw new NotImplementedException();
}

private enum DummyEnum
enum DummyEnum
{
First,
Second
Expand Down
4 changes: 2 additions & 2 deletions src/Humanizer.Tests.Shared/StringExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
public class StringExtensionsTests
{
private const string Format = "This is a format with three numbers: {0}-{1}-{2}.";
private const string Expected = "This is a format with three numbers: 1-2-3.";
const string Format = "This is a format with three numbers: {0}-{1}-{2}.";
const string Expected = "This is a format with three numbers: 1-2-3.";

[Fact]
public void CanFormatStringWithExactNumberOfArguments() =>
Expand Down
8 changes: 4 additions & 4 deletions src/Humanizer.Tests.Shared/UseCultureAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace Humanizer.Tests
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class UseCultureAttribute : BeforeAfterTestAttribute
{
private readonly Lazy<CultureInfo> culture;
private readonly Lazy<CultureInfo> uiCulture;
private CultureInfo originalCulture;
private CultureInfo originalUICulture;
readonly Lazy<CultureInfo> culture;
readonly Lazy<CultureInfo> uiCulture;
CultureInfo originalCulture;
CultureInfo originalUICulture;

/// <summary>
/// Replaces the culture and UI culture of the current thread with
Expand Down
2 changes: 1 addition & 1 deletion src/Humanizer/ArticlePrefixSort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static string[] PrependArticleSuffix(string[] appended)
return inserted;
}

private static string ToOriginalFormat(string[] appended, string suffix, int i)
static string ToOriginalFormat(string[] appended, string suffix, int i)
{
var insertion = appended[i].Remove(appended[i].IndexOf(suffix, StringComparison.CurrentCulture));
var original = $"{suffix} {insertion}";
Expand Down
4 changes: 2 additions & 2 deletions src/Humanizer/Bytes/ByteSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public string ToString(string format) =>
public string ToString(string format, IFormatProvider provider) =>
ToString(format, provider, toSymbol: true);

private string ToString(string format, IFormatProvider provider, bool toSymbol)
string ToString(string format, IFormatProvider provider, bool toSymbol)
{
if (format == null)
format = "G";
Expand Down Expand Up @@ -500,7 +500,7 @@ public static bool TryParse(string s, IFormatProvider formatProvider, out ByteSi
return true;
}

private static NumberFormatInfo GetNumberFormatInfo(IFormatProvider formatProvider)
static NumberFormatInfo GetNumberFormatInfo(IFormatProvider formatProvider)
{
if (formatProvider is NumberFormatInfo numberFormat)
return numberFormat;
Expand Down
4 changes: 2 additions & 2 deletions src/Humanizer/Configuration/Configurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ internal static INumberToWordsConverter GetNumberToWordsConverter(CultureInfo cu
public static ITimeOnlyHumanizeStrategy TimeOnlyHumanizeStrategy { get; set; } = new DefaultTimeOnlyHumanizeStrategy();
#endif

private static readonly Func<PropertyInfo, bool> DefaultEnumDescriptionPropertyLocator = p => p.Name == "Description";
private static Func<PropertyInfo, bool> _enumDescriptionPropertyLocator = DefaultEnumDescriptionPropertyLocator;
static readonly Func<PropertyInfo, bool> DefaultEnumDescriptionPropertyLocator = p => p.Name == "Description";
static Func<PropertyInfo, bool> _enumDescriptionPropertyLocator = DefaultEnumDescriptionPropertyLocator;
/// <summary>
/// A predicate function for description property of attribute to use for Enum.Humanize
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Humanizer/Configuration/FormatterRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public FormatterRegistry() : base(new DefaultFormatter("en-US"))
Register("lb", new LuxembourgishFormatter());
}

private void RegisterDefaultFormatter(string localeCode)
void RegisterDefaultFormatter(string localeCode)
{
try
{
Expand All @@ -72,7 +72,7 @@ private void RegisterDefaultFormatter(string localeCode)
}
}

private void RegisterCzechSlovakPolishFormatter(string localeCode) =>
void RegisterCzechSlovakPolishFormatter(string localeCode) =>
Register(localeCode, new CzechSlovakPolishFormatter(localeCode));
}
}
6 changes: 3 additions & 3 deletions src/Humanizer/Configuration/LocaliserRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
public class LocaliserRegistry<TLocaliser>
where TLocaliser : class
{
private readonly IDictionary<string, Func<CultureInfo, TLocaliser>> _localisers = new Dictionary<string, Func<CultureInfo, TLocaliser>>();
private readonly Func<CultureInfo, TLocaliser> _defaultLocaliser;
readonly IDictionary<string, Func<CultureInfo, TLocaliser>> _localisers = new Dictionary<string, Func<CultureInfo, TLocaliser>>();
readonly Func<CultureInfo, TLocaliser> _defaultLocaliser;

/// <summary>
/// Creates a localiser registry with the default localiser set to the provided value
Expand Down Expand Up @@ -47,7 +47,7 @@ public void Register(string localeCode, TLocaliser localiser) =>
public void Register(string localeCode, Func<CultureInfo, TLocaliser> localiser) =>
_localisers[localeCode] = localiser;

private Func<CultureInfo, TLocaliser> FindLocaliser(CultureInfo culture)
Func<CultureInfo, TLocaliser> FindLocaliser(CultureInfo culture)
{
for (var c = culture; !string.IsNullOrEmpty(c?.Name); c = c.Parent)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static string PrecisionHumanize(TimeOnly input, TimeOnly comparisonBase,
return PrecisionHumanize(ts, tense, precision, culture);
}
#endif
private static string PrecisionHumanize(TimeSpan ts, Tense tense, double precision, CultureInfo culture)
static string PrecisionHumanize(TimeSpan ts, Tense tense, double precision, CultureInfo culture)
{
int seconds = ts.Seconds, minutes = ts.Minutes, hours = ts.Hours, days = ts.Days;
int years = 0, months = 0;
Expand Down Expand Up @@ -172,7 +172,7 @@ public static string DefaultHumanize(TimeOnly input, TimeOnly comparisonBase, Cu
}
#endif

private static string DefaultHumanize(TimeSpan ts, bool sameMonth, int days, Tense tense, CultureInfo culture)
static string DefaultHumanize(TimeSpan ts, bool sameMonth, int days, Tense tense, CultureInfo culture)
{
var formatter = Configurator.GetFormatter(culture);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Humanizer
/// </summary>
public class PrecisionDateOnlyHumanizeStrategy : IDateOnlyHumanizeStrategy
{
private readonly double _precision;
readonly double _precision;

/// <summary>
/// Constructs a precision-based calculator for distance of time with default precision 0.75.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Humanizer
/// </summary>
public class PrecisionDateTimeHumanizeStrategy : IDateTimeHumanizeStrategy
{
private readonly double _precision;
readonly double _precision;

/// <summary>
/// Constructs a precision-based calculator for distance of time with default precision 0.75.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Humanizer
/// </summary>
public class PrecisionDateTimeOffsetHumanizeStrategy : IDateTimeOffsetHumanizeStrategy
{
private readonly double _precision;
readonly double _precision;

/// <summary>
/// Constructs a precision-based calculator for distance of time with default precision 0.75.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Humanizer
/// </summary>
public class PrecisionTimeOnlyHumanizeStrategy : ITimeOnlyHumanizeStrategy
{
private readonly double _precision;
readonly double _precision;

/// <summary>
/// Constructs a precision-based calculator for distance of time with default precision 0.75.
Expand Down
2 changes: 1 addition & 1 deletion src/Humanizer/EnumDehumanizeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static TTargetEnum DehumanizeTo<TTargetEnum>(this string input)
public static Enum DehumanizeTo(this string input, Type targetEnum, OnNoMatch onNoMatch = OnNoMatch.ThrowsException) =>
(Enum)DehumanizeToPrivate(input, targetEnum, onNoMatch);

private static object DehumanizeToPrivate(string input, Type targetEnum, OnNoMatch onNoMatch)
static object DehumanizeToPrivate(string input, Type targetEnum, OnNoMatch onNoMatch)
{
var match = Enum.GetValues(targetEnum).Cast<Enum>().FirstOrDefault(value => string.Equals(value.Humanize(), input, StringComparison.OrdinalIgnoreCase));

Expand Down
4 changes: 2 additions & 2 deletions src/Humanizer/EnumHumanizeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public static string Humanize(this Enum input)
/// Checks whether the given enum is to be used as a bit field type.
/// </summary>
/// <returns>True if the given enum is a bit field enum, false otherwise.</returns>
private static bool IsBitFieldEnum(Type type) =>
static bool IsBitFieldEnum(Type type) =>
type.GetCustomAttribute(typeof(FlagsAttribute)) != null;

private static string GetCustomDescription(MemberInfo memberInfo)
static string GetCustomDescription(MemberInfo memberInfo)
{
var displayAttribute = memberInfo.GetCustomAttribute<DisplayAttribute>();
if (displayAttribute != null)
Expand Down
4 changes: 2 additions & 2 deletions src/Humanizer/Inflections/Vocabularies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// </summary>
public static class Vocabularies
{
private static readonly Lazy<Vocabulary> Instance;
static readonly Lazy<Vocabulary> Instance;

static Vocabularies() =>
Instance = new(BuildDefault, LazyThreadSafetyMode.PublicationOnly);
Expand All @@ -17,7 +17,7 @@ static Vocabularies() =>
/// </summary>
public static Vocabulary Default => Instance.Value;

private static Vocabulary BuildDefault()
static Vocabulary BuildDefault()
{
var _default = new Vocabulary();

Expand Down
2 changes: 1 addition & 1 deletion src/Humanizer/Inflections/Vocabulary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ string LetterS(string word)

class Rule(string pattern, string replacement)
{
private readonly Regex regex = new(pattern, RegexOptions.IgnoreCase | RegexOptionsUtil.Compiled);
readonly Regex regex = new(pattern, RegexOptions.IgnoreCase | RegexOptionsUtil.Compiled);

public string Apply(string word)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public string Humanize<T>(IEnumerable<T> collection, Func<T, object> objectForma
separator);
}

private string HumanizeDisplayStrings(IEnumerable<string> strings, string separator)
string HumanizeDisplayStrings(IEnumerable<string> strings, string separator)
{
var itemsArray = strings
.Select(item => item == null ? string.Empty : item.Trim())
Expand Down
4 changes: 2 additions & 2 deletions src/Humanizer/Localisation/Formatters/ArabicFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
class ArabicFormatter() :
DefaultFormatter("ar")
{
private const string DualPostfix = "_Dual";
private const string PluralPostfix = "_Plural";
const string DualPostfix = "_Dual";
const string PluralPostfix = "_Plural";

protected override string GetResourceKey(string resourceKey, int number)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Humanizer/Localisation/Formatters/CroatianFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Humanizer
class CroatianFormatter() :
DefaultFormatter("hr")
{
private const string DualTrialQuadralPostfix = "_DualTrialQuadral";
const string DualTrialQuadralPostfix = "_DualTrialQuadral";

protected override string GetResourceKey(string resourceKey, int number)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class CzechSlovakPolishFormatter(string localeCode) :
DefaultFormatter(localeCode)
{
private const string PaucalPostfix = "_Paucal";
const string PaucalPostfix = "_Paucal";

protected override string GetResourceKey(string resourceKey, int number)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Humanizer/Localisation/Formatters/DefaultFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// </summary>
public class DefaultFormatter : IFormatter
{
private readonly CultureInfo _culture;
readonly CultureInfo _culture;

/// <summary>
/// Constructor.
Expand Down Expand Up @@ -68,13 +68,13 @@ public virtual string TimeUnitHumanize(TimeUnit timeUnit)
return Format(resourceKey);
}

private string GetResourceForDate(TimeUnit unit, Tense timeUnitTense, int count)
string GetResourceForDate(TimeUnit unit, Tense timeUnitTense, int count)
{
var resourceKey = ResourceKeys.DateHumanize.GetResourceKey(unit, timeUnitTense: timeUnitTense, count: count);
return count == 1 ? Format(resourceKey) : Format(resourceKey, count);
}

private string GetResourceForTimeSpan(TimeUnit unit, int count, bool toWords = false)
string GetResourceForTimeSpan(TimeUnit unit, int count, bool toWords = false)
{
var resourceKey = ResourceKeys.TimeSpanHumanize.GetResourceKey(unit, count, toWords);
return count == 1 ? Format(resourceKey + (toWords ? "_Words" : "")) : Format(resourceKey, count, toWords);
Expand Down
2 changes: 1 addition & 1 deletion src/Humanizer/Localisation/Formatters/FrenchFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class FrenchFormatter(string localeCode) :
DefaultFormatter(localeCode)
{
private const string DualPostfix = "_Dual";
const string DualPostfix = "_Dual";

protected override string GetResourceKey(string resourceKey, int number)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Humanizer/Localisation/Formatters/HebrewFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
class HebrewFormatter() :
DefaultFormatter("he")
{
private const string DualPostfix = "_Dual";
private const string PluralPostfix = "_Plural";
const string DualPostfix = "_Dual";
const string PluralPostfix = "_Plural";

protected override string GetResourceKey(string resourceKey, int number)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Humanizer/Localisation/Formatters/IcelandicFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
class IcelandicFormatter() :
DefaultFormatter(LocaleCode)
{
private const string LocaleCode = "is";
private readonly CultureInfo _localCulture = new(LocaleCode);
const string LocaleCode = "is";
readonly CultureInfo _localCulture = new(LocaleCode);

public override string DataUnitHumanize(DataUnit dataUnit, double count, bool toSymbol = true) =>
base.DataUnitHumanize(dataUnit, count, toSymbol)?.TrimEnd('s');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected override string GetResourceKey(string resourceKey, int number)
return resourceKey + suffix;
}

private static string GetSuffix(LithuanianNumberForm form)
static string GetSuffix(LithuanianNumberForm form)
{
if (form == LithuanianNumberForm.Singular)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Humanizer/Localisation/Formatters/MalteseFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
class MalteseFormatter(string localeCode) :
DefaultFormatter(localeCode)
{
private const string DualPostfix = "_Dual";
const string DualPostfix = "_Dual";

private static readonly string[] DualResourceKeys =
static readonly string[] DualResourceKeys =
[
"DateHumanize_MultipleDaysAgo", "DateHumanize_MultipleDaysFromNow", "DateHumanize_MultipleHoursAgo", "DateHumanize_MultipleHoursFromNow" ,
"DateHumanize_MultipleMonthsAgo", "DateHumanize_MultipleMonthsFromNow", "DateHumanize_MultipleYearsAgo", "DateHumanize_MultipleYearsFromNow",
Expand Down
Loading