Skip to content

Audit CodeFixes that fabricate SemicolonToken for issue #395-class bugs #398

Description

@Arthurvdv

Background

Issue #395 revealed that the PC0037 CodeFix fabricated a SemicolonToken via SyntaxFactory.Token(EnumProvider.SyntaxKind.SemicolonToken) when rewriting a statement. In AL, a statement directly before else must not have a semicolon, so the fabricated token produced non-compiling code. The fix was to reuse the original statement's SemicolonToken (a missing token when absent).

Task

Audit the remaining CodeFixes that construct semicolon tokens and verify none of them can replace an existing statement whose semicolon is optional/absent (e.g., then-branch before else):

  • src/ALCops.PlatformCop/CodeFixes/UseSetAutoCalcFieldsForLoopsCodeFixProvider.cs:155
  • src/ALCops.ApplicationCop/CodeFixes/RunPageImplementPageManagement.cs:360 and :400
  • src/ALCops.PlatformCop/CodeFixes/UsePartialRecordsOnRead.cs:195
  • src/ALCops.PlatformCop/CodeFixes/MandatoryFieldMissingOnApiPage.cs:148
  • src/ALCops.ApplicationCop/CodeFixes/GlobalLanguageImplementTranslationHelper.cs:346

CodeFixes that insert new statements into a block legitimately need a fabricated semicolon; the risky pattern is replacing an existing statement in place. For each location, determine which case applies and add regression fixtures (if-then before else, nested in repeat..until) where the replace-in-place pattern is used.

Correct reference pattern: GlobalLanguageImplementTranslationHelper.cs:141 and the PC0037 fix for #395.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions