Add analyzer for checking for null parameters on assignation
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 294
- Avg merge
- 2h 30m
- Merged PRs (30d)
- 4
Description
It would be nice if you had an analyzer that would e.g. change
```cs
private string Arg1;
private Stream Arg2;
public void Foo(string arg1, Stream arg2)
{
this.Arg1 = arg1;
this.Arg2 = arg2;
}
```
to
```cs
private string Arg1;
private Stream Arg2;
public void Foo(string arg1, Stream arg2)
{
this.Arg1 = arg1 ?? throw new ArgumentNullException(nameof(arg1));
this.Arg2 = arg2 ?? throw new ArgumentNullException(nameof(arg2));
}
```
I think this should only be available when the line is a simple assignation (`x = param`).
Contributor guide
Research direction
The issue provides no repository files or tests to start from. Locate existing C# analyzer and code-fix entry points and their tests, then verify how simple parameter-to-member assignments are diagnosed. Done means the analyzer offers null checks for those assignments while leaving other assignment forms unchanged.
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
- 45/100