Skip to content

Commit 6bf961c

Browse files
committed
refactor: Enforce naming rules, analyzers, and test clarity
- Added PascalCase rule for static readonly fields in .editorconfig - Set severity for unused parameter rules (IDE0060, RCS1163) - Disabled Meziantou.Analyzer in Directory.Build.props - Added Roslynator analyzers and code fix packages - Fixed XML doc typo and improved <inheritdoc> in ConstraintBase - Updated ConstraintTests to use StringComparer.Ordinal for dictionaries
1 parent 5491733 commit 6bf961c

5 files changed

Lines changed: 32 additions & 3 deletions

File tree

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ dotnet_naming_rule.all_const.severity = error
134134
dotnet_naming_rule.all_const.style = all_elements
135135
dotnet_naming_rule.all_const.symbols = all_const
136136

137+
dotnet_naming_style.all_static_readonly.capitalization = pascal_case
138+
dotnet_naming_symbols.all_static_readonly.applicable_kinds = field
139+
dotnet_naming_symbols.all_static_readonly.required_modifiers = static, readonly
140+
dotnet_naming_rule.all_static_readonly.severity = error
141+
dotnet_naming_rule.all_static_readonly.style = all_static_readonly
142+
dotnet_naming_rule.all_static_readonly.symbols = all_static_readonly
143+
137144
dotnet_naming_style.all_fields.required_prefix = _
138145
dotnet_naming_style.all_fields.capitalization = camel_case
139146
dotnet_naming_symbols.all_fields.applicable_kinds = field
@@ -263,6 +270,11 @@ dotnet_diagnostic.IDE0046.severity = sugges
263270
csharp_style_prefer_primary_constructors = false
264271
dotnet_diagnostic.IDE0290.severity = suggestion
265272

273+
# IDE0060: Remove unused parameter
274+
dotnet_diagnostic.IDE0060.severity = warning
275+
dotnet_diagnostic.RCS1163.severity = none
276+
dotnet_code_quality_unused_parameters = all
277+
266278
# [CSharpier] Incompatible rules deactivated
267279
# https://csharpier.com/docs/IntegratingWithLinters#code-analysis-rules
268280
dotnet_diagnostic.IDE0055.severity = none

Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<PackageReleaseNotes>$(RepositoryUrl)/releases</PackageReleaseNotes>
88
<PackageTags>fluent;value;validation;</PackageTags>
99
<CopyrightYearStart>2024</CopyrightYearStart>
10+
11+
<DisableRecommendedPackage>Meziantou.Analyzer</DisableRecommendedPackage>
1012
</PropertyGroup>
1113
<PropertyGroup>
1214
<NetEvolve_ProjectTargetFrameworks>net8.0;net9.0;net10.0</NetEvolve_ProjectTargetFrameworks>

Directory.Packages.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.202" />
1111
<GlobalPackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.14.15" />
1212
<GlobalPackageReference Include="NetEvolve.Defaults" Version="2.4.0" />
13+
<GlobalPackageReference Include="Roslynator.Analyzers" Version="4.15.0" />
14+
<GlobalPackageReference Include="Roslynator.Formatting.Analyzers" Version="4.15.0" />
15+
<GlobalPackageReference Include="Roslynator.CodeAnalysis.Analyzers" Version="4.15.0" />
16+
<GlobalPackageReference Include="Roslynator.CodeFixes" Version="4.15.0" />
17+
<GlobalPackageReference Include="Roslynator.Refactorings" Version="4.15.0" />
1318
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="10.23.0.137933" />
1419
</ItemGroup>
1520
<ItemGroup>

src/NetEvolve.FluentValue/Constraints/ConstraintBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal abstract class ConstraintBase : IConstraint
2626
/// <inheritdoc />
2727
public abstract void SetDescription(StringBuilder builder);
2828

29-
/// <inhertdoc />
29+
/// <inheritdoc cref="object.Equals(object?)" />
3030
[Obsolete("This is base `object` method that should not be called.", true)]
3131
[EditorBrowsable(EditorBrowsableState.Never)]
3232
[DebuggerHidden]

tests/NetEvolve.FluentValue.Tests.Unit/ConstraintTests.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,18 @@ public async Task Value_Theory_Expected(bool expected, IConstraint constraint, o
6969
() => (true, Value.Contains("Hello"), "Hello World!"),
7070
() => (false, Value.Contains('Z', Ordinal), "Hello World!"),
7171
() => (true, Value.Contains('W'), "Hello World!"),
72-
() => (false, Value.Contains(2), new Dictionary<string, object> { { "Hello", "World!" } }),
73-
() => (true, Value.Contains("Hello"), new Dictionary<string, object> { { "Hello", "World!" } }),
72+
() =>
73+
(
74+
false,
75+
Value.Contains(2),
76+
new Dictionary<string, object>(StringComparer.Ordinal) { { "Hello", "World!" } }
77+
),
78+
() =>
79+
(
80+
true,
81+
Value.Contains("Hello"),
82+
new Dictionary<string, object>(StringComparer.Ordinal) { { "Hello", "World!" } }
83+
),
7484
() => (false, Value.Contains(2), new List<string> { "Hello", "World!" }),
7585
() => (true, Value.Contains("World!"), new List<string> { "Hello", "World!" }),
7686
() => (false, Value.Contains(2), Enumerable.Range(10, 10)),

0 commit comments

Comments
 (0)