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

Intellisense bug: when contents of string interpolation contains newline, the final double quote is incorrectly moved #39846

Closed
vsfeedback opened this issue Nov 15, 2019 · 6 comments
Labels
Area-IDE Bug Developer Community The issue was originally reported on https://developercommunity.visualstudio.com help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-Formatter Code formatter and/or smart indent Need More Info The issue needs more information to proceed.
Projects
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


Example:

_logger?. LogError($"{guid} failure: {await httpResponseMessage
. Content
. ReadAsStringAsync()
. ConfigureAwait(false)}");

... becomes...

_logger?. LogError($"{guid} failure: {await httpResponseMessage
. Content
. ReadAsStringAsync()
. ConfigureAwait(false)}
");

... on save. This doesn't compile.


Original Comments

Visual Studio Feedback System on 11/10/2019, 10:15 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

@sharwell sharwell added Area-IDE Bug Developer Community The issue was originally reported on https://developercommunity.visualstudio.com help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-Formatter Code formatter and/or smart indent labels Nov 15, 2019
@sharwell sharwell added this to InQueue in Small Fixes via automation Nov 15, 2019
@sharwell sharwell added this to the Backlog milestone Nov 15, 2019
@davidnmbond
Copy link

It's also worth noting that string interpolation does not currently support newline characters, though I can see no logical reason why not.

@CyrusNajmabadi
Copy link
Member

@davidnmbond What do you mean by that? You can both embed newline characters with an escape like so:

                    var v = $"foo\nbar";

Or you can directly embed a newline like so:

                    var v = $@"foo
bar";

This matches how normal strings work.

@davidnmbond
Copy link

davidnmbond commented Nov 20, 2019

I mean:

    var text =$"They list of people includes: {(string.Join(", ", people.Where(p=>p.IsHappy)
        .OrderBy(p=>p.Surname)
        .ThenBy(p=>p.Forename)
        .Select(p => $"{p.Forename} {p.Surname}"))}.  They are all happy.";

There are no newline characters in the output string, but adding length Linq mid-interpolated string is a pain because you have to keep it all one one line. There is no real need for this constraint.

@CyrusNajmabadi
Copy link
Member

There is no real need for this constraint.

Yes there is. You have a normal interpolated string. So the lexer isn't going to consume newlines in the middle since that's not allowed there. If you want this, you can write it as:

                var text = $@"They list of people includes: {
                    (string.Join(", ", people.Where(p => p.Length > 21)
                    .OrderBy(p => p.Surname)
                    .ThenBy(p => p.Forename)
                    .Select(p => $"{p.Forename} {p.Surname}")))}.  They are all happy.";

@ strings can span multiple lines in C#, non-@ strings cannot. That's regardless of whether they're interpolations or not.

@CyrusNajmabadi
Copy link
Member

This part doesn't make sense:

... on save. This doesn't compile.

We don't manipulate code on save. So this must be some other tool. Need more info on a repro that causes this.

@CyrusNajmabadi CyrusNajmabadi added the Need More Info The issue needs more information to proceed. label Oct 26, 2022
@ghost
Copy link

ghost commented Nov 5, 2022

Closing this issue as we've seen no reply to the request for more information. If you are able to get the requested information, please add it to the issue and we will retriage it.

@ghost ghost closed this as completed Nov 5, 2022
Small Fixes automation moved this from InQueue to Completed Nov 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug Developer Community The issue was originally reported on https://developercommunity.visualstudio.com help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-Formatter Code formatter and/or smart indent Need More Info The issue needs more information to proceed.
Projects
Small Fixes
  
Completed
Development

No branches or pull requests

4 participants