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

Typing "override" gives no suggestion based on the base class. #1044

Closed
AlexandreFiset opened this issue Dec 15, 2016 · 51 comments · Fixed by #3986
Closed

Typing "override" gives no suggestion based on the base class. #1044

AlexandreFiset opened this issue Dec 15, 2016 · 51 comments · Fixed by #3986

Comments

@AlexandreFiset
Copy link

Environment data

dotnet --info output:
VS Code version: 1.8.0
C# Extension version: 1.5.3

Steps to reproduce

  1. Create a class.
  2. Create a virtual/abstract method.
  3. Create a new class that derives from class 1.
  4. Type "override".
  5. Notice there is no autocomplete as opposed to Monodevelop and VS2015 that both support this awesome, practical behaviour.

Expected behavior

Typing "override" should show me a list of all possible overrides from base class.

Actual behavior

Typing "override" gives no suggestion based on the base class.

@grzegorz-herman
Copy link

I second this request. When inheriting generic base classes with elaborate type arguments, not having to re-type the signatures would save a lot of energy!

@Leopotam
Copy link
Contributor

Leopotam commented Jan 2, 2017

+1 - i have alot of pain each time for searching parent class with method signature (it can be down 2-4 levels of abstraction sequence), want to write "override" keyword and select method from list.

@juanfornospomelo
Copy link

+1

@appetizermonster
Copy link

+1

@Leopotam
Copy link
Contributor

@DustinCampbell multiple requests during last 3 months - no assignees. Can we know devs plans about this problem?

@DustinCampbell
Copy link
Member

The work is primarily in omnisharp-roslyn, where we need to create a new endpoint. It's on my list, but at the moment, all work goes serially through me. So, as I work through the backlog in priority order, I'll get to it.

Do note that this is an open source project and we're accepting contributions! 😄

@chuckries
Copy link
Contributor

@DustinCampbell I'd be interested in taking a shot at this, but I really have no clue what's going on. I set up a debuggable Omnisharp on my box and hooked it up to VS Code. All I've determined so far is that after typing 'override' and a space, the csharp intellisense service is not getting an AutocompleteRequest. Any suggestions on where to go from there?

@DustinCampbell
Copy link
Member

DustinCampbell commented Mar 23, 2017

In the VS Code extension, you'll need to ensure that completion can trigger on a space character (assuming that's possible).

@chuckries
Copy link
Contributor

There are some immediate issues with this. If we include the space character as a completion target, the full completion list appears on every space. It does not look like vscodes 'provideCompletionItems' gives any indication of whether the autcomplete was triggered automatically by typing or manually by a gesture (ctrl + space being the default).

I know VS IDE's behavior is to show the completion list for override items on space after 'override'. Maybe here we include these items when typing override?

@DustinCampbell
Copy link
Member

Note: You'd need to update OmniSharp itself to make this work. This can't be done via extension alone and requires a new endpoint to be added to OmniSharp.

I would prefer to replicate Visual Studio's behavior here if we can. We have a goal of making features which are heavy on muscle memory somewhat consistent within the Visual Studio family.

@chuckries
Copy link
Contributor

Even with the correct endpoint in place on the server, I'm not sure how we could get the extension to trigger the request at the right time.

@DustinCampbell
Copy link
Member

Sure we can. We need a new endpoint in the OmniSharp server and the extension would stop listening to the old /autocomplete endpoint. The new endpoint would essentially be a passthrough to the Roslyn CompletionService API. That API provides a lot more smarts about whether a list should trigger or not.

@chuckries
Copy link
Contributor

I'm a little confused, it looks like the existing AutoComplete endpoint is using Roslyn's CompletionService. In fact, the CompletionService is actually giving me the correct completions for override:
image

These are getting dropped on the floor because they are not keywords.

Is a new server endpoint part of a bigger work item?

@DustinCampbell
Copy link
Member

Yes, it is part of a bigger work item. Today, we only use it for keywords because of backward compatibility of the /autocomplete endpoint with other OmniSharp editors (like VIM, Emacs, Sublime, Atom, etc.). In addition, the /autocomplete endpoint is not suitable for all of the information that can be returned by the Roslyn CompletionService.

That bigger work item is tracked here: OmniSharp/omnisharp-roslyn#78.

@chuckries
Copy link
Contributor

I see. I think in that case I'll bow out. Thanks for the info!

@chuckries
Copy link
Contributor

FWIW, I still think you will run into issues on the VS Code side. You will need to begin triggering autocomplete v2 requests on space. This will cause available 'recommended symbols' to show up on every space.

@DustinCampbell
Copy link
Member

Only if the new service allows triggers on space. The Roslyn CompletionService allows completion to be triggered differently depending on what character was typed and what the current position is in the syntax tree. So, it returns a completion list when SPACE is typed after "override" and "new". It won't return a list at all in other situations.

@chuckries
Copy link
Contributor

chuckries commented Mar 23, 2017

Today's implementation gets the completion list and then appends all 'recommended symbols' for the position as well.

                var model = await document.GetSemanticModelAsync();
                var symbols = await Recommender.GetRecommendedSymbolsAtPositionAsync(model, position, _workspace);

If the extension queries Omnisharp on SPACE, even though Roslyn's CompletetionService returns no completions, the list of recommended symbols would still be returned and shown on every SPACE. It seems like we would want to show recommended symbols ONLY if the autocomplete was triggered manually with a gesture (ctrl + SPACE). VS Code's API does not allow you to determine if the autcomplete is triggered manually or not.

@DustinCampbell
Copy link
Member

Yes. I know that's how it works today. That code would all go away with the new end point.

@DustinCampbell
Copy link
Member

The thing that might not be clear is that this would be a brand new end point that lives next to autocomplete. It would all be new code that just talks to Roslyn's CompletionService.

@chuckries
Copy link
Contributor

The issues I think I am seeing all relate to querying Omnisharp from the extension, regardless of new endpoint. In VS there are instances where intellisense shows nothing until you manually invoke it using ctrl + SPACE. If we want to show autcomplete after the override keyword, the extension must be invoking it's completionProvider on SPACE. On most SPACE's, there will be no autcompletes to show. However, the user may want to manually invoke autcomplete to show recommendations. I do not believe VS Code will allow you to distinguish between these two. A space and a ctrl + space would trigger the exact same request.

@DustinCampbell
Copy link
Member

Space and Ctrl+Space should trigger the same request. This is something we've been trying to move toward in VS.

@chuckries
Copy link
Contributor

Thank you for your patience and information. I am asking simply because I am interested in this space. I am curious what the plan is for cases where there are no autocomplete items, but the user may want to invoke intellisense with ctrl + SPACE in order to see available suggestions that are not necessarily autocomplete items. For example, if I type int i = followed by a SPACE, there are no autocomplete items but I may want to invoke Intellisense with ctrl + SPACE to see all available suggestions.

@DustinCampbell
Copy link
Member

Correct. After typing int i = followed by SPACE, the Roslyn CompletionService won't return a completion list. The issue here is that OmniSharp will need a completion end point that allows different triggers to be specified by the VS Code extension. Roslyn distinguishes between typing as a trigger (e.g. SPACE) and an invocation of the list (e.g. CTRL+SPACE).

@chuckries
Copy link
Contributor

that allows different triggers to be specified by the VS Code extension

I think this may be an issue. I couldn't find any way to distinguish these triggers from the VS Code endpoint. VS Code's API reports SPACE and CTRL+SPACE as identical triggers.

@DustinCampbell
Copy link
Member

If that's the case, we'll probably need an ask on VS Code to help us distinguish between them.

@appetizermonster
Copy link

Is there any news? 😃

@Leopotam
Copy link
Contributor

appetizermonster

Assignees
No one assigned

I think, no. You can check commits, logging and addiing TODO-s comments more important than basic language features :)

@pedro15
Copy link

pedro15 commented Oct 7, 2017

Any news ?? :D

@DustinCampbell
Copy link
Member

@pedro15: A crude form of override completion is already present. It just doesn't trigger on SPACE. You have type the first character of the override method.

@pedro15
Copy link

pedro15 commented Oct 8, 2017

@DustinCampbel Thanks !

@AlexandreFiset
Copy link
Author

As of the latest version of both VSCode and OmniSharp (October 10th), the auto-complete for overriding of methods still isn't implemented.

If you were to override MyMethod (int myInt), you would have to manually type the requirement, plus do all the formatting by yourself.

Yes, typing "override M" now gives me the name of the base method, but at the bottom of the list of suggestions (even if that is the only method to override) and with no autoformat.

Again a deal breaker to me. I can't believe people are using VSCode; even Monodevelop is vastly superior.

Going back to Visual Studio.

@DustinCampbell
Copy link
Member

@AlexandreFiset: Thanks for the feedback! I agree that this is an important feature, and there are a couple of active pull requests that bring this particular completion list feature much closer to being implemented. That said, do note that C# for VS Code is an open source project. So, if you're passionate about a particular feature and have some spare cycles, feel free to contribute. We'd be happy to work with you to get a pull request merged.

@AlexandreFiset
Copy link
Author

@DustinCampbell I understand that and unfortunately with my company and the growing team I can't really invest time in other projects for the time being. That being said, I left a comment to avoid other people wasting their time installing VSCode and hit the same wall as I did. I'll try to budget some resources to help out in the future.

@P-Daddy
Copy link

P-Daddy commented Nov 4, 2017

@AlexandreFiset : I think you're being a bit harsh. I don't think anybody's "wasting their time" by installing VS Code. All in all, it's an excellent product, and it keeps getting better, and OmniSharp really takes it a long way toward being a full Visual Studio replacement.

Yes, there are a couple of things that it still doesn't do quite as well as Visual Studio, including this issue, but it doesn't make sense that that would cause you to be so incredulous that people would still find it a highly useful tool, or for you to describe it as "vastly" inferior to MonoDevelop (which is also worthy of far more esteem than you seem to hold for it).

In many ways, I find VS Code superior to VS proper. It's a lot faster, and it uses a lot less RAM (especially over time ... VS seems to leak). Its hot exit feature is a whole world better than Visual Studio's backup feature. It's more configurable (and it's easier to find configuration options by searching for them than by navigating a tree). It's a lot easier to use it with non .NET languages. Its command palette is a more developer-friendly method of accessing features. And let's not forget that it does all this equally well (as far as I know) on Windows, OS X, and Linux, and that it's free and open source.

As for me, anyway, I'm grateful to @DustinCampbell, @bpasero, and their teams for putting together a pretty amazing tool and to @microsoft for giving it away.

@AbhimanyuAryan
Copy link

Looking forward to this. Anytime timeline/roadmap when will this fix?

@helios02
Copy link

Any update on auto-completing method signatures for overrides? Thanks.

@bugproof
Copy link

bugproof commented Sep 21, 2018

@P-Daddy using vs code instead of vs or anything more full-blown might have advantages you mentioned about but I think the drawback is productivity, you're way more productive using full-blown IDEs(with let's say ReSharper) than omnisharp with an editor like vs-code (at least at this moment). If you have a good hardware, running full-blown IDE is not that slow in my experience.

the issue here is showing the drawbacks, but omnisharp still isn't perfect and it might change in the future

VS or Rider is way more superior for serious dotnet development.

@Leopotam
Copy link
Contributor

Leopotam commented Sep 21, 2018

@Necronux why not stop developing omnisharp-vscode then? What is main goal of this extension?

@bugproof
Copy link

bugproof commented Sep 22, 2018

@Leopotam I'm not saying it's worthless, but I'm saying it's still far behind full-blown IDEs to be productive with it. You will certainly spend more time writing some piece of code with omnisharp-vscode than with vs or rider.

It's meant to be lightweight but we aren't there yet with features to compete with IDEs.

btw.

Omnisharp itself(the server) is not even documented. IIRC it has some kind of HTTP API but it's not documented anywhere so I can't even imagine the pain to get started if you wanted to contribute to omnisharp-vscode

@sattha
Copy link

sattha commented Mar 28, 2019

+1 still hope for this in 2019

@keithelder
Copy link

@DustinCampbell I just ran into this and sitting here thinking I was doing something weird in VSCode by not getting the return arguments from the method I override. Is it time to start with beer bribery to maybe get this implemented? :)

@bysameng
Copy link

I check back every hundred times Visual Studio Mac hangs and crashes on me (so every week?) hoping this is implemented. I sadly am just not nearly as productive without this feature.

I'd love to support this in some way so I can finally switch to VS Code.

@kasradzenika
Copy link

1,188 days later...

@hermitcat
Copy link

1,188 days later...

Created a github account just to second this.

@webczat
Copy link

webczat commented Apr 10, 2020

now that seems to partially work for me except it does not put the return type, and doesn't type the accessibility modifier. So I have to guess more or less. Still better than nothing though

@FreshlyBrewedCode
Copy link

+1 current workaround for this is to hit CTRL+. on the class definition and select "Generate overrides".

@Koopa1018
Copy link

Koopa1018 commented May 3, 2020

+1 current workaround for this is to hit CTRL+. on the class definition and select "Generate overrides".

Didn't know about that shortcut. Thanks!

@toptensoftware
Copy link

+1 for this.

As temporary stop gap until the "override" + space can be made to work properly, any chance of "Generate override" command? Basically the same as the "Generate overrides" command, but instead of generating all available overrides prompts for which method to override?

Also, there probably shouldn't be ellipsis on the "Generate Overrides..." command as it doesn't prompt before it does its thing. Nor on the other Generate commands for that matter.

Brad

@gzz100
Copy link

gzz100 commented Jul 10, 2020

+1

@NemoStein
Copy link

No one assigned for

  • 114,307,200 seconds
  • 1,905,120 minutes
  • 31,752 hours
  • 1323 days

Or 3 years, 7 months, 15 days and counting...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.