Skip to content

feat: add FC0006 - Permission values should be lowercase#401

Merged
Arthurvdv merged 5 commits into
mainfrom
feat/fc0006-permission-values-should-be-lowercase
Jul 14, 2026
Merged

feat: add FC0006 - Permission values should be lowercase#401
Arthurvdv merged 5 commits into
mainfrom
feat/fc0006-permission-values-should-be-lowercase

Conversation

@Arthurvdv

@Arthurvdv Arthurvdv commented Jul 12, 2026

Copy link
Copy Markdown
Member

Summary

Implements a new FormattingCop rule FC0006 PermissionValuesShouldBeLowercase from discussion #383.

The Permissions property on application objects accepts permission values in any casing, but casing has no runtime meaning there. Uppercase RIMD falsely suggests direct permission grants, a semantic that only exists in permissionset/permissionsetextension objects and the InherentPermissions property. FC0006 flags uppercase values and ships a code fix that lowercases them.

Scope decisions

  • Covered objects: codeunit, table, page, report, requestpage, xmlport, query (all objects supporting the Permissions property).

  • Excluded: permissionset / permissionsetextension objects and the InherentPermissions property — casing is semantic there (direct vs. indirect).

  • Granularity: one diagnostic per Permissions property (matches FC0004).

  • Severity: Info, Category Style (matches FC0004).

  • Scope was posted for feedback on the discussion: scope comment.

  • Execute permission (X) is covered: the uppercase check applies to every permission value, including X, per rvanbekkum's feedback on the discussion.

Notable finding

The AL compiler only accepts tabledata entries in the object-level Permissions property; non-tabledata entries (codeunit X = X) fail with AL0104: Syntax error, 'tabledata' expected, despite Microsoft Learn examples suggesting otherwise. Parser evidence: ObjectParser parses object-level permission lists with a TableDataKeyword-only predicate.

Consequence for X coverage: in FC0006's scope, X only occurs in code carrying a compile error (AL0195 on tabledata entries; non-tabledata entries are dropped by parser error recovery and never reach the analyzer). The rule still flags and fixes tabledata Foo = X, and the generic uppercase check automatically covers non-tabledata entries should a future compiler legalize them. The X test cases use error-tolerant fixtures (ThrowsWhenInputDocumentContainsError = false), following the existing ApplicationCop.Test/TestHelper.cs pattern.

Changes

  • Analyzer PermissionValuesShouldBeLowercase (syntax-node action on PermissionPropertyValue, skips obsolete objects and permissionset ancestors)
  • CodeFix PermissionValuesShouldBeLowercaseCodeFixProvider (lowercases all permission tokens, BatchFixer)
  • EnumProvider: added SyntaxKind.PermissionPropertyValue
  • 21 tests (10 HasDiagnostic, 7 NoDiagnostic, 4 HasFix)
  • Instruction file + maintenance table row

Testing

  • dotnet build ALCops.sln: clean
  • dotnet test ALCops.sln: all pass (FormattingCop.Test: 101, incl. 21 new FC0006 tests)

Documentation page for alcops.dev prepared separately.

Closes #383

Arthurvdv and others added 5 commits July 12, 2026 15:02
Flags uppercase permission values (RIMD) in the Permissions property of
application objects (codeunit, table, page, report, requestpage, xmlport,
query), where casing has no runtime meaning. Excludes permissionset and
permissionsetextension objects and the InherentPermissions property, where
casing distinguishes direct from indirect permissions.

Includes a code fix that lowercases all permission values in the property.

Refs discussion #383

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Per feedback from rvanbekkum on discussion #383, the rule also applies
to the execute permission. The uppercase check already covered any
uppercase character; this adds the 'x' to the diagnostic message and
test evidence for X values.

On object-level Permissions, X values only occur in code carrying a
compile error (AL0195 on tabledata entries; non-tabledata entries are
dropped by parser error recovery and never reach the analyzer), so the
new test cases use error-tolerant fixtures
(ThrowsWhenInputDocumentContainsError = false), following the existing
ApplicationCop.Test/TestHelper.cs pattern. A future SDK that legalizes
non-tabledata entries is covered automatically by the generic
uppercase check.

Refs discussion #383

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…n-values-should-be-lowercase

# Conflicts:
#	.github/instructions/instruction-maintenance.instructions.md
#	src/ALCops.FormattingCop/DiagnosticIds.cs
Older SDKs reject the permission set extension fixture with AL0334
(extension target already declared in this module).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ension fixture

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Arthurvdv
Arthurvdv merged commit 5f4fccf into main Jul 14, 2026
51 checks passed
@Arthurvdv
Arthurvdv deleted the feat/fc0006-permission-values-should-be-lowercase branch July 14, 2026 12:18
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