Skip to content

Conversation

jjonescz
Copy link
Member

@jjonescz jjonescz commented Oct 3, 2025

Description

This blocks usage of quotes " inside #: file-level directives, so we can later support quoted directives (#49367) without a breaking change. This also improves the error recovery experience if users try to use quotes now thinking that's a supported syntax.

Customer impact

If customers have quotes in their file-level directives (which seems unlikely, there is no known use case for that), they will now see errors (and would need to move these directives outside the file-based app into a Directory.Build.props file for example until we support quoted directives - this is similar to other special characters we currently don't support in unquoted directives, like trailing whitespace).

Regression

N/A.

Risk

Low, changing a new feature in .NET 10, disallowing an edge case that is unlikely to be relied upon. Will avoid a future breaking change.

@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label Oct 3, 2025
@jjonescz jjonescz requested a review from Copilot October 3, 2025 11:07
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 introduces validation to disallow quotes in file-level directives and surfaces a new localized error message when quotes are present.

  • Adds diagnostic reporting when a directive value contains a double quote.
  • Updates tests to assert new diagnostics instead of previous property name validation in affected cases.
  • Introduces a new localized resource (QuoteInDirective) across all .xlf language files.

Reviewed Changes

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

Show a summary per file
File Description
test/dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs Adds expected directive diagnostics for quotes, extends helper methods to collect and verify diagnostics, introduces constant for program path.
src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs Adds validation rejecting directives containing quotes and emits new diagnostic.
src/Cli/dotnet/Commands/CliCommandStrings.resx Adds new resource string for quote restriction error.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf Adds localization entry for new error (manually edited).
src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf Adds localization entry for new error (manually edited).
src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf Adds localization entry for new error (manually edited).
src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf Adds localization entry for new error (manually edited).
src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf Adds localization entry for new error (manually edited).
src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf Adds localization entry for new error (manually edited).
src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf Adds localization entry for new error (manually edited).
src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf Adds localization entry for new error (manually edited).
src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf Adds localization entry for new error (manually edited).
src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf Adds localization entry for new error (manually edited).
src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf Adds localization entry for new error (manually edited).
src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf Adds localization entry for new error (manually edited).
src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf Adds localization entry for new error (manually edited).

@jjonescz jjonescz marked this pull request as ready for review October 3, 2025 11:11
@jjonescz jjonescz requested a review from a team October 3, 2025 11:11
@jjonescz jjonescz added this to the 10.0.1xx milestone Oct 3, 2025
@jjonescz
Copy link
Member Author

jjonescz commented Oct 3, 2025

@RikkiGibson @333fred @MiYanni for reviews, thanks

@RikkiGibson
Copy link
Member

taking a look shortly.

Copy link
Member

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

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

It would be good to also demonstrate what happens when user tries to escape the quote, e.g. #:property Name=\"Value\".

Copy link
Member

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

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

LGTM aside from a test suggestion.

<comment>{0} is the directive type and name.</comment>
</data>
<data name="QuoteInDirective" xml:space="preserve">
<value>Directives currently cannot contain quotes (").</value>
Copy link
Member

Choose a reason for hiding this comment

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

So, is this specific to double quotes " or does that also account for single quotes '? Might make sense to be a bit more specific.

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