StyleBro.Analyzers 0.1.0-alpha.8

This is a prerelease version of StyleBro.Analyzers.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package StyleBro.Analyzers --version 0.1.0-alpha.8
                    
NuGet\Install-Package StyleBro.Analyzers -Version 0.1.0-alpha.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="StyleBro.Analyzers" Version="0.1.0-alpha.8">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StyleBro.Analyzers" Version="0.1.0-alpha.8" />
                    
Directory.Packages.props
<PackageReference Include="StyleBro.Analyzers">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add StyleBro.Analyzers --version 0.1.0-alpha.8
                    
#r "nuget: StyleBro.Analyzers, 0.1.0-alpha.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package StyleBro.Analyzers@0.1.0-alpha.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=StyleBro.Analyzers&version=0.1.0-alpha.8&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=StyleBro.Analyzers&version=0.1.0-alpha.8&prerelease
                    
Install as a Cake Tool

StyleBro

Roslyn analyzers and code fixes that keep C# code tidy. It's a modern alternative to StyleCop, built so that dotnet format fixes everything it reports.

StyleCop writes you a ticket. StyleBro just fixes it. Rule IDs use the BRO prefix.

Principles

  • Every rule has a code fix, and Fix All works. Fixes are written for dotnet format: deterministic, idempotent, and they converge in a single pass. CI checks this with a second dotnet format --verify-no-changes run.
  • Don't duplicate the SDK. If a built-in IDE rule already covers a StyleCop rule, the preset enables that rule instead of shipping a copy.
  • Configurable through .editorconfig, with a recommended preset shipped as a low-priority global config.

Rules

ID Title Replaces Fix
BRO1001 Members should be ordered SA1201-SA1204, SA1214 Yes, with custom Fix All
BRO1002 Single-line comments should begin with a space SA1005 Yes
BRO1003 Property accessors should follow order SA1212 Yes
BRO1004 Event accessors should follow order SA1213 Yes
BRO1005 Documentation lines should begin with single space SA1004 Yes
BRO1101 Code should not contain empty statements SA1106 Yes
BRO1102 Each attribute should be in its own brackets SA1133 Yes
BRO1103 Constants should be on the right-hand side of comparisons SA1131 Yes
BRO1104 Use default instead of a value type's default constructor SA1129 Yes
BRO1105 Constructor initializers should be on their own line SA1128 Yes
BRO1106 Use string.Empty for empty strings SA1122 Yes
BRO1107 Split parameters should start on the line after the declaration SA1116 Yes
BRO1108 Parameters should be on the same line or on separate lines SA1117 Yes
BRO1109 Opening parenthesis or bracket should be on the declaration line SA1110 Yes
BRO1110 Closing parenthesis or bracket should be on the line of the last item SA1111 Yes
BRO1111 Generic type constraints should be on their own line SA1127 Yes
BRO1112 Do not use regions (off in the preset) SA1124 Yes
BRO1113 Regions should not be placed inside code elements SA1123 Yes
BRO1114 Do not combine fields SA1132 Yes
BRO1115 Use shorthand for nullable types SA1125 Yes
BRO1116 Closing parenthesis should be on line of opening parenthesis SA1112 Yes
BRO1117 Comma should be on the same line as previous parameter SA1113 Yes
BRO1118 Parameter list should follow declaration SA1114 Yes
BRO1119 Parameter should follow comma SA1115 Yes
BRO1120 Comments should contain text SA1120 Yes
BRO1121 Enum values should be on separate lines SA1136 Yes
BRO1122 Use literal suffix notation instead of casting SA1139 Yes
BRO1123 Use tuple syntax SA1141 Yes
BRO1124 Refer to tuple elements by name SA1142 Yes
BRO1125 Use lambda syntax SA1130 Yes
BRO1126 Using directives should be qualified SA1135 Yes
BRO1301 Variable names should begin with a lower-case letter SA1312 Yes
BRO1302 Parameter names should begin with a lower-case letter SA1313 Yes
BRO1303 Private field names should be camelCase SA1306, SA1309 Yes
BRO1304 Interface names should begin with I SA1302 Yes
BRO1305 Type parameter names should begin with T SA1314 Yes
BRO1306 Constant, static readonly and non-private field names should be PascalCase SA1303, SA1304, SA1307, SA1311 Yes
BRO1307 Field names should not begin with a prefix SA1308 Yes
BRO1308 Field names should not contain an underscore SA1310 Yes
BRO1309 Element names should begin with an upper-case letter SA1300 Yes
BRO1401 Use a trailing comma in multi-line initializers SA1413 Yes
BRO1402 Attribute constructor should not use unnecessary parenthesis SA1411 Yes
BRO1403 Remove delegate parenthesis when possible SA1410 Yes
BRO1601 Overrides and implementations should inherit their documentation SA1600 (these members) Yes
BRO1602 Single-line comments should not use documentation style slashes SA1626 Yes
BRO1603 Documentation text should end with a period SA1629 Yes
BRO1604 Property summary documentation should match accessors SA1623 Yes
BRO1605 Property summary documentation should omit accessor with restricted access SA1624 Yes
BRO1606 Constructor summary documentation should begin with standard text SA1642 Yes
BRO1607 Destructor summary documentation should begin with standard text SA1643 Yes
BRO1608 Void return value should not be documented SA1617 Yes
BRO1609 Do not use placeholder elements SA1651 Yes
BRO1610 Documentation text should not be empty SA1627 Yes
BRO1611 Element parameter documentation should match element parameters SA1612 Yes
BRO1612 Element parameter documentation should declare parameter name SA1613 Yes
BRO1613 Generic type parameter documentation should match type parameters SA1620 Yes
BRO1614 Generic type parameter documentation should declare parameter name SA1621 Yes
BRO1615 File should have the XML copyright header (needs stylebro_file_header_company) SA1633-SA1638, SA1640, SA1641 Yes
BRO1501 Opening braces should not be preceded by a blank line SA1509 Yes
BRO1502 Chained blocks should not be preceded by a blank line SA1510 Yes
BRO1503 Opening braces should not be followed by a blank line SA1505 Yes
BRO1504 Single-line comments should be preceded by a blank line SA1515 Yes
BRO1505 Elements should be separated by a blank line SA1516 Yes
BRO1506 Single-line comments should not be followed by a blank line SA1512 Yes
BRO1507 Files should not end with blank lines SA1518 Yes
BRO1508 A block should not be on a single line SA1501 Yes
BRO1509 An element should not be on a single line SA1502 Yes
BRO1510 Accessors should all be single-line or all multi-line SA1504 Yes
BRO1511 Element documentation headers should not be followed by blank line SA1506 Yes
BRO1512 While-do footer should not be preceded by blank line SA1511 Yes
BRO1513 Element documentation header should be preceded by blank line SA1514 Yes

How every StyleCop rule maps to StyleBro or the SDK: docs/stylecop-mapping.md. The rules StyleBro doesn't cover, why, and what it would take to add them: docs/skipped-rules.md. Where the preset and the rules differ from StyleCop's defaults, and how to get StyleCop's behavior back: docs/differences-from-stylecop.md.

Usage

<PackageReference Include="StyleBro.Analyzers" Version="0.1.0-alpha.8" PrivateAssets="all" />
dotnet format                      # whitespace + style + analyzers, including StyleBro
dotnet format analyzers --diagnostics BRO1001

To opt out of the preset and configure everything yourself: <StyleBroPreset>none</StyleBroPreset>.

Migrating from StyleCop

stylebro-migrate reads a repository's StyleCop setup (rulesets, global configs, .editorconfig files, stylecop.json) and writes matching StyleBro and SDK settings into its .editorconfig files, so the switch doesn't reformat code StyleCop was happy with. It also carries #pragma warning disable SA… and [SuppressMessage] suppressions over to the replacing rules, and lists the StyleCop rules nothing enforces any more. dotnet tool install --global StyleBro.Migrate --prerelease, then stylebro-migrate path/to/repo. See docs/migrating.md.

Baseline: fail only on new violations

In a codebase with many existing violations, stylebro-migrate baseline records them in stylebro.baseline. The build, the IDE and dotnet format then ignore those (every StyleBro rule and the SDK rules the preset turns on), so only new code has to follow the rules; a violation counts as new once its line is edited. See docs/baseline.md.

Repository layout

src/StyleBro.Analyzers     netstandard2.0, Microsoft.CodeAnalysis.CSharp only (no Workspaces, RS1038)
src/StyleBro.CodeFixes     netstandard2.0, code fixes + Fix All providers
src/StyleBro.Package       packs both DLLs into analyzers/dotnet/cs + build/ preset
src/StyleBro.Migrate       stylebro-migrate: StyleCop setup -> .editorconfig settings
tests/StyleBro.Tests       Microsoft.CodeAnalysis.Testing: diagnostics, single fix, Fix All, idempotence
samples/Messy           dotnet format integration sample (Input -> Expected)
scripts/verify-format.ps1

Developing

dotnet test tests/StyleBro.Tests
pwsh scripts/verify-format.ps1
dotnet pack src/StyleBro.Package -c Release -o artifacts

Roslyn is pinned to 4.8.0 so the package loads in the .NET 8 SDK / VS 17.8 and newer.

Roadmap

  1. More StyleCop rules with safe fixes (the candidates in docs/skipped-rules.md)
  2. Baseline support (docs/baseline.md)
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has 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.

Version Downloads Last Updated
0.7.0-alpha.1 1,433 10/13/2026
0.6.0-alpha.1 81 10/12/2026
0.5.0-alpha.1 4,389 10/10/2026
0.4.0-alpha.1 81 10/10/2026
0.3.0-alpha.1 80 10/9/2026
0.2.0-alpha.1 122 10/6/2026
0.1.0-alpha.8 251 10/2/2026
0.1.0-alpha.7 56 10/2/2026
0.1.0-alpha.6 48 10/1/2026
0.1.0-alpha.5 62 10/1/2026
0.1.0-alpha.4 52 10/1/2026
0.1.0-alpha.3 53 9/30/2026
0.1.0-alpha.2 53 9/30/2026
0.1.0-alpha.1 56 9/30/2026