fix(FC0004): regression fixtures for permission lists with compiler directives; CodeFix directive policy - #565
Merged
Merged
Conversation
… fix rewrites NoDiagnostic cases pin that unsorted lists with an active #if/#pragma around an entry, or an #endif in the ; token's leading trivia, are not reported (so the fix cannot delete those lines). HasFix cases pin that #pragma and #if lines around the whole property survive both the layout-preserving reorder and the single-line to multi-line rebuild. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A CodeFix keeps every directive and any disabled text in the span it edits, or does not register. codefix-development.md explains where directives live, which calls drop them (including what each SyntaxRemoveOptions value keeps) and how to detect them; testing.md makes the directive fixture set mandatory for fixes that remove, move or rebuild nodes; the new-codefix skill and REVIEW.md enforce both. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds FC0004 regression fixtures for permission lists that contain compiler directives. It also adds a house policy for every CodeFix: keep every directive and any disabled text in the edited span, or do not offer the fix.
No analyzer, CodeFix or Common C# code changed.
Verification
PermissionSyntaxHelper.BuildMultiLinePermissionValue, which strips every entry's leading and trailing trivia. A directive line is leading trivia of the token after it, so#if not CLEAN…and#pragma warning disable AL0432lines inside the list were deleted.PermissionSyntaxHelper.TryBuildRegionTree) refuses any list with a non-region directive in an entry's leading trivia or in the;token's leading trivia. For such a list the analyzer reports nothing, so the fix never runs. Such lists are also not sorted, which matches AZ AL Dev Tools.What the fixtures pin
NoDiagnostic/ActiveIfWithPragmaAroundEntry.al: the issue's exact layout. An unsorted list has one entry wrapped in#if not CLEAN25+#pragma warning disable/restore AL0432, and that entry's table is markedObsoleteState = Pending.NoDiagnostic/IfAroundLastEntry.al: an unsorted list whose#endiflands in the;token's leading trivia.HasFix/PreserveDirectivesAroundProperty: a multi-line list with#pragma warning disable/restorearound the property. This covers the layout-preserving reorder path.HasFix/SingleLineWithDirectivesAroundProperty: a single-line list with#if not CLEAN25/#endifaround the property. This covers the multi-line rebuild path.expected.alfirst left out one directive line. Both tests failed withTransformedCodeDifferentThanExpectedExceptionnaming the missing line, then passed once the line was restored.#ifand#pragmaswapped behaved the same, so the PR keeps one of each.Guidance added
.claude/rules/codefix-development.md: new section "Compiler directives and disabled text". It covers:SyntaxRemoveOptionsvalue keeps (perSyntaxNodeRemover.AddDirectives);yesat every SDK version in the nav-sdk-docs reference tables;The "Where to find each fix shape" table also gets a new row.
.claude/rules/testing.md: a mandatory directive fixture set for fixes that remove, move or rebuild nodes: active#if, inactive#if, a#pragmapair and a#regionpair..claude/skills/new-codefix/SKILL.md: a design-gate question, a Step 3 test requirement and a Common Mistakes row.REVIEW.md(house section): a new row for trivia-stripping fixes without a directive gate or directive fixtures. The severity sentence now also counts "what a CodeFix produces" as correctness..claude/rules/diagnostics/fc0004-permission-declaration-order.md: the directive non-report now explains both#ifbranches. The CodeFix table gets a row on directives outside the list.Fixes #454
Audit of the other CodeFixes: #564
Checks
dotnet test src/ALCops.FormattingCop.Test/ --filter "FullyQualifiedName~PermissionDeclarationOrder":Passed! - Failed: 0, Passed: 49, Skipped: 0, Total: 49, Duration: 1 s - ALCops.FormattingCop.Test.dll (net10.0)dotnet build ALCops.sln: succeeded, 0 errors.dotnet format ALCops.sln --verify-no-changes: exit 0.pwsh .claude/scripts/Validate-Rules.ps1:OK: 55 rules files (15 guides, 40 rule docs) pass all checks.#if/#pragmaare not checked, so no docs PR is needed.🤖 Generated with Claude Code