This 1.4-beta follows 1.4.26-beta. It adds three new rules, an opt-in name-ordering trait for SA1201, a multi-targeting compatibility option for SA1121, an ASP.NET exemption for SA1415, and a crash fix for SA1648 that was forwarded from the v1.3 servicing branch.
Highlights
- SA1144 (
ZeroWidthCharactersInLiteralsMustBeEscaped) reports U+200B, U+2060, and U+FEFF when they appear unescaped in string, character, UTF-8 string, and interpolated string literals (including interpolation format clauses). The rule is enabled by default as a warning. A code fix replaces each character with its escape sequence where the literal syntax allows it; a second fix removes the characters. U+200C and U+200D are not reported. (#4435, fixes #3429) - SA1145 (
DoNotUseAssignmentAsCondition) reports an assignment used as a condition (if,while,do,for,?:,when) or as an operand of&&,||, or!. Compared assignments such as(line = reader.ReadLine()) != nullare not reported. The rule is enabled by default as a warning. There is no code fix. (#4436, fixes #862) - SA1655 (
DocumentationElementTagsMustBeConsistentlyPlaced) requires that for every XML documentation element, the opening and closing tags are either both on lines by themselves or neither is. The rule is enabled by default as a warning. There is no code fix. (#4438, fixes #747) - SA1648 no longer throws
NullReferenceException(AD0001) on a documented static constructor of an interface. A<summary>is accepted;<inheritdoc/>is reported because there is nothing to inherit from. (#4430, forwarded in #4441) - SA1415 no longer reports methods decorated with an attribute derived from
HttpMethodAttribute([HttpGet],[HttpPost], …), because making those methodsinternalwould stop ASP.NET Core from discovering the action. (#4442, fixes #4439) - SA1201 can optionally sort equally ranked members by name. Append
nametostylecop.ordering.elementOrder(orsettings.orderingRules.elementOrderinstylecop.json). The default trait list is unchanged. (#4431) - SA1121 gains
compatibility.multiTargetsLegacyFrameworks(stylecop.jsonorstylecop.compatibility.multiTargetsLegacyFrameworksin EditorConfig). When true, SA1121 no longer reportsIntPtr/UIntPtr. A code fix can set the option in an existing settings file when the project multi-targets a legacy framework. (#4443)
Behavior changes worth knowing about
- SA1144, SA1145, and SA1655 are enabled by default as warnings and may appear in existing projects.
- SA1415 no longer reports
publicmethods on internal types when the method has anHttpMethodAttribute. - SA1648 reports
<inheritdoc/>on an interface static constructor instead of crashing. - SA1201 name ordering is off unless you add the
nametrait. - SA1121 still reports
IntPtr/UIntPtrunlesscompatibility.multiTargetsLegacyFrameworksis set.
All changes
New rules
- Add SA1144: zero-width characters in literals must be escaped by @AArnott in #4435
- Add SA1145: Do not use assignment as condition by @AArnott in #4436
- Add SA1655: documentation element tags must be consistently placed by @AArnott in #4438
Enhancements
- SA1201: Add opt-in member ordering by name by @vossnc in #4431
- SA1121: Add multiTargetsLegacyFrameworks option and code fix by @AArnott in #4443
- SA1415: Don't report HttpMethodAttribute-decorated methods by @AArnott in #4442
Fixes
- SA1648: Don't crash on a documented static constructor of an interface by @richardcocks in #4430
Infrastructure and build
- Merge v1.3 into master by @AArnott in #4441
- Remove unused AnalyzerReleases files by @AArnott in #4437
- Re-run pull request validation when the base branch changes by @AArnott in #4433
- Update dependency dotnet-reportgenerator-globaltool to v5.6.1 by @app/renovate in #4434
New Contributors
- @vossnc made their first contribution in #4431
- @richardcocks made their first contribution in #4430
Full Changelog: 1.4.26-beta...1.4.47-beta