-
Notifications
You must be signed in to change notification settings - Fork 29
Roslyn Conventions
Roslyn conventions leverage roslyn diagnostic analyzers to analyze the code that makes up a codebase in a syntax-tree format, as opposed to Solution conventions which work with the raw text that comprises the solution.
All roslyn conventions derive from SolutionDiagnosticAnalyzerConventionSpecification
Roslyn conventions are available in a separate package to keep the dependency weight of Best.Conventional to a minimum. To access the Roslyn conventions, or build your own, you will need to
Install-Package Best.Conventional.Roslyn
Roslyn-based conventions need to know what solution they will be working with, and this can be set in one of two ways. The first is to simply set your solution root, and let Conventional do a recursive search from there for the first .sln file it can find
KnownPaths.SolutionRoot = @"c:\projects\MySolutionRoot"
The other option, if you happen to have a slightly more complex composition, is to set the full path to the solution like so
KnownPaths.FullPathToSolution = @"c:\projects\MySolutionRoot\MySolution.sln"
ThisCodebase
.MustConformTo(RoslynConvention.IfAndElseMustHaveBraces)
.WithFailureAssertion(Assert.Fail);
- If and Else must have braces
- Using statements must not be nested