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

Command to show or copy value of string literal #31842

Closed
Neme12 opened this issue Dec 16, 2018 · 5 comments
Closed

Command to show or copy value of string literal #31842

Neme12 opened this issue Dec 16, 2018 · 5 comments
Labels
Area-IDE Feature Request help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@Neme12
Copy link
Contributor

Neme12 commented Dec 16, 2018

String literals can be complicated. They have escape characters, verbatim string literals have double quotes, interpolated string literals have double curlies... It would be nice to have either a command that would

  • Copy the value of the string literal to the clipboard
    or
  • Show a dialog with the (possibly multiline) text, which would make it easy to see and copy the value. This should be the same dialog that is shown when debugging:
    image

I also propose that this command work not only on regular string literals, but on interpolated strings as well. It would have to either remove the interpolated part altogether or replace it with some kind of a marker.

This would be extremely useful for scenarios like this:

        [Theory, Trait(Traits.Feature, Traits.Features.TypeInferenceService)]
        [InlineData("IAsyncEnumerable")]
        [InlineData("IAsyncEnumerator")]
        [InlineData("InvalidGenericType")]
        public async Task TestYieldReturnInAsyncMethod(string returnTypeName)
        {
            var markup =
$@"namespace System.Collections.Generic
{{
    interface {returnTypeName}<T> {{ }}
    class C
    {{
        async {returnTypeName}<int> M()
        {{
            yield return [|abc|]
        }}
    }}
}}";
            await TestAsync(markup, "global::System.Int32");
        }

Getting the raw string value from this (so that I can test this manually or just see that this represents the string I want it to represent and I didn't make a mistake when escaping) is a very tedious, slow and error-prone task. I have to copy the inside of the string literal, then replace all double curlies & replace all double quotes.

@CyrusNajmabadi
Copy link
Member

Nifty idea. @tmat Do you know if hte debuger text-visualizer dialog is available in some manner for other code to call into outside of a debugging session?

@tmat
Copy link
Member

tmat commented Dec 17, 2018

I doubt it is.

@CyrusNajmabadi
Copy link
Member

Pity. @Neme12 I'd likely start just by implementing this as a lightbulb option on string literals then.

@vatsalyaagrawal vatsalyaagrawal added Area-IDE Feature Request Need Design Review The end user experience design needs to be reviewed and approved. labels Dec 18, 2018
@vatsalyaagrawal vatsalyaagrawal added this to the Backlog milestone Dec 18, 2018
@jinujoseph jinujoseph added help wanted The issue is "up for grabs" - add a comment if you are interested in working on it and removed Need Design Review The end user experience design needs to be reviewed and approved. labels Jul 1, 2019
@jinujoseph
Copy link
Contributor

Design Meeting Notes
This will be a very useful feature for string esp for json and such. May be good to show for constant expression as well.

May be related to #31869 cc @sharwell

@CyrusNajmabadi
Copy link
Member

Closing out due to lack of feedback.

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 20, 2024
@dotnet dotnet locked as resolved and limited conversation to collaborators Oct 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area-IDE Feature Request help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
Status: Complete
Development

No branches or pull requests

5 participants