Repository navigation
Releases
1.3.180
This is the first stable StyleCop.Analyzers release since 1.1.118. It includes the entire 1.2 beta line and the 1.3 revival: the analyzers now understand C# 8 through the C# 15 previews, many long-standing bugs are fixed, and the project is once again actively maintained. Thank you to everyone who contributed code, reviews, translations and bug reports over the long gap.
Highlights
- C# 8 through C# 15 language support. Rules now understand records and record structs, file-scoped namespaces, global usings, raw and interpolated strings, primary constructors, collection expressions, partial properties, events and constructors,
allows ref struct, C# 14 extension blocks and thefieldkeyword, and C# 15 preview unions with theclosedandsafemodifiers, instead of ignoring that syntax or crashing on it. (#4142, #4139, #4137, #4163, #4148, #4191, #4193) - New rules. SA1143 checks that wrapped conditional (
?:) expressions are laid out consistently, SA1315 requires overriding and implementing parameters to keep their inherited names, SA1317 reports identifiers that use letters outside basic Latin A–Z, SA1653 reports<summary>documentation on more than one part of a partial type, and SA1654 reports escaped generic brackets increfs (for exampleList<T>vsList{T}). SX1412 is an opt-in alternative to SA1412 that requires UTF-8 without a BOM. All of these except SX1412 are on by default as warnings. (#3942, #4299, #4318, #4314, #4315, #4328) - Better code fixes. The member-ordering rules (SA1201, SA1202, SA1203, SA1204 and SA1214) now offer their code fix, including Fix All. Many other rules gained fixes, and existing fixes keep comments, trivia, custom indentation and the document's line endings, and use the compiler's batch Fix All. (#4312, #4076, #4199, #4108, #4229, #4360)
- More configuration. Every setting can be set in
.editorconfig. New settings includeorderingRules.memberKindOrder,orderingRules.accessibilityOrderandlayoutRules.allowBracelessIfStatements(bracelessifs are off by default; the accessibility order default is unchanged). (#4221, #3285, #4324, #4359, #4319) - Fewer false positives and crash fixes. A long backlog of spacing, layout, documentation, naming and maintainability issues was cleared, including several crashes and incorrect code fixes found by fuzzing.
- Localization and documentation. This release adds Simplified Chinese (
zh-CN) resources and documentation, finishes the Czech translations, and includes more translations of code-fix documentation text (Czech, Dutch, Russian and others). Rule documentation and status are published on GitHub Pages. (#4285, #4286, #3374, #3944, #3900, #4220, #4218) - Packaging and engineering. The package has an icon and a README, and PDBs are embedded in the DLLs (there is no separate symbols package). Packages are published from GitHub Actions using nuget.org trusted publishing. CI runs on GitHub Actions on Linux, the build uses the .NET 10 SDK, and Renovate keeps dependencies current. The analyzers still target the same Roslyn version, so they work with the same compilers and IDEs as before. (#4320, #4204, #4173, #4123, #4105, #4126, #4231)
Behavior changes worth knowing about
Upgrading from 1.1.118, or from a 1.2 beta, may produce new or different diagnostics:
- Rules now cover newer syntax. Ordering, layout, spacing and documentation rules now analyze records, primary constructors, collection expressions, extension blocks, unions and other newer constructs. They used to skip these, so expect new warnings in code that uses them.
- New rules on by default: SA1143, SA1315, SA1317, SA1653 and SA1654 are enabled as warnings. SX1412 is off by default.
- Extension members need documentation. SA1600 no longer treats C# 14 extension blocks as private, so their public members must be documented. SA1600 also reports undocumented record primary constructor parameters. (#4163, #4213)
- Partial types and members. For partial methods, properties, indexers, constructors, events and types, documenting one part is enough (SA1600 leaves the check for partial members to SA1601). SA1653 reports a
<summary>on more than one part, but ignores generated partial declarations such as WPF*.g.csfiles. (#4148, #4149, #4152, #4308, #4299, #4393) - SA1500 and SA1137 now check the brackets of multi-line collection expressions. SA1137 accepts aligning a closing bracket with an inline opening bracket (one that follows other code on the same line) or with the opening line's indentation. Both rules offer an alternate, tab-aware code fix that aligns the closing bracket with the opening bracket. (#4396, #4400)
- SA1642 expects "union" wording in constructor summaries of C# 15 union types, for example "Initializes a new instance of the … union.", and "interface" rather than "class" in the standard text for static constructors in interfaces. (#4193, #4386)
- SA1121 reports the built-in type inside a using alias target instead of every use of the alias, and no longer reports
IntPtrandUIntPtrin XML documentationcrefs, or in shared source compiled for targets wherenintisn't equivalent. SA1121 and SA1125 also report System types in using alias targets. (#4287, #4395, #4175) - SA1316 always reports explicitly written tuple element names, even when
includeInferredTupleElementNamesis off. (#4202) - SA1312 no longer reports
_forforeachvariables andusingdeclarations. (#4203) - SA1205 treats the
filemodifier as an access modifier. (#4198) - SA1304 now analyzes
protected readonlyfields when SA1307 is enabled. (#4217) - SA1122 reports empty interpolated and raw string literals, and SA1130 reports anonymous methods whose parameter names differ from the delegate's. (#4178, #4179)
- SA1407 now checks bitwise operators (
&,|,^) and>>>. SA1408 reports??mixed with&&or||without parentheses. (#4289, [#4323](https://github.com/DotNe...
1.3.177-beta
A small follow-up to 1.3.171-beta. It accepts a common layout for collection-expression brackets and strengthens the settings default tests.
Highlights
- Inline collection bracket alignment. SA1137 now accepts aligning a collection expression's closing bracket with an opening bracket that follows code on the same line, and both SA1137 and SA1500 offer an alternate fix that preserves that layout. (#4400)
Behavior changes worth knowing about
- SA1137 no longer reports when a multi-line collection expression's closing bracket is aligned with an inline opening bracket (one that follows other code on the same line). Aligning with the opening line's indentation remains accepted. Both SA1137 and SA1500 now offer an alternate code fix that aligns the closing bracket with the opening bracket, with tab-aware column checks. (#4400, fixes #4399)
All changes
Fixes
Infrastructure and build
- Improve settings tests slightly by @bjornhellander in #4397
Full Changelog: 1.3.171-beta...1.3.177-beta
1.3.171-beta
A reliability-focused follow-up to 1.3.151-beta. It fixes several crashes and broken code fixes, checks the layout of multi-line collection expressions, and reduces false positives in SA1121, SA1143 and SA1653.
Highlights
- Crash and code fix fixes. These cover a crash in SA1627/SA1651 on
<include>, crashes and an infinite loop in SA1500 and its code fix, crashes in the SA1642 and using-directive code fixes, and a using code fix that rewrote a non-genericSystem.ValueTuplealias. (#4380, #4383, #4382, #4384, #4381, #4385) - Collection expression layout. SA1500 and SA1137 now check the brackets of multi-line collection expressions. (#4396)
- Fewer false positives. SA1121 keeps
IntPtrandUIntPtrwherenintandnuintwould be wrong, SA1653 ignores generated partial declarations such as WPF*.g.csfiles, and the SA1143 fix keeps multi-line branches intact. (#4395, #4393, #4392)
Behavior changes worth knowing about
- SA1500 now checks multi-line collection expressions, and SA1137 checks the alignment of their closing bracket. Expect new warnings where a closing
]shares a line with the last element. (#4396) - SA1642 expects "interface" rather than "class" in the standard text for static constructors in interfaces, for example "Initializes static members of the … interface." (#4386)
- SA1121 no longer reports
IntPtrandUIntPtrin XML documentationcrefs, or in shared source compiled for targets wherenintisn't equivalent. (#4395) - SA1653 ignores
<summary>tags in generated partial declarations. (#4393)
All changes
Fixes
- Fix collection expression bracket layout in SA1500 and SA1137 by @AArnott in #4396
- SA1121: Preserve native integer compatibility in crefs and linked targets by @AArnott in #4395
- SA1653: Ignore summary tags in generated partial declarations by @AArnott in #4393
- Fix SA1627/SA1651 crash on with no documented member by @AArnott in #4380
- Fix SA1500 NRE on a top-level block at the start of a file by @AArnott in #4383
- Fix SA1500 code fix infinite loop on unmatched braces by @AArnott in #4382
- Fix SA1642 code fix for static constructors in generic interfaces by @AArnott in #4384
- Fix NRE in using code fix when qualifying alias-any-type usings by @AArnott in #4381
- Fix using code fix rewriting non-generic System.ValueTuple alias by @AArnott in #4385
- Use 'interface' in SA1642 standard text for interface static constructors by @AArnott in #4386
- SA1143: Preserve multiline branches when aligning closing delimiters by @AArnott in #4392
Infrastructure and build
- Update dotnet monorepo by @renovate[bot] in #4387
- Update dependency Microsoft.CodeAnalysis.Analyzers to 5.11.0-1.26521.10 by @renovate[bot] in #4347
- Update dependency Microsoft.CodeAnalysis.Analyzers to 5.11.0-1.26525.1 by @renovate[bot] in #4379
- Update actions/setup-dotnet action to v6.1.0 by @renovate[bot] in #4394
- Update dependency node to v26 by @renovate[bot] in #4389
- Update dependency dotnet-reportgenerator-globaltool to v5.5.12 by @renovate[bot] in #4388
Full Changelog: 1.3.151-beta...1.3.171-beta
1.3.151-beta
A small follow-up to 1.3.149-beta. SA1143 now accepts conditional expressions whose condition spans several lines.
Behavior changes worth knowing about
- SA1143 no longer reports an expanded conditional expression whose condition spans several lines, as long as the
?and:lines line up and are indented past the condition's last line. The code fix still flattens the condition onto one line. (#4374)
Fixes
Infrastructure and build
- Upgrade c# 15 test project to use prerelease 5.11.x now that Visual Studio 18.11 is out by @bjornhellander in #4373
Full Changelog: 1.3.149-beta...1.3.151-beta
1.3.149-beta
A follow-up to 1.3.133-beta, centered on code fixes: five rules that only reported problems now offer fixes, and code fixes keep the document's line endings. SA1202 also gets a configurable accessibility order. Thanks to @bjornhellander for moving the repo itself onto the latest StyleCop.Analyzers.
Highlights
- New code fixes for SA1117 (put each parameter on its own line), SA1114 (remove blank lines after the opening delimiter), SA1612 (reorder and complete
<param>tags) and SA1653 (keep one partial<summary>, converting the others to<content>or removing duplicates). The SA1314 rename now also updates type parameter references increfs. (#4353, #4352, #4354, #4372, #4361) - Line endings preserved. Code fixes that insert or move lines follow the document's existing newline sequence instead of mixing CRLF and LF. (#4360)
- Configurable SA1202 order. The new
orderingRules.accessibilityOrdersetting, orstylecop.ordering.accessibilityOrderin EditorConfig, customizes the accessibility order. The default is unchanged. (#4359)
Behavior changes worth knowing about
- SA1114 no longer reports the first item when only conditional compilation directives separate it from the opening delimiter. (#4356)
- SA1009 no longer reports a multi-line tuple whose opening and closing parentheses are each on their own line. (#4358)
- SA1653's message now mentions removing duplicate summaries as well as using
<content>. (#4372) - Older compilers and IDEs: light-up fallbacks for newer base syntax types were fixed, which may change results on older Roslyn hosts. (#4357)
All changes
Enhancements
- SA1117: Add a code fix for inconsistent parameter lines by @AArnott in #4353
- SA1114: Add code fix for blank lines after opening delimiter by @AArnott in #4352
- SA1612: add parameter documentation code fix by @AArnott in #4354
- SA1653: add code fix for partial summaries by @AArnott in #4372
- SA1202: Add configurable accessibility ordering by @AArnott in #4359
- SA1314: Rename type parameters in documentation crefs by @AArnott in #4361
Fixes
- Preserve document line endings in code fixes by @AArnott in #4360
- SA1114: Allow conditional directives before list items by @AArnott in #4356
- SA1009: Allow multiline tuple parenthesis layout by @AArnott in #4358
- Fix light-up fallbacks for base syntax types by @AArnott in #4357
Documentation
Infrastructure and build
- Upgrade StyleCop.Analyzers and fix warnings by @bjornhellander in #4371
- Use CommonData.EndOfLineSequences for line ending theories by @bjornhellander in #4366
- Update becheran/mlc action to v1.3.0 by @renovate[bot] in #4370
Full Changelog: 1.3.133-beta...1.3.149-beta
1.3.133-beta
A follow-up to 1.3.109-beta. It fixes how SA1600 handles the documentInterfaces setting, fixes several crashes and code-fix bugs found by fuzzing, and adds a code fix for SA1648. Thanks to @sbe-schleupen for the SA1135 fix, their first contribution.
Highlights
- SA1600 interface documentation settings.
documentInterfacesadds to the general accessibility settings again, as it originally did, and"exposed"now uses each interface's effective accessibility. (#4346, #4343) - Robustness. Fuzzing turned up crashes and incorrect code fixes, including a SA1003 crash on incomplete code and a SA1316 rename that missed references. These are fixed. (#4344)
- Code fixes and messages. SA1648 has a new code fix that removes an invalid
<inheritdoc/>, and SA1315's message now names the expected parameter name. (#4337, #4351)
Behavior changes worth knowing about
- SA1600 with
documentInterfaces: falseagain requires documentation on public interfaces and their members whendocumentExposedElementsis on. Earlier 1.3 betas had stopped requiring it, so warnings may come back. (#4346) - SA1600 with
documentInterfaces: "exposed"no longer reports members of interfaces that aren't actually exposed, such as internal interfaces whendocumentInternalElementsis false, or nested interfaces inside non-public types. (#4343) - SA1135 no longer reports using directives that start with an
extern alias. (#4341) - SA1315's diagnostic message now includes the expected name or names. (#4351)
All changes
Fixes
- SA1600: Restore additive interface documentation settings by @AArnott in #4346
- SA1600: Respect effective accessibility in exposed interface documentation by @AArnott in #4343
- SA1135: Using directives should be qualified occurs with external alias by @sbe-schleupen in #4341
- Fix crashes and code fixes found by syntax fuzzing by @AArnott in #4344
Enhancements
- SA1648: Add code fix to remove invalid inheritdoc by @AArnott in #4337
- SA1315: Include expected parameter names in diagnostics by @AArnott in #4351
Infrastructure and build
- Add a local fuzz harness for analyzers and code fixes by @AArnott in #4350
- Fix VB roslyn package dependency version by @AArnott in #4349
New Contributors
- @sbe-schleupen made their first contribution in #4341
Full Changelog: 1.3.109-beta...1.3.133-beta
1.3.109-beta
A follow-up to 1.3.98-beta. It eases several layout rules that were too strict, including the new SA1143, adds a rule for generic cref syntax, and improves code fixes. Thanks to @bgrainger for the SA1143 fix, their first contribution.
Highlights
- Fewer false positives. SA1143 allows branches that continue onto more lines. SA1118 allows multi-line string and switch-expression arguments. SA1500 and SA1513 allow an operator such as
??right after a switch expression's closing brace. (#4336, #4331, #4333, #4334) - New rule SA1654 reports escaped generic brackets in XML documentation
crefs, for exampleList<T>, and its code fix converts them toList{T}. (#4328) - Code fixes. SA1115 has a new code fix, SA1003's Fix All edits each document in one pass, and the SA1501 fix no longer crashes at the end of a file. (#4326, #4329, #4327)
Behavior changes worth knowing about
- New rule on by default: SA1654 (use
{T}rather than escaped<T>increfattributes) is enabled as a warning. (#4328) - Fewer diagnostics from SA1143, SA1118, SA1500 and SA1513 in the cases described above. (#4336, #4331, #4333, #4334)
All changes
Enhancements
- SA1654: encode generic brackets in cref by @AArnott in #4328
- Implement a code fix for SA1115 by @AArnott in #4326
- SA1003: batch Fix All edits per document by @AArnott in #4329
Fixes
- Allow multiline conditional expressions by @bgrainger in #4336
- SA1118: Allow multiline string arguments by @AArnott in #4331
- SA1118: Allow multiline switch expressions with single-line headers by @AArnott in #4333
- SA1500/SA1513: Allow continuations after switch expression closing braces by @AArnott in #4334
- SA1501: Handle code fixes at end of file by @AArnott in #4327
New Contributors
- @bgrainger made their first contribution in #4336
Full Changelog: 1.3.98-beta...1.3.109-beta
1.3.98-beta
This release adds three new rules and a long-requested code fix, makes member ordering and braceless guard clauses configurable, and tightens several existing rules. The package also has an icon now.
Highlights
- New rules. SA1143 checks that wrapped conditional (
?:) expressions are laid out consistently. SA1315 checks that overriding and implementing parameters keep their inherited names. SX1412 is an opt-in alternative to SA1412 that requires UTF-8 without a BOM. All three come with code fixes. (#4318, #4314, #4315) - Member-ordering code fix enabled. SA1201, SA1202, SA1203, SA1204 and SA1214 now offer their code fix, including Fix All. It had been turned off until it was stable. (#4312)
- More configuration. The new
orderingRules.memberKindOrdersetting customizes the SA1201 member-kind order, andlayoutRules.allowBracelessIfStatementslets SA1501 and SA1503 allow compact guard clauses. Both are off by default. (#4324, #4319) - Package icon. NuGet now shows the StyleCop.Analyzers icon. (#4320)
Behavior changes worth knowing about
- New rules on by default: SA1143 (conditional expression formatting, #4318) and SA1315 (parameter names must match inherited names, #4314) are enabled as warnings. SX1412 is off by default.
- SA1200 now reports and moves
extern aliasdirectives using the same placement setting asusingdirectives. (#4313) - SA1017 now requires a space after a parameter's or type parameter's attribute list, for example
[NotNullWhen(true)] out string? foo. (#4321) - SA1408 now reports
??mixed with&&or||without parentheses. (#4323) - SA1649 picks the type that names the file according to the
maintainabilityRules.topLevelTypessetting, so the expected file name may change. (#4316)
All changes
Enhancements
- SA1143: Format conditional expressions consistently by @AArnott in #4318
- SA1315: Match inherited parameter names by @AArnott in #4314
- SX1412: Add UTF-8 without BOM rule by @AArnott in #4315
- Enable element order code fix provider by @AArnott in #4312
- SA1201: support configurable member-kind ordering by @AArnott in #4324
- SA1501/SA1503: Allow configurable braceless if guards by @AArnott in #4319
- Adopt proposed StyleCop.Analyzers icon by @AArnott in #4320
Fixes
- SA1200: Treat extern alias directives like using directives by @AArnott in #4313
- SA1017: Require spacing after parameter attributes by @AArnott in #4321
- SA1408: Include null-coalescing precedence by @AArnott in #4323
- SA1649: Respect top-level type settings by @AArnott in #4316
Documentation
Full Changelog: 1.3.82-beta...1.3.98-beta
1.3.82-beta
A small follow-up to 1.3.79-beta. The SA1504 code fix no longer drops comments or blank lines when it expands accessors onto multiple lines. The documentation's opening pages have also been reorganized. No diagnostics change in this release.
Fixes
Documentation
Full Changelog: 1.3.79-beta...1.3.82-beta
1.3.79-beta
This release follows 1.3.18-beta with two new rules, a round of fixes for long-standing false positives, and better code fixes. It also adds Simplified Chinese resources and documentation. Thanks to @melomory for contributing SA1317, their first contribution to the project.
Highlights
- Two new rules, both on by default. SA1317 reports identifiers that use letters outside basic Latin A–Z, which can hide look-alike characters, and SA1653 reports partial types that have
<summary>documentation on more than one part. (#3942, #4299) - Fewer false positives. SA1501 now allows empty
catchandfinallyblocks, SA1118 allows multi-line tuple arguments, SA1629 accepts!and?, and SA1515 and SA1005 ignore tool marker comments such as ReSharper, language injection andNOSONAR. SA1305 skipsDllImportparameters, and SA1402 and SA1649 accept supporting types in files with top-level statements. (#4290, #4284, #4298, #4302, #4297, #4306) - Better code fixes. SA1201 Fix All finishes in one pass, the SA1503 fix respects custom indentation, the SA1003 fix keeps constructor initializer line breaks, and the SA1402 fix removes unneeded usings from the files it creates. (#4277, #4294, #4280, #4307)
- Localization. This release adds Simplified Chinese (
zh-CN) resources and documentation, and finishes the Czech translations. (#4285, #4286)
Behavior changes worth knowing about
- New rules: SA1317 (Latin-only identifiers, #3942) and SA1653 (only one partial part should have a
<summary>, #4299) are both enabled by default as warnings. Codebases with non-Latin identifiers, or with summaries on several parts of a partial type, will see new diagnostics. - SA1601 now requires documentation on only one part of a partial type, matching how partial members already work. (#4308)
- SA1121 now reports on the built-in type inside a using alias target instead of on every use of the alias, so a deliberate alias no longer flags each usage. (#4287)
- SA1407 now checks bitwise operators (
&,|,^) and>>>, so mixed-precedence expressions using them get new diagnostics. (#4289) - SA1633: disabling one required-header rule, for example SA1637, no longer turns off the other header checks, so those checks may now report. (#4276)
- SA1202 treats explicit interface events as public, like other explicit interface members. (#4281)
- SA1137 now aligns type members to their most common indentation instead of to the first member. (#4301)
- Fewer diagnostics from SA1501, SA1118, SA1629, SA1515/SA1005, SA1305, SA1402/SA1649 and SA1642 (langword markup), as described above. (#4290, #4284, #4298, #4302, #4297, #4306, #4282)
- SA1625 has a new name and message that describe duplicate documentation accurately. Its rule ID is unchanged. (#4291)
All changes
Enhancements
- Implement a new rule SA1317 by @melomory in #3942
- SA1653: Detect conflicting summary documentation on partial types by @AArnott in #4299
- SA1121: report using alias targets by @AArnott in #4287
- SA1407: Cover bitwise and unsigned shift operators by @AArnott in #4289
- SA1201: fix all member ordering in one pass by @AArnott in #4277
- SA1402: Remove unused usings from extracted files by @AArnott in #4307
- SA1141: Use IOperation for expression analysis by @AArnott in #4292
- Add Simplified Chinese resources and documentation by @AArnott in #4285
- Translate remaining Czech documentation text by @AArnott in #4286
Fixes
- SA1601: only require documentation on one part of a partial type by @AArnott in #4308
- SA1633: Keep other header checks active for optional headers by @AArnott in #4276
- SA1501: Allow empty catch and finally blocks by @AArnott in #4290
- SA1118: Allow multiline tuple arguments by @AArnott in #4284
- SA1629: accept exclamation and question marks by @AArnott in #4298
- SA1515: Exclude tool marker comments by @AArnott in #4302
- SA1305: Skip DllImport parameter names by @AArnott in #4297
- SA1402/SA1649: Handle files with top-level statements by @AArnott in #4306
- SA1202: Order explicit interface events as public by @AArnott in #4281
- SA1137: Choose common indentation for type members by @AArnott in #4301
- SA1642: Allow langword markup in constructor standard text by @AArnott in #4282
- SA1504: handle expression-bodied accessors by @AArnott in #4283
- SA1003: Preserve constructor initializer line breaks in code fix by @AArnott in #4280
- SA1503: respect custom indentation in code fix by @AArnott in #4294
- SA1625: Describe duplicate documentation accurately by @AArnott in #4291
Documentation
- Document rule category names by @AArnott in #4295
- Clarify SA1200 using placement for file-scoped namespaces by @AArnott in #4288
- Clarify SA0001 documentation analysis limitations by @AArnott in #4279
- Improve rule page titles and remove redundant metadata tables by @AArnott in #4278
Infrastructure and build
- Enable nullable analysis throughout sources and annotate light-up APIs by @AArnott in #4300
- Add nullability lightup APIs by @AArnott in #4293
- Use stronger
-warnAsErrorexcept for NuGet warnings by @AArnott in #4304 - Use async Task Main in StyleCopTester by @AArnott in #4296
- Update dependency dotnet-sdk to v10.0.402 by @renovate[bot] in #4245
- Update dependency System.Security.Cryptography.Pkcs to v10 by @renovate[bot] in #4303
New Contributors
Full Changelog: 1.3.18-beta...1.3.79-beta