Skip to content

fix(multiple) missing MessageFormat arguments across analyzers#415

Merged
Arthurvdv merged 2 commits into
ALCops:mainfrom
MODUSCarstenScholling:dev-cs-fix-messageformats
Jul 20, 2026
Merged

fix(multiple) missing MessageFormat arguments across analyzers#415
Arthurvdv merged 2 commits into
ALCops:mainfrom
MODUSCarstenScholling:dev-cs-fix-messageformats

Conversation

@MODUSCarstenScholling

@MODUSCarstenScholling MODUSCarstenScholling commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Several diagnostics passed too few arguments to Diagnostic.Create, producing messages with literal "{0}" placeholders. Add the missing name arguments and align resx/call sites where they had drifted.

  • AC0001 (LookupPageIdAndDrillDownPageId): include list page name in message
  • AC0012 (IntegrationEventInInternalCodeunit): drop superfluous {1} arg
  • PC0001 (EditableFlowField): pass field.Name
  • PC0011 (EventPublisherIsHandledByVar): pass parameter.Name
  • PC0013: diagnostic message now includes the resolved primary key fields for clarity.
  • LC0054 (InterfaceObjectNameGuide): pass interfaceTypeSymbol.Name (3 sites)
  • LC0082 (UseQueryOrFindWithNextInsteadOfCount): preserve real operator and compared value; add FlipOperator/GetOperatorSign switch expressions so "2 > Rec.Count()" is normalized to "Count() < 2" in the message

Fixes #414

Several diagnostics passed too few arguments to Diagnostic.Create,
producing messages with literal "{0}" placeholders. Add the missing
name arguments and align resx/call sites where they had drifted.

- PC0001 (EditableFlowField): pass field.Name
- PC0011 (EventPublisherIsHandledByVar): pass parameter.Name
- LC0054 (InterfaceObjectNameGuide): pass interfaceTypeSymbol.Name (3 sites)
- AC0001 (LookupPageIdAndDrillDownPageId): include list page name in message
- AC0012 (IntegrationEventInInternalCodeunit): drop superfluous {1} arg
- LC0082 (UseQueryOrFindWithNextInsteadOfCount): preserve real operator
  and compared value; add FlipOperator/GetOperatorSign switch expressions
  so "2 > Rec.Count()" is normalized to "Count() < 2" in the message

Fixes ALCops#414
@MODUSCarstenScholling

Copy link
Copy Markdown
Contributor Author

The change for PC0013 is based on internal feedback.

@Arthurvdv Arthurvdv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: PR #415 — fix(multiple) missing MessageFormat arguments across analyzers

Summary: Verified every touched rule end-to-end: resx placeholder count/order against all Diagnostic.Create call sites per descriptor, the LC0082 operator-normalization logic, PC0013 TFM guards/reflection helpers, and test impact.

  • AC0001 — resx now has {0}/{1}; the single call site already passed table.Name + the page name in matching order. ✓
  • AC0012 — the dropped applicationObject.Name arg was superfluous; applicationObject is still used for the internal-codeunit guard, so no unused-variable fallout. ✓
  • PC0001 / PC0011 — one call site each, now passing the single {0} arg. ✓
  • LC0054 — all 3 call sites updated consistently; no other call sites exist. ✓
  • PC0013 — new resx format has 3 placeholders; both call sites pass GetPrimaryKeySignature(table), table.Name, expectedArgs in matching order. GetMethodName is a const string, valid in the interpolation. QuoteIdentifierIfNeededWithReflection and ToDisplayStringWithReflection exist in ALCops.Common with matching #if NETSTANDARD2_1 guards; the #else path (field.Type?.ToDisplayString()) mirrors existing usage. All three TFMs (netstandard2.1/net8/net10) check out. ✓
  • LC0082 — exactly one side of the comparison can be an int literal (the Count() side yields the −1 sentinel), so countIsOnRight = leftValue >= 0 && rightValue < 0 is sound. Every report path guarantees comparedValue is 1 or 2, making the "=" fallback in GetOperatorSign unreachable. FlipOperator mirrors correctly: 2 > Rec.Count() → "Count() < 2", 1 <= Rec.Count() → "Count() >= 1". A genuine -1 literal can't collide with the sentinel since only 0/1/2 trigger reports, and 0-comparisons are diverted to the IsEmpty diagnostic earlier. ✓
  • Tests — all touched rules use marker-based assertions (HasDiagnosticAtAllMarkers) with diagnostic IDs only; no test asserts message text, and arg counts now match placeholders, so no FormatException risk at render time.

Findings

1. Missing trailing newline
File: src/ALCops.PlatformCop/Analyzers/RecordGetProcedureArguments.cs (last line)
Severity: Trivial
No functional impact.

Verdict

Approve. No bugs, logic errors, or placeholder/arg mismatches found — the PR does what it claims at every call site, and the LC0082 operator normalization is correct across all reachable paths.

Generated with Claude Fable 5 via GitHub Copilot CLI

@Arthurvdv
Arthurvdv merged commit 7932e20 into ALCops:main Jul 20, 2026
49 checks passed
@MODUSCarstenScholling
MODUSCarstenScholling deleted the dev-cs-fix-messageformats branch July 21, 2026 00:48
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.

[Bug]: Several analyzers have diagnostic messages containing incorrect placeholders

2 participants