dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.07k stars 4.04k forks source link

IntelliSense auto completion for known format string values #29921

Open vsfeedback opened 6 years ago

vsfeedback commented 6 years ago

For objects like DateTime or Int32 there's a known list of supported format strings, such as "s" for DateTime or "N0" for Int32. It'd be really helpful if IntelliSense knew about these and gave auto completion for them.

Outside of the few I use regularly I always have to refer back to the docs to see what the available options are along with the resulting output. What I'd like to see is a list of values such as: o - 2018-09-10T20:44:10.3523872-04:00 s - 2018-09-10T20:44:10

This issue has been moved from https://developercommunity.visualstudio.com/content/problem/332710/intellisense-auto-completion-for-known-format-stri.html VSTS ticketId: 681722 These are the original issue comments: (no comments) These are the original issue solutions: (no solutions)

CyrusNajmabadi commented 6 years ago

@sharwell @jinujoseph The virtualchar/embedded-language work i did could be helpful here. We could detect format strings and properly provide IDE services in them.

jinujoseph commented 6 years ago

cc @dpoeschl @ivanbasov

ivanbasov commented 6 years ago

Are we talking about the Watch window and the Immediate window? If so, we consider to implement this in VS for all languages not for Roslyn only. Are there any scenarios other than debugging in Watch/Immediate windows?

CyrusNajmabadi commented 6 years ago

@ivanbasov I don't think this has anything to do wit Watch/Immediate. This is just about general intellisense for VB/C#. i.e. when you type val.Format(" <-- here we should have help in intellisense for what you can legally type in that format string.

xt0rted commented 6 years ago

This was my request based on a feature of ReSharper which looks like this:

image

More info under Formatting Specifier Completion at https://blog.jetbrains.com/dotnet/2013/07/02/code-completion-improvements-in-resharper-8/

ivanbasov commented 6 years ago

Thank you for clarifications, @CyrusNajmabadi and @xt0rted ! Then, it should be implemented in Roslyn.

CyrusNajmabadi commented 6 years ago

@olegtk @dpoeschl Completion has the facility to place gray 'suffix' text after the complation item. However, i don't know if there's any facility to give the right-aligned example. Can you guys let me know if the VS completion system actually has a way of providing such a thing. It would also be super useful for the regex completion PR here: https://github.com/dotnet/roslyn/pull/27694

olegtk commented 6 years ago

I don't believe we support this. @AmadeusW? What about simpler form, were "long date" also goes into the suffix? [icon] D long date, e.g. Thursday, 10 April 2008

CyrusNajmabadi commented 6 years ago

@olegtk Is there any way for a 3rd party to get cutomization control here?

Note: as per https://github.com/dotnet/roslyn/pull/27694 i've found the suffix a bit not-great. Specifically, because it is left aligned, instead of right aligned. It ends up hurting readability here.

Would it be difficult to be able to add and expose this through the editor layer somehow?

olegtk commented 6 years ago

@AmadeusW ?

CyrusNajmabadi commented 6 years ago

Note: cases like tihs would also benefit from being able to get pretty fine-grained control over the individual runs. For example, even in the resharper image, it's not great that everything is variable width. You want all the format specifiers to be in a fixed-width font so they all align well.

JeWaVe commented 5 years ago

Please implement that feature for Single and Double as well. "G", "F17" etc drive me crazy everytime