Skip to content

fix(FC0004): use AZ Dev Tools-compatible permission sorting#251

Open
Arthurvdv wants to merge 1 commit into
mainfrom
fix/fc0004-az-compatible-sorting
Open

fix(FC0004): use AZ Dev Tools-compatible permission sorting#251
Arthurvdv wants to merge 1 commit into
mainfrom
fix/fc0004-az-compatible-sorting

Conversation

@Arthurvdv

Copy link
Copy Markdown
Member

Summary

Fixes false positive in FC0004 where permission entries sorted by AZ Dev Tools' "Sort Permissions" action would still trigger the diagnostic.

Changes

Replaces the simple OrdinalIgnoreCase string comparison with a natural/alphanumeric sort that matches AZ Dev Tools' PermissionComparer behavior:

  • Type ordering: table/tabledata types sort first (grouped by name), remaining types sort alphabetically
  • Name comparison: Natural sort with numeric chunks compared as integers (Item 2 < Item 10)
  • Text handling: Spaces stripped, InvariantCultureIgnoreCase for text chunks

New files

  • src/ALCops.Common/Permissions/NaturalNameComparer.cs - Natural/alphanumeric string comparer

Test coverage

  • 6 HasDiagnostic cases (added: UnsortedNumeric, UnsortedTableNotFirst)
  • 7 NoDiagnostic cases (added: DotsBeforeLetters, NaturalNumericSort, TableTypesFirst)
  • 4 HasFix cases (ReorderMixedTypes updated for new sort order)

Closes #245

Replace OrdinalIgnoreCase string comparison with natural/alphanumeric
sort that matches AZ Dev Tools' PermissionComparer behavior:

- table/tabledata types sort first, grouped by name
- Remaining types sort alphabetically by type keyword
- Object names use natural sort (numeric chunks as integers)
- Text chunks compared with spaces stripped and InvariantCultureIgnoreCase

This fixes false positives on code formatted by AZ Dev Tools' Sort
Permissions action.

Closes #245

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Base automatically changed from release/v0.8.0 to main May 12, 2026 07:19
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