Skip to content

Fix CoreLib extern modifier ordering - #132240

Open
EgorBo with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-modifiers-order-osx-arm64
Open

Fix CoreLib extern modifier ordering#132240
EgorBo with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-modifiers-order-osx-arm64

Conversation

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Reorders CoreLib safety modifiers from safe extern/unsafe extern to extern safe/extern unsafe, satisfying IDE0036 and restoring macOS ARM64 builds.

Copilot AI lite review requested due to automatic review settings August 12, 2026 22:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
16 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI linked an issue Aug 12, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix modifiers order errors on osx-arm64 build Fix CoreLib extern modifier ordering Aug 12, 2026
Copilot AI requested a review from EgorBo August 12, 2026 23:05
@EgorBo

EgorBo commented Aug 12, 2026

Copy link
Copy Markdown
Member

@copilot where are the changes?

Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 12, 2026 23:21

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@copilot where are the changes?

Fixed and pushed in eec38c7. Checked CoreLib builds cleanly with 0 warnings/errors.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

@EgorBo

EgorBo commented Aug 12, 2026

Copy link
Copy Markdown
Member

@copilot plz fix AddUnsafeToExternCodeFixProvider.cs and AddUnsafeToExternCodeFixTests.cs as well.

@EgorBo

EgorBo commented Aug 12, 2026

Copy link
Copy Markdown
Member

@copilot plz fix AddUnsafeToExternCodeFixProvider.cs and AddUnsafeToExternCodeFixTests.cs as well.

Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 13, 2026 00:17

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot plz fix AddUnsafeToExternCodeFixProvider.cs and AddUnsafeToExternCodeFixTests.cs as well.

Fixed in 2d46b3f. The code fix now emits extern unsafe/extern safe; all 12 targeted tests pass.

@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Aug 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/tools/illink/src/ILLink.CodeFix/UnsafeModifierCodeFixHelpers.cs:274

  • AddModifier(SyntaxTokenList ...) still inserts the safety modifier before extern when insertAfterModifier is left as the default (SyntaxKind.None). That means other code fixes that reuse this helper without specifying insertAfterModifier can still generate unsafe extern / safe extern and reintroduce IDE0036-style modifier ordering problems (the same class of issue this PR is addressing for CoreLib).

Consider treating extern as a special case in the default insertion logic (insert after extern when present), while keeping the existing partial behavior for non-extern declarations.

                // 'extern' and 'partial' conventionally sit closest to the return type, so the safety modifier goes
                // before them. Otherwise it is appended, which matches the repo's preferred modifier order where
                // 'unsafe' follows 'virtual', 'abstract', 'sealed' and 'override'.
                insertionIndex = GetFirstModifierIndex(modifiers, SyntaxKind.ExternKeyword, SyntaxKind.PartialKeyword);
            }

@EgorBo
EgorBo marked this pull request as ready for review August 13, 2026 00:56
@EgorBo
EgorBo requested a review from sbomer as a code owner August 13, 2026 00:56
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Infrastructure linkable-framework Issues associated with delivering a linker friendly framework

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

main is failing to build on osx-arm64

4 participants