Skip to content

Conversation

jjonescz
Copy link
Member

@jjonescz jjonescz commented Sep 22, 2025

Description

dotnet add app.cs package will now insert #:package directives:

  • After #! directives (first commit) because #! needs to always be first in the file.
  • Sorted (second commit) to match the behavior of dotnet add project.csproj package.

Customer impact

This was discovered by me while dogfooding the feature.

Regression

No.

Risk

Low. This is just a tooling update, scoped to the new feature (file-based apps). Unit tests verify the behavior.

@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label Sep 22, 2025
@jjonescz jjonescz requested review from a team and Copilot September 22, 2025 13:58
@jjonescz jjonescz marked this pull request as ready for review September 22, 2025 13:58
Copy link
Contributor

@Copilot 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

This PR improves the placement and ordering of file-level directives in C# script files by handling shebang directives and implementing sorted insertion of named directives.

  • Directives are now placed after shebang (#!) directives to respect script file structure
  • Named directives (like packages) are inserted in alphabetical order for better organization

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Cli/dotnet/Commands/Run/FileBasedAppSourceEditor.cs Implements sorting logic for named directives and shebang handling in directive placement
test/dotnet.Tests/CommandTests/Run/FileBasedAppSourceEditorTests.cs Adds test cases for sorted directive insertion and shebang directive handling

@jjonescz
Copy link
Member Author

@RikkiGibson for a review, thanks

@jjonescz jjonescz merged commit 2ab81d4 into dotnet:release/10.0.1xx Sep 26, 2025
30 checks passed
@jjonescz jjonescz deleted the sprint-package-add-sort branch September 26, 2025 17:55
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 Servicing-approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants