Skip to content

Remove the discarded message argument of MA0080 - #1509

Merged
meziantou merged 1 commit into
mainfrom
feature/ma0080-properties-analyzeloop-75511a
Sep 12, 2026
Merged

meziantou merged 1 commit into
mainfrom
feature/ma0080-properties-analyzeloop-75511a

Conversation

@meziantou

Copy link
Copy Markdown
Owner

What changed

One line in UseAnOverloadThatHasCancellationTokenAnalyzer.AnalyzeLoop: MA0080 (FlowCancellationTokenInAwaitForEachRule) no longer passes string.Join(", ", availableCancellationTokens) as a message argument.

Why

The argument was already being discarded:

  • In that branch availableCancellationTokens is always empty (it is the else of if (availableCancellationTokens.Length > 0)), so the join always produced "".
  • The rule's messageFormat is "Specify a CancellationToken" — no {0} placeholder — so the argument was formatted into nothing.

Notes for the reviewer

This is a cleanup, not a bug fix, and no test changes because nothing observable changes. The diagnostic ID, severity, location and message text are all identical before and after. If you'd rather not carry a no-op diff, this is a reasonable thing to close.

This started from a report that also suggested passing CreateProperties(...) on this branch, for symmetry with AnalyzeInvocation and for a hypothetical future MA0080 fixer. I tried that and backed it out, because the properties would carry no information: in the loop case every value is a constant (ParameterIndex="-1", ParameterName=null, IsEnumeratorCancellation="False", CancellationTokens=""). Worse, the existing fixer's only use of them is cancellationTokens.Split(','), and "".Split(',') yields a single empty string — so an MA0080 fixer reading those properties would offer a bogus Use CancellationToken: action over an empty expression. Such a fixer would have to synthesize CancellationToken.None itself and ignore the properties. The asymmetry with AnalyzeInvocation looks intentional rather than an oversight: the loop case has nothing meaningful to pass.

Testing

  • dotnet build src/Meziantou.Analyzer/Meziantou.Analyzer.roslyn5.9.csproj — succeeded, 0 warnings.
  • UseAnOverloadThatHasCancellationTokenAnalyzerTests — 64/64 pass on roslyn5.9. The same class passed 64/64 on roslyn4.8, 4.14, 5.0 and 5.6 earlier in the session; the final one-line diff is Roslyn-version independent, and CI covers all five.
  • dotnet run --project src/DocumentationGenerator — exit 0, no markdown changes (no descriptor or message-format change).

MA0080 (FlowCancellationTokenInAwaitForEachRule) was reported with
string.Join(", ", availableCancellationTokens) as a message argument. In
that branch availableCancellationTokens is always empty, and the rule's
messageFormat is "Specify a CancellationToken", which has no {0}
placeholder, so the argument was formatted into nothing.

No behavior change: the message, the location and the diagnostic ID stay
the same.
@meziantou
meziantou merged commit c5d3809 into main Sep 12, 2026
13 checks passed
@meziantou
meziantou deleted the feature/ma0080-properties-analyzeloop-75511a branch September 12, 2026 20:17
This was referenced Sep 12, 2026
IhateTrains pushed a commit to ParadoxGameConverters/ImperatorToCK3 that referenced this pull request Sep 16, 2026
Updated
[Meziantou.Analyzer](https://github.com/meziantou/Meziantou.Analyzer)
from 3.0.235 to 3.0.259.

<details>
<summary>Release notes</summary>

_Sourced from [Meziantou.Analyzer's
releases](https://github.com/meziantou/Meziantou.Analyzer/releases)._

## 3.0.259

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.259>

## What's Changed
* Only generate the polyfills used by the code by @​meziantou in
meziantou/Meziantou.Analyzer#1526


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.258...3.0.259

## 3.0.258

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.258>

## What's Changed
* chore(deps): update dependency meziantou.framework.roslyn to 1.2.0 by
@​renovate[bot] in
meziantou/Meziantou.Analyzer#1525


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.257...3.0.258

## 3.0.257

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.257>

## What's Changed
* Use GetTypeByMetadataName unless the type is commonly declared as
internal in several assemblies by @​meziantou in
meziantou/Meziantou.Analyzer#1523


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.256...3.0.257

## 3.0.256

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.256>

## What's Changed
* Fix metadata names that could never resolve in MA0003, MA0001 and
MA0060 by @​meziantou in
meziantou/Meziantou.Analyzer#1522


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.255...3.0.256

## 3.0.255

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.255>

## What's Changed
* Add an option to include extension methods from namespaces that are
not imported in the rules using OverloadFinder by @​meziantou in
meziantou/Meziantou.Analyzer#1521


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.254...3.0.255

## 3.0.254

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.254>

## What's Changed
* Remove the unreachable string.Join branch of MA0089 by @​meziantou in
meziantou/Meziantou.Analyzer#1504
* Fix MA0018 reporting one diagnostic per event accessor by @​meziantou
in meziantou/Meziantou.Analyzer#1505
* chore(deps): update all dependencies to 1.0.172 by @​renovate[bot] in
meziantou/Meziantou.Analyzer#1507
* Report MA0070 on every declaration that can be obsolete by @​meziantou
in meziantou/Meziantou.Analyzer#1508
* Remove the discarded message argument of MA0080 by @​meziantou in
meziantou/Meziantou.Analyzer#1509
* Report MA0068 on the parameter and property placements of
NotNullIfNotNull by @​meziantou in
meziantou/Meziantou.Analyzer#1510
* Include the preprocessor trivia in the MA0202 branch comparison by
@​meziantou in meziantou/Meziantou.Analyzer#1511
* Report MA0179 when the constant is on the left of the length
comparison by @​meziantou in
meziantou/Meziantou.Analyzer#1512
* Fix the MA0166 message saying "available tokens" by @​meziantou in
meziantou/Meziantou.Analyzer#1513
* Detect the ConfigureAwait of the async enumerable in the MA0004
foreach analysis by @​meziantou in
meziantou/Meziantou.Analyzer#1506
* Report MA0206 on record struct and interface declarations by
@​meziantou in meziantou/Meziantou.Analyzer#1514
* Report MA0147 on async void method groups by @​meziantou in
meziantou/Meziantou.Analyzer#1515
* Report MA0051 on expression bodies of properties, indexers, and
operators by @​meziantou in
meziantou/Meziantou.Analyzer#1517
* Clarify the MA0095 comment about the Equals(object) lookup by
@​meziantou in meziantou/Meziantou.Analyzer#1518
* Report relational and generic math NaN comparisons in MA0082 by
@​meziantou in meziantou/Meziantou.Analyzer#1519
* Cache the MA0042 "no async equivalent" results per call-site scope by
@​meziantou in meziantou/Meziantou.Analyzer#1520
* Report the contextual keywords in MA0154 by @​meziantou in
meziantou/Meziantou.Analyzer#1516


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.253...3.0.254

## 3.0.253

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.253>

## What's Changed
* Share the argument list logic of the code fixes that add an argument
by @​meziantou in
meziantou/Meziantou.Analyzer#1503


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.252...3.0.253

## 3.0.252

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.252>

## What's Changed
* Preserve the variable scope in the MA0004 code fix by @​meziantou in
meziantou/Meziantou.Analyzer#1502


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.251...3.0.252

## 3.0.251

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.251>

## What's Changed
* Keep the initialization order in the MA0004 code fix by @​meziantou in
meziantou/Meziantou.Analyzer#1496
* Do not offer the MA0082 code fix when both operands are NaN by
@​meziantou in meziantou/Meziantou.Analyzer#1497
* Report MA0224/MA0225 when an earlier assignment configures another
instance by @​meziantou in
meziantou/Meziantou.Analyzer#1498
* Fix MA0040 inserting the CancellationToken in an invalid argument
position by @​meziantou in
meziantou/Meziantou.Analyzer#1499
* Preserve argument binding in the MA0074 code fix by @​meziantou in
meziantou/Meziantou.Analyzer#1500
* Fix MA0011 inserting the IFormatProvider in an invalid argument
position by @​meziantou in
meziantou/Meziantou.Analyzer#1501


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.250...3.0.251

## 3.0.250

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.250>

## What's Changed
* Report MA0163 when an assignment cannot fix the configuration used by
Process.Start by @​meziantou in
meziantou/Meziantou.Analyzer#1489
* Fix MA0166 inserting the TimeProvider in an invalid argument position
by @​meziantou in
meziantou/Meziantou.Analyzer#1490
* Do not report MA0214 when the function cannot be made async by
@​meziantou in meziantou/Meziantou.Analyzer#1491
* Preserve argument binding in the MA0108 code fix by @​meziantou in
meziantou/Meziantou.Analyzer#1492
* Add the type to the parameter added by the MA0106 code fix on a typed
lambda by @​meziantou in
meziantou/Meziantou.Analyzer#1495


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.249...3.0.250

## 3.0.249

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.249>

## What's Changed
* MA0177: preserve nested XML elements such as <see/> when collapsing by
@​meziantou in meziantou/Meziantou.Analyzer#1481
* Fix MA0184 code fix keeping doubled braces as literal text by
@​meziantou in meziantou/Meziantou.Analyzer#1465
* Do not report MA0209/MA0210 for arguments that cannot be passed by
reference by @​meziantou in
meziantou/Meziantou.Analyzer#1469
* Do not report MA0148/MA0149 when the constant does not convert to the
operand type by @​meziantou in
meziantou/Meziantou.Analyzer#1470
* Do not report MA0028 for string.Join overloads without an AppendJoin
equivalent by @​meziantou in
meziantou/Meziantou.Analyzer#1475
* chore(deps): update all dependencies by @​renovate[bot] in
meziantou/Meziantou.Analyzer#1477
* Fix MA0193 code fix producing invalid calls with named arguments by
@​meziantou in meziantou/Meziantou.Analyzer#1486
* Do not report MA0173 when the value cannot be captured by a lambda by
@​meziantou in meziantou/Meziantou.Analyzer#1487
* Do not report MA0106 when the factory writes the captured variable by
@​meziantou in meziantou/Meziantou.Analyzer#1488


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.248...3.0.249

## 3.0.248

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.248>

## What's Changed
* Do not report MA0065 when the invoked equality member is overridden by
@​meziantou in meziantou/Meziantou.Analyzer#1485
* Do not report MA0152 when the inner await suppresses the exceptions by
@​meziantou in meziantou/Meziantou.Analyzer#1484


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.247...3.0.248

## 3.0.247

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.247>

## What's Changed
* Do not report MA0215 when ConfigureAwait changes what the method does
by @​meziantou in
meziantou/Meziantou.Analyzer#1483


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.246...3.0.247

## 3.0.246

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.246>

## What's Changed
* Fix MA0158 code fix when the field is assigned in another document by
@​meziantou in meziantou/Meziantou.Analyzer#1478
* Do not report MA0173 when the return value of CompareExchange is used
by @​meziantou in
meziantou/Meziantou.Analyzer#1479
* Do not report MA0066 on ImmutableSortedDictionary by @​meziantou in
meziantou/Meziantou.Analyzer#1480


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.245...3.0.246

## 3.0.245

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.245>

## What's Changed
* Do not report MA0158 when the value cannot be migrated to
System.Threading.Lock by @​meziantou in
meziantou/Meziantou.Analyzer#1476


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.244...3.0.245

## 3.0.244

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.244>

## What's Changed
* Fix MA0028 changing escaped braces when replacing AppendFormat with
Append by @​meziantou in
meziantou/Meziantou.Analyzer#1474


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.243...3.0.244

## 3.0.243

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.243>

## What's Changed
* Do not report MA0078 when the selector does more than casting its
element by @​meziantou in
meziantou/Meziantou.Analyzer#1473


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.242...3.0.243

## 3.0.242

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.242>

## What's Changed
* Do not report MA0111 in expression trees by @​meziantou in
meziantou/Meziantou.Analyzer#1471
* Do not offer the MA0098 Last() code fix when the source cannot be
evaluated twice by @​meziantou in
meziantou/Meziantou.Analyzer#1472


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.241...3.0.242

## 3.0.241

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.241>

## What's Changed
* Do not merge MA0148/MA0149 comparisons when the operand can change
between evaluations by @​meziantou in
meziantou/Meziantou.Analyzer#1466
* Fix MA0210 checking the wrong parameter for reordered named arguments
by @​meziantou in
meziantou/Meziantou.Analyzer#1467
* Do not report MA0184 when the interpolated string is converted to
IFormattable by @​meziantou in
meziantou/Meziantou.Analyzer#1468


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.240...3.0.241

## 3.0.240

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.240>

## What's Changed
* Remove every dollar of raw strings in MA0184 code fix by @​meziantou
in meziantou/Meziantou.Analyzer#1464


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.239...3.0.240

## 3.0.239

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.239>

## What's Changed
* Do not report MA0005 for arrays of pointers by @​meziantou in
meziantou/Meziantou.Analyzer#1460
* Fix MA0171 code fix omitting parentheses around the generated pattern
by @​meziantou in
meziantou/Meziantou.Analyzer#1461
* Do not offer the MA0044 code fix when removing ToString would drop
argument side effects by @​meziantou in
meziantou/Meziantou.Analyzer#1462
* Import System.Threading.Tasks in MA0152 code fix by @​meziantou in
meziantou/Meziantou.Analyzer#1463


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.238...3.0.239

## 3.0.238

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.238>

## What's Changed
* Preserve interpolation alignment in MA0052 code fix by @​meziantou in
meziantou/Meziantou.Analyzer#1454
* Do not report MA0160 when ContainsKey is explicitly implemented by
@​meziantou in meziantou/Meziantou.Analyzer#1453


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.237...3.0.238

## 3.0.237

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.237>

## What's Changed
* Fix MA0127 code fix producing uncompilable code for object and span
operands by @​meziantou in
meziantou/Meziantou.Analyzer#1459
* MA0113: Only report DateTime constructors with the Utc kind by
@​meziantou in meziantou/Meziantou.Analyzer#1458
* Preserve attribute inheritance behavior in the MA0179 code fix by
@​meziantou in meziantou/Meziantou.Analyzer#1457
* MA0239: Do not report GetType() on a property by @​meziantou in
meziantou/Meziantou.Analyzer#1456
* MA0052: Suggest the first declared member when the enum value has
aliases by @​meziantou in
meziantou/Meziantou.Analyzer#1455
* Fix MA0089 treating an integer start index or count as
StringComparison.Ordinal by @​meziantou in
meziantou/Meziantou.Analyzer#1452
* chore(deps): update all dependencies by @​renovate[bot] in
meziantou/Meziantou.Analyzer#1445


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.236...3.0.237

## 3.0.236

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.236>

## What's Changed
* Exclude CsWinRT-required partial types from MA0204 by @​meziantou with
@​Copilot in meziantou/Meziantou.Analyzer#1451


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.235...3.0.236

Commits viewable in [compare
view](meziantou/Meziantou.Analyzer@3.0.235...3.0.259).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Meziantou.Analyzer&package-manager=nuget&previous-version=3.0.235&new-version=3.0.259)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant