ardalis / ardalis/GuardClauses.Analyzers

CA1062: Validate arguments of public methods

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
11
Forks
1
PR merge metrics
No merged PRs in 30d

Description

First off, I'm not sure if this project is intended to fix issues like this, but here goes.

The current version of GuardClauses does not prevent "CA1062: Validate arguments of public methods" from producing warnings.

Example that would produce the warning on modelBuilder:

```c#
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
Guard.Against.Null(modelBuilder, nameof(modelBuilder));

base.OnModelCreating(modelBuilder);

// All string properties are considered VARCHAR by default.
foreach (var property in modelBuilder.Model.GetEntityTypes().SelectMany(t => t.GetProperties()).Where(p => p.ClrType == typeof(string)))
property.AsProperty().Builder.IsUnicode(false, ConfigurationSource.Convention);
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the CA1062 warning for the OnModelCreating(ModelBuilder modelBuilder) example and inspect how Guard.Against.Null is recognized. Determine what analyzer behavior is needed for this pattern; done means the shown public-method argument no longer produces the warning while the existing guard call remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.