Skip to content

Improve TableHelper.IsSetupTable() with GetRecordOnce pattern detection #287

@Arthurvdv

Description

@Arthurvdv

Context

In #283 / PR #286, we added TableHelper.IsSetupTable() to suppress PC0030 on setup table parameterless Get() calls. The current heuristic checks:

  • Single PK field
  • PK field type is Code
  • PK field name matches "Primary Key" or "PrimaryKey" (case-insensitive)

Enhancement

Add an additional check: detect tables that define a public GetRecordOnce() method (or similar caching pattern). This is Microsoft's preferred optimization for setup tables and could serve as a secondary signal for tables that don't follow the "Primary Key" field naming convention.

Microsoft's pattern

procedure GetRecordOnce()
begin
    if RecordHasBeenRead then
        exit;
    Get();
    RecordHasBeenRead := true;
end;

This pattern exists on 9+ major setup tables in the BaseApp (GeneralLedgerSetup, SalesReceivablesSetup, PurchasesPayablesSetup, InventorySetup, ManufacturingSetup, JobsSetup, MarketingSetup, ServiceMgtSetup, WarehouseSetup).

Implementation notes

  • Could check ITableTypeSymbol for a method named GetRecordOnce (or match a pattern like Get*Once)
  • This would be an OR condition alongside the existing PK-based heuristic
  • Consider if the method needs to be public or if internal/local patterns also count

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions