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

C# verbatim, interpolated strings sometimes break #58062

Closed
3geek14 opened this issue Sep 29, 2022 · 4 comments
Closed

C# verbatim, interpolated strings sometimes break #58062

3geek14 opened this issue Sep 29, 2022 · 4 comments
Assignees
Labels
c# clang-format invalid-code-generation Tool (e.g. clang-format) produced invalid code that no longer compiles

Comments

@3geek14
Copy link

3geek14 commented Sep 29, 2022

I have two files that each have a single verbatim, interpolated string:

mwe-good.cs:

$@"path\to\{specifiedFile}"

mwe-bad.cs

@$"path\to\{specifiedFile}"

When running clang-format --style=LLVM mwe-good.cs, the output is identical to the file (yay!). When running it on mwe-bad.cs, the output is different:

@$ "path\to\{specifiedFile}"

There's an extra space added, which causes compilation errors (when it's a full file and not a MWE). As of C# 8, both orderings are accepted.

As a bug report, I'd like the space to no longer be added. As a small feature request, and only if it's easy to implement/maintain, I think it would be nice if clang-format picked an ordering of the two symbols and made verbatim, interpolated strings always use that order.

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 29, 2022

@llvm/issue-subscribers-clang-format

@owenca owenca self-assigned this Oct 1, 2022
@owenca owenca added the invalid-code-generation Tool (e.g. clang-format) produced invalid code that no longer compiles label Oct 1, 2022
@owenca
Copy link
Contributor

owenca commented Oct 2, 2022

@owenca owenca added the awaiting-review Has pending Phabricator review label Oct 2, 2022
@owenca owenca closed this as completed in b60e7a7 Oct 5, 2022
@github-actions github-actions bot removed the awaiting-review Has pending Phabricator review label Oct 5, 2022
@tru
Copy link
Collaborator

tru commented Oct 5, 2022

@owenca @3geek14 pinged me and asked me to backport this to the release branch. does that make sense to you? how safe is it? We are late in the 15.x release cycle so I am a bit conservative.

@owenca
Copy link
Contributor

owenca commented Oct 5, 2022

@tru it's ok with me unless @mydeveloperday thinks otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c# clang-format invalid-code-generation Tool (e.g. clang-format) produced invalid code that no longer compiles
Projects
None yet
Development

No branches or pull requests

5 participants