Skip to content

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

Description

@MODUSCarstenScholling

Symptoms

A number of Diagnostic.Create calls pass fewer or more arguments than their
MessageFormat string references, so the rendered diagnostic message
still contains the unformatted {n} placeholder instead of
the expected symbol name.

Affected rules

ID Rule Effect
PC0001 EditableFlowField Message shows {0} instead of the field name
PC0011 EventPublisherIsHandledByVar Message shows {0} instead of the parameter name
LC0054 InterfaceObjectNameGuide Message shows {0} instead of the interface name
LC0082 UseQueryOrFindWithNextInsteadOfCount Count() >= 1 is reported as Count() <> - operator collapsed to <>, compared value omitted
AC0001 LookupPageIdAndDrillDownPageId Second argument passed but never rendered - list page name missing from message
AC0012 IntegrationEventInInternalCodeunit Extra argument passed that the message doesn't reference

Cause

Two independent classes of issues:

  1. Missing args at the call site - Diagnostic.Create(descriptor, location) is called with no message args although the MessageFormat contains {0}. Affects PC0001, PC0011, LC0054.
  2. Resx / call-site drift - the number of args passed and the number of placeholders in the resx no longer match, either because the message was later reworded or the call site was later extended. Affects AC0001, AC0012.

Additionally, LC0082's helper GetOperatorKind normalized every
non-= operator to <> and threw away the compared literal value, so
the emitted message could not describe the actual code being flagged.

Expected behaviour

Every diagnostic message renders with all placeholders substituted; the
operator and compared value in LC0082's message match the source code
being flagged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    part of upcoming releaseAvailable in alpha/beta and waiting to be included in the next stable release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions