Skip to content

Commit 9daaf8a

Browse files
authored
feat: Replace Argument.ThrowIfNull with ArgumentNullException.ThrowIf… (#401)
* feat: Replace Argument.ThrowIfNull with ArgumentNullException.ThrowIfNull for built-in null checking - Remove NetEvolve.Arguments using directives where no longer needed - Remove coverlet.collector from Directory.Packages.props and test project - Clean up unused using directives in several files * fix: Add permissions section to CI workflow for enhanced access control
1 parent 0a58bb9 commit 9daaf8a

13 files changed

Lines changed: 33 additions & 43 deletions

File tree

.csharpierignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
**/nuget.config
2-
**/_snapshots/
3-
**/_snapshot/
1+
**/[Nn]u[Gg]et.config
2+
**/*.verified.*
3+
**/*.received.*

.editorconfig

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,22 @@ generated_code = true
4444
# XML project files
4545
[*.{slnx,csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,nativeproj,locproj}]
4646
indent_size = 2
47+
max_line_length = 200
4748

4849
# Xml build files
4950
[*.builds]
5051
indent_size = 2
52+
max_line_length = 200
5153

5254
# Xml files
5355
[*.{xml,stylecop,resx,ruleset}]
5456
indent_size = 2
57+
max_line_length = 200
5558

5659
# XML config files
5760
[*.{props,targets,ruleset,config,nuspec,vsixmanifest,vsct}]
5861
indent_size = 2
62+
max_line_length = 200
5963

6064
# JSON files
6165
[*.json]
@@ -86,10 +90,6 @@ insert_final_newline = false
8690
[*.sln]
8791
indent_style = tab
8892

89-
[*.{received,verified}.txt]
90-
insert_final_newline = false
91-
trim_trailing_whitespace = false
92-
9393
[*.{cs,csx,vb,vbx}]
9494
# .NET Code Style Settings
9595
# See https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
@@ -266,19 +266,18 @@ dotnet_diagnostic.IDE0290.severity = sugges
266266
# [CSharpier] Incompatible rules deactivated
267267
# https://csharpier.com/docs/IntegratingWithLinters#code-analysis-rules
268268
dotnet_diagnostic.IDE0055.severity = none
269-
dotnet_diagnostic.SA1000.severity = none
270-
dotnet_diagnostic.SA1009.severity = none
271-
dotnet_diagnostic.SA1111.severity = none
272-
dotnet_diagnostic.SA1118.severity = none
273-
dotnet_diagnostic.SA1137.severity = none
274-
dotnet_diagnostic.SA1413.severity = none
275-
dotnet_diagnostic.SA1500.severity = none
276-
dotnet_diagnostic.SA1501.severity = none
277-
dotnet_diagnostic.SA1502.severity = none
278-
dotnet_diagnostic.SA1504.severity = none
279-
dotnet_diagnostic.SA1515.severity = none
280-
dotnet_diagnostic.SA1516.severity = none
281269

282270
# Support for NetEvolve.Arguments Methods
283271
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1062#null-check-validation-methods
284272
dotnet_code_quality.CA1062.null_check_validation_methods = M:NetEvolve.Arguments.Argument.ThrowIfNull(System.Object,System.String)|M:NetEvolve.Arguments.Argument.ThrowIfNull(System.Void*,System.String)|M:NetEvolve.Arguments.Argument.ThrowIfNullOrEmpty(System.String,System.String)|M:NetEvolve.Arguments.Argument.ThrowIfNullOrEmpty``1(System.Collections.Generic.IEnumerable{``0},System.String)|M:NetEvolve.Arguments.Argument.ThrowIfNullOrWhiteSpace(System.String,System.String)
273+
274+
# Disable all style rules for generated code
275+
[*.{received,verified}.*]
276+
generated_code = true
277+
# Disable all style rules for migrations
278+
dotnet_analyzer_diagnostic.severity = none
279+
280+
[**/Migrations/*.{cs,csx,vb,vbx}]
281+
generated_code = true
282+
# Disable all style rules for migrations
283+
dotnet_analyzer_diagnostic.severity = none

.github/workflows/cicd.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ on:
1818
- detailed
1919
- diagnostic
2020

21+
permissions:
22+
actions: read
23+
contents: write
24+
pull-requests: write
25+
security-events: write
26+
2127
jobs:
2228
all:
2329
if: github.run_id != 1

Directory.Packages.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="10.21.0.135717" />
1414
</ItemGroup>
1515
<ItemGroup>
16-
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
1716
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
1817
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.5.2" />
1918
<PackageVersion Include="NetEvolve.Arguments" Version="3.2.84" />

src/NetEvolve.FluentValue/Constraints/ConstraintBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace NetEvolve.FluentValue.Constraints;
22

33
using System;
4-
using System.Collections;
54
using System.ComponentModel;
65
using System.Diagnostics;
76
using System.Diagnostics.CodeAnalysis;

src/NetEvolve.FluentValue/Constraints/DefaultConstraint.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NetEvolve.FluentValue.Constraints;
22

3-
using System;
43
using System.Text;
54
using NetEvolve.FluentValue;
65

src/NetEvolve.FluentValue/Constraints/ParenthesisConstraint.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace NetEvolve.FluentValue.Constraints;
22

33
using System.Text;
4-
using NetEvolve.Arguments;
54
using NetEvolve.FluentValue;
65

76
internal sealed class ParenthesisConstraint : ConstraintBase
@@ -10,14 +9,14 @@ internal sealed class ParenthesisConstraint : ConstraintBase
109

1110
internal ParenthesisConstraint(IConstraint constraint)
1211
{
13-
Argument.ThrowIfNull(constraint);
12+
ArgumentNullException.ThrowIfNull(constraint);
1413

1514
_constraint = (ConstraintBase)constraint;
1615
}
1716

1817
public override bool IsSatisfiedBy(object? value)
1918
{
20-
Argument.ThrowIfNull(_constraint);
19+
ArgumentNullException.ThrowIfNull(_constraint);
2120

2221
return _constraint.IsSatisfiedBy(value);
2322
}

src/NetEvolve.FluentValue/Operators/AndOperator.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
using System;
44
using System.Text;
5-
using NetEvolve.Arguments;
65
using NetEvolve.FluentValue;
76
using NetEvolve.FluentValue.Constraints;
87

@@ -13,7 +12,7 @@ internal sealed class AndOperator : ConstraintBase, IOperator
1312

1413
internal AndOperator(IConstraint left)
1514
{
16-
Argument.ThrowIfNull(left);
15+
ArgumentNullException.ThrowIfNull(left);
1716

1817
_left = left;
1918
}
@@ -30,7 +29,7 @@ public override bool IsSatisfiedBy(object? value)
3029

3130
public IConstraint SetConstraint(IConstraint constraint)
3231
{
33-
Argument.ThrowIfNull(constraint);
32+
ArgumentNullException.ThrowIfNull(constraint);
3433

3534
if (_right is NotOperator notOperator)
3635
{

src/NetEvolve.FluentValue/Operators/NotOperator.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
using System;
44
using System.Text;
5-
using NetEvolve.Arguments;
65
using NetEvolve.FluentValue;
76
using NetEvolve.FluentValue.Constraints;
87

@@ -24,7 +23,7 @@ public override bool IsSatisfiedBy(object? value)
2423

2524
public IConstraint SetConstraint(IConstraint constraint)
2625
{
27-
Argument.ThrowIfNull(constraint);
26+
ArgumentNullException.ThrowIfNull(constraint);
2827

2928
_constraint = constraint;
3029

src/NetEvolve.FluentValue/Operators/OrOperator.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
using System;
44
using System.Text;
5-
using NetEvolve.Arguments;
65
using NetEvolve.FluentValue;
76
using NetEvolve.FluentValue.Constraints;
87

@@ -13,7 +12,7 @@ internal sealed class OrOperator : ConstraintBase, IOperator
1312

1413
internal OrOperator(IConstraint left)
1514
{
16-
Argument.ThrowIfNull(left);
15+
ArgumentNullException.ThrowIfNull(left);
1716

1817
_left = left;
1918
}
@@ -30,7 +29,7 @@ public override bool IsSatisfiedBy(object? value)
3029

3130
public IConstraint SetConstraint(IConstraint constraint)
3231
{
33-
Argument.ThrowIfNull(constraint);
32+
ArgumentNullException.ThrowIfNull(constraint);
3433

3534
if (_right is NotOperator notOperator)
3635
{

0 commit comments

Comments
 (0)