Skip to content

Allow duplicate #:project and #:ref directives#54035

Merged
jjonescz merged 4 commits intodotnet:release/10.0.4xxfrom
jjonescz:51139-sprint-allow-duplicate-refs
Apr 24, 2026
Merged

Allow duplicate #:project and #:ref directives#54035
jjonescz merged 4 commits intodotnet:release/10.0.4xxfrom
jjonescz:51139-sprint-allow-duplicate-refs

Conversation

@jjonescz
Copy link
Copy Markdown
Member

Closes #51139.

Copilot AI review requested due to automatic review settings April 22, 2026 09:18
@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label Apr 22, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates file-based program directive handling to permit duplicate #:project and #:ref directives, aligning tests and docs with the new behavior for project/ref references.

Changes:

  • Allow duplicate #:project and #:ref directives during directive parsing (no duplicate error reported).
  • Update run-file tests to expect successful execution when these directives are repeated.
  • Update documentation to describe the new duplicate-directive exception for #:project and #:ref.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/dotnet.Tests/CommandTests/Run/RunFileTests.cs Updates existing tests to expect success when #:project/#:ref directives are duplicated.
src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs Changes duplicate-directive validation logic to exempt #:project and #:ref.
documentation/general/dotnet-run-file.md Documents the new duplicate-directive rule (with exceptions for #:project/#:ref).

Comment thread src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs Outdated
Comment thread documentation/general/dotnet-run-file.md Outdated
@jjonescz jjonescz requested a review from a team April 22, 2026 11:27
We disallow duplicate `#:` directives to allow us design some deduplication mechanism in the future.
We disallow duplicate `#:` directives (except `#:project` and `#:ref`) to allow us to design some deduplication mechanism in the future.
Specifically, directives are considered duplicate if their type and name (case insensitive) are equal.
`#:project` and `#:ref` duplicates are allowed because MSBuild handles deduplication of project references naturally.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe clarify that multiple <ProjectReference> directives are allowed? The current wording says that indirectly, but it could be more explicit about it.

@jjonescz jjonescz requested a review from MiYanni April 23, 2026 14:17
@jjonescz jjonescz merged commit 5441380 into dotnet:release/10.0.4xx Apr 24, 2026
28 checks passed
@jjonescz jjonescz deleted the 51139-sprint-allow-duplicate-refs branch April 24, 2026 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-run-file Items related to the "dotnet run <file>" effort

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants