Skip to content
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

CS8998 when last character is double quote in raw string literal #73063

Closed
kasperk81 opened this issue Apr 17, 2024 · 2 comments
Closed

CS8998 when last character is double quote in raw string literal #73063

kasperk81 opened this issue Apr 17, 2024 · 2 comments
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@kasperk81
Copy link

compilation fails when last character is a double quote in raw string literal:

"hello \"there\"" // baseline: hello "there"
"""hello "there"""" // error CS8998: The raw string literal does not start with enough quote characters to allow this many consecutive quote characters as content.
"""hello "there" """ // allowed with (undesired) extra trailing space
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 17, 2024
@CyrusNajmabadi
Copy link
Member

Correct. This is the design of raw strings. If you want to start or end with a quote you must use a multi line literal like:

Var v = """
     Hello "there"
     """;

@kasperk81
Copy link
Author

thanks for highlighting it's a design decision. with your approach, it keeps the string length intact (no trailing space). that fixed my unit tests where i started using raw strings.

Console.WriteLine("""
Hello "there"
""");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

2 participants