Analyzers
The Roslyn rules that ship inside Waystone.Monads, what each tier means, and how to turn a rule up or off.
What this page is for
Waystone.Monads ships a Roslyn analyzer inside the package. Install or upgrade to 7.0.0 and you get these rules. You add no reference and configure nothing.
Every rule has an ID like WM1002. The first digit tells you how much it matters:
Warnings show up in your build. Suggestions show up in your IDE only, so they never break a build that passes today. The WM3xxx rules stay off until you enable them.
The WMS rules ship in the Waystone.Monads.Shouldly package, which you install in test projects only. They are not in the core package.
A separate set of diagnostics uses a WMG prefix. Those come from the source generator rather than the analyzer, they are all errors, and they only fire on an enum you marked with [ErrorCodeCatalog]. They are on Source generation instead.
Do you build with TreatWarningsAsErrors? Then a WM1xxx rule that fires breaks your build after you upgrade. We chose that on purpose. Every one of these rules marks code that throws or returns the wrong value at run time. Read the rule before you suppress it.
Every rule
The id space has gaps. WM1004, WM1007, WM1009, WM1010 and WM2014 shipped in 5.x and were removed in 6.0.0. WM2010 was removed in 7.0.0. A removed id is never reused.
Changing a rule
You configure every rule through .editorconfig, the standard way. Raise one:
Silence one:
Silence one at a single line:
Put an .editorconfig in a subdirectory to scope a rule to part of your solution. Test projects are the common case. WM2001 earns its keep less in a test, where an unwrap that throws fails the test anyway.
You cannot drop the analyzer and keep the library, because both ship in one package. .editorconfig is how you turn rules off.
To raise a whole tier rather than a rule at a time, see Severity presets. One MSBuild property covers the set.
The WMS rules configure the same way, through dotnet_diagnostic.WMS2001.severity and the like. You can drop those entirely by removing the Waystone.Monads.Shouldly package reference, since the analyzer ships with it — which you cannot do for the WM rules, because they ship inside the library.
Last updated
Was this helpful?