Skip to content

Clarify raw string literal multi-line rules for opening quotes and whitespace handling #47728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 4, 2025

This PR clarifies the documentation for multi-line raw string literal rules to address confusion about what "on their own line" means and how whitespace is handled.

Changes Made

  1. Clarified opening/closing quote requirements: Changed "last non-comment token on its respective line" to "last non-whitespace characters on their line" to be more precise and eliminate confusion about whether quotes can appear on the same line as variable declarations.

  2. Improved whitespace handling description: Changed "Whitespace following the opening quote" to "Any whitespace following the opening quotes" for consistency and clarity.

  3. Made plural forms consistent: Changed "closing quote" to "closing quotes" to match the plural form used elsewhere in the documentation.

Issue Addressed

The original documentation caused confusion because:

  • Readers weren't sure if var xml = """ counted as quotes being "on their own line"
  • It wasn't clear whether whitespace after the opening quotes was included in the string literal

Example

The existing code example demonstrates the clarified behavior:

var xml = """
        <element attr="content">
            <body>
            </body>
        </element>
        """;

In this example:

  • The opening quotes """ are the last non-whitespace characters on their line (after the variable assignment)
  • Any whitespace after the opening quotes on the same line would be ignored
  • The actual content starts on the next line

Fixes #34192.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


Internal previews

📄 File 🔗 Preview link
docs/csharp/language-reference/tokens/raw-string.md docs/csharp/language-reference/tokens/raw-string

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Aug 4, 2025
…itespace handling

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Clarifications regarding two of the listed string literal rules Clarify raw string literal multi-line rules for opening quotes and whitespace handling Aug 4, 2025
@Copilot Copilot AI requested a review from BillWagner August 4, 2025 20:16
Copilot finished work on behalf of BillWagner August 4, 2025 20:16
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

This LGTM, and is ready for final review.

@BillWagner BillWagner marked this pull request as ready for review August 5, 2025 14:53
@BillWagner BillWagner requested a review from a team as a code owner August 5, 2025 14:53
@BillWagner BillWagner requested a review from tdykstra August 5, 2025 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-csharp/svc lang-reference/subsvc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarifications regarding two of the listed string literal rules
2 participants