Swevo.PollyAnalyzers
1.0.1
Prefix Reserved
dotnet add package Swevo.PollyAnalyzers --version 1.0.1
NuGet\Install-Package Swevo.PollyAnalyzers -Version 1.0.1
<PackageReference Include="Swevo.PollyAnalyzers" Version="1.0.1" />
<PackageVersion Include="Swevo.PollyAnalyzers" Version="1.0.1" />
<PackageReference Include="Swevo.PollyAnalyzers" />
paket add Swevo.PollyAnalyzers --version 1.0.1
#r "nuget: Swevo.PollyAnalyzers, 1.0.1"
#:package Swevo.PollyAnalyzers@1.0.1
#addin nuget:?package=Swevo.PollyAnalyzers&version=1.0.1
#tool nuget:?package=Swevo.PollyAnalyzers&version=1.0.1
PollyAnalyzers
Free, MIT-licensed Roslyn analyzers for async/resilience anti-patterns. No per-seat license required — ever.
Why PollyAnalyzers?
ReSharper (~$249+/seat/year) and similar commercial tools are broad style/inspection suites. Free tools like Roslynator and SonarLint already cover general C# code smells well. What none of them specifically targets is reliability: the handful of async/exception-handling mistakes that cause deadlocks, silent failures, and un-cancellable requests in production. PollyAnalyzers is a small, focused analyzer pack for exactly that gap, built by the same team that maintains 28+ Polly v8 resilience integration packages.
var data = httpClient.GetAsync(url).Result; // PLY001: blocking call, deadlock risk
async void OnTimerElapsed(object? state) { ... } // PLY002: async void, unobservable exceptions
SendWelcomeEmailAsync(order); // PLY003: fire-and-forget, exception lost
catch (Exception) { } // PLY004: swallowed exception
await httpClient.GetAsync(url); // PLY005: cancellationToken in scope, not passed
Install
dotnet add package Swevo.PollyAnalyzers
Works automatically in Visual Studio, Rider, and VS Code (via the C# Dev Kit/OmniSharp Roslyn workspace) the moment the package is referenced — no separate IDE extension to install.
Rules
| ID | Severity | Title |
|---|---|---|
| PLY001 | Warning | Blocking call on async API (.Result, .Wait(), .GetAwaiter().GetResult()) may cause a deadlock |
| PLY002 | Warning | Avoid async void methods (except conventional event handlers) |
| PLY003 | Warning | Fire-and-forget task is not awaited, assigned, or discarded |
| PLY004 | Warning | Empty catch block swallows exceptions |
| PLY005 | Info | Async call drops an available CancellationToken |
Each rule ships with one or more code fixes (Ctrl+. / Alt+Enter):
- PLY001 — replace with
await(offered only inside an already-asyncmethod, since the fix can't safely make a sync method async and update every caller for you). - PLY002 — change the return type to
Task. - PLY003 — discard with
_ =(always safe), orawaitthe call (offered inside async methods). - PLY004 — insert
throw;to rethrow instead of swallowing. - PLY005 — append the in-scope
CancellationTokenas the call's last argument.
Suppressing a rule
Standard Roslyn suppression applies — per line:
#pragma warning disable PLY001
var data = httpClient.GetAsync(url).Result;
#pragma warning restore PLY001
or per-project via .editorconfig:
dotnet_diagnostic.PLY001.severity = none
Design goals
- MIT licensed, forever. No commercial tier, no per-seat fees.
- Narrow and precise. Five rules that catch real production incidents, not hundreds of style opinions — pairs cleanly alongside Roslynator/SonarLint rather than competing with them.
- Actionable. Every rule ships with a code fix, not just a warning.
Roadmap
- Additional rules are being considered based on real-world false-positive/false-negative
feedback: HttpClient calls with no timeout or retry policy configured, and
ConfigureAwait(false)guidance for library code.
💼 Need .NET consulting?
I'm the author of PollyAnalyzers and a suite of compile-time source generators (AutoWire, AutoMap.Generator) and 28+ Polly v8 resilience packages. I'm available for consulting on Polly v8 resilience, Azure cloud architecture, and clean .NET design.
→ solidqualitysolutions.com · LinkedIn
Also by the same author
🌐 Full suite overview: swevo.github.io
| Package | Description |
|---|---|
| FluentPdf | Free, MIT-licensed fluent PDF generation — alternative to QuestPDF's commercial license. |
| AutoBus | Free, MIT-licensed message bus — alternative to MassTransit's commercial license. |
| AutoArchitecture | Free, MIT-licensed compile-time architecture rule enforcement — alternative to NDepend. |
| AutoAssert | Free, MIT-licensed fluent assertions — alternative to FluentAssertions' commercial license. |
| AutoWire | Compile-time DI auto-registration — [Scoped]/[Singleton]/[Transient] generates IServiceCollection registration code. |
| PollyAction | Free retry/backoff GitHub Action — wrap any CI step with exponential-backoff retries. |
License
MIT © Justin Bannister
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.0.1: Add missing package icon. 1.0.0: Initial release. PLY001-PLY005 resilience/reliability analyzers with code fixes.