GuardClauses icon indicating copy to clipboard operation
GuardClauses copied to clipboard

Analyzers that verify this is used in all public methods

Open C0DK opened this issue 3 years ago • 3 comments
trafficstars

Awesome package. Love it.

We currently employ units tests to verify that guard clauses are used in all public methods, which is done by extending the AutoFixture idiom helper and then searching all packages in the solution.

Testing code quality via unit tests isn't ideal, and it would be nice not to have it as part of our test suite but instead utilize Roslyn, which I assume might be possible. (I might be wrong, though!)

Not sure if this would be too much of a stretch compared to this otherwise light package, but one might name a separate sub-project.

I'll try to work on it myself if I have time one day, but I am currently somewhat busy.

C0DK avatar Dec 21 '21 08:12 C0DK

I'm seeing some stuff here. https://github.com/dotnet/roslyn-analyzers/blob/main/docs/Analyzer%20Configuration.md#null-check-validation-methods

Could we maybe just extend the readme to help users doing this?

C0DK avatar Dec 21 '21 08:12 C0DK

@C0DK The Roslyn approach to just specify that Ardalis.GuardClauses method perform null checks looks good. Have you gotten it to work and if so what, specifically, did you specify to inform Roslyn?

ardalis avatar Jan 18 '22 20:01 ardalis

If you want to provide a PR to extend our README that would be great.

ardalis avatar May 17 '22 14:05 ardalis