Skip to content

Commit

Permalink
Use primary constructor to address IDE0290 warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Locke <[email protected]>
  • Loading branch information
kevinoid committed Nov 30, 2023
1 parent a1e800e commit b178f82
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
11 changes: 3 additions & 8 deletions NLCaseConvert/NameCapitalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,13 @@ private static string GetPattern(Builder builder)
"Microsoft.Design",
"CA1034:NestedTypesShouldNotBeVisible",
Justification = "Builder as nested type is conventional.")]
public class Builder
public class Builder(CultureInfo cultureInfo)
{
public Builder()
: this(CultureInfo.CurrentCulture)
{
}

public Builder(CultureInfo cultureInfo)
{
this.CultureInfo = cultureInfo
?? throw new ArgumentNullException(nameof(cultureInfo));
}

/// <summary>
/// Gets a pattern to match Arabic name prefixes which should not
/// be capitalized.
Expand Down Expand Up @@ -244,7 +238,8 @@ public Builder(CultureInfo cultureInfo)
public static string MixedCaseWordPattern { get; } =
@"(?!['`’-])[\p{L}\p{Mn}\p{Nd}'`’]*[\p{Lu}\p{Lt}][\p{L}\p{Mn}\p{Nd}'`’-]*";

public CultureInfo CultureInfo { get; }
public CultureInfo CultureInfo { get; } = cultureInfo
?? throw new ArgumentNullException(nameof(cultureInfo));

/// <summary>
/// Gets a pattern to match a word where all letters should be
Expand Down
9 changes: 2 additions & 7 deletions NLCaseConvert/SentenceCapitalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,20 +303,15 @@ private static string GetPattern(Builder builder)
"Microsoft.Design",
"CA1034:NestedTypesShouldNotBeVisible",
Justification = "Builder as nested type is conventional.")]
public class Builder
public class Builder(CultureInfo cultureInfo)
{
public Builder()
: this(CultureInfo.CurrentCulture)
{
}

public Builder(CultureInfo cultureInfo)
{
this.CultureInfo = cultureInfo
public CultureInfo CultureInfo { get; } = cultureInfo
?? throw new ArgumentNullException(nameof(cultureInfo));
}

public CultureInfo CultureInfo { get; }

public bool AfterParagraphBreak { get; set; }

Expand Down
9 changes: 2 additions & 7 deletions NLCaseConvert/TitleCapitalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,15 @@ private static string GetPattern(Builder builder)
"Microsoft.Design",
"CA1034:NestedTypesShouldNotBeVisible",
Justification = "Builder as nested type is conventional.")]
public class Builder
public class Builder(CultureInfo cultureInfo)
{
public Builder()
: this(CultureInfo.CurrentCulture)
{
}

public Builder(CultureInfo cultureInfo)
{
this.CultureInfo = cultureInfo
public CultureInfo CultureInfo { get; } = cultureInfo
?? throw new ArgumentNullException(nameof(cultureInfo));
}

public CultureInfo CultureInfo { get; }

/// <summary>
/// Gets additional patterns to exclude from capitalization.
Expand Down

0 comments on commit b178f82

Please sign in to comment.