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

Writing code to call a function using identifiers that don’t exist yet. #33667

Closed
ivanbasov opened this issue Feb 25, 2019 · 17 comments · Fixed by #38000
Closed

Writing code to call a function using identifiers that don’t exist yet. #33667

ivanbasov opened this issue Feb 25, 2019 · 17 comments · Fixed by #38000
Assignees
Labels
Area-IDE Bug IDE-IntelliSense Completion, Signature Help, Quick Info Regression
Milestone

Comments

@ivanbasov
Copy link
Contributor

Source: Scenario 1 at https://developercommunity.visualstudio.com/content/problem/465732/vs-2019-preview-3-intellisense-auto-selecting-para.html

Writing code to call a function using identifiers that don’t exist yet.

class Program
{
    static void Main ( string[] args )
    {
        var mySvc = new MyService(10, otherSvc, $$);
    }        
}

class MyService
{
    public MyService (int id, OtherService otherService, string name)
    {
    }
}

class OtherService
{
}

In this scenario I’ve just put the comma in the call to new MyService in Main. I now enter a variable name name that doesn’t exist yet. As soon as you hit space or a dot (because this is an object) then IS autocompletes to the name: parameter name. This isn’t what I wanted so I have to stop my typing, go back and correct to the variable (I haven’t defined yet) and then continue typing. In VS 2017 it doesn’t autocomplete to the parameter name. It does recognize that the parameter name is the best choice, it just doesn’t auto complete it.

Expected by user
var mySvc = new MyService(10, otherSvc, name);
Actual
var mySvc = new MyService(10, otherSvc, name:);
The behavior is the same with the old completion and the new completion. It seems it is caused by #26764

@ivanbasov ivanbasov added the Need Design Review The end user experience design needs to be reviewed and approved. label Feb 25, 2019
@ivanbasov
Copy link
Contributor Author

I actually do not think that the previous behavior was better than the new one. @CyrusNajmabadi , what do you think?

@ivanbasov ivanbasov added the IDE-IntelliSense Completion, Signature Help, Quick Info label Feb 25, 2019
@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Feb 25, 2019

Sorry, i'm confused by your repro. Can you clarify things like: I now enter a variable name name

Do you mean you're entering the characters name? or something else?

Please udpate the OP and let me know when it's done. I want to experiment with the correct repro steps myself once that is done.

@ivanbasov
Copy link
Contributor Author

Sorry, @CyrusNajmabadi !
Please type "na" and space in $$. The user expects "name" and this happens in VS 15.9. Currently both completions (old and new) add a colon "name:".

@CyrusNajmabadi
Copy link
Member

"Please type "na" and space in $$. The user expects "name" and this happens in VS 15.9. Currently both completions (old and new) add a colon "name:"."

if the user wanted "name" why did they write na<space> instead of 'name'? Since they're typing the name of something that doesn't exist, i woudl expect them to have to write out the entire name.

@CyrusNajmabadi
Copy link
Member

Note: i believe this has been the behavior ever since we added named param completion. Could you explain what behavior you woudl want, including for the customer that wants to type na<space> and get name: ?

@CyrusNajmabadi
Copy link
Member

for example, i do this all the time:

canc<space>

I know that this will select and insert cancellationToken: so that i can then continue from there. If you change this behavior you will badly break my muscle memory here.

@ivanbasov
Copy link
Contributor Author

"Please type "na" and space in $$. The user expects "name" and this happens in VS 15.9. Currently both completions (old and new) add a colon "name:"."

if the user wanted "name" why did they write na<space> instead of 'name'? Since they're typing the name of something that doesn't exist, i woudl expect them to have to write out the entire name.

Thank you, @CyrusNajmabadi !

  1. I'm totally fine with name:
  2. It seems that the user is used to get name with typing na<space>. This is the complain.
  3. I just would like to confirm with you that adding : was intentional. If so, we will just resolve the issue.

@CyrusNajmabadi
Copy link
Member

3\. I just would like to confirm with you that adding `:` was intentional. If so, we will just resolve the issue.

I believe so. But we should check. IIRC, we've had this behavior since forever. However, if we haven't we should try to preserve whatever we've been doing since like VS2010 onwards.

@ivanbasov
Copy link
Contributor Author

@CyrusNajmabadi , sorry! I'm not sure I understand you. There is a change between 15.9 and 16.0.
Here is 15.9:
name_no_colon

Here is 16.0:
name_colon

I typed name<space> in both cases. Sorry - not na<space> and I got different results.
I think this change is intentional and correct.
Do you agree?

@jinujoseph jinujoseph added the Bug label Feb 27, 2019
@jinujoseph jinujoseph added this to the 16.0 milestone Feb 27, 2019
@sharwell
Copy link
Member

@ivanbasov The colon should not be completed for these entries unless the commit character is :.

@ivanbasov
Copy link
Contributor Author

@ivanbasov The colon should not be completed for these entries unless the commit character is :.

@sharwell , why? VS does not know about the variable you may going to add in the future. However, it knows that there is a parameter with the corresponding name. Why should not it suggest the whole name: by typing space or Tab? I would not consider it as a regression but as an improvement. Not?

@sharwell
Copy link
Member

sharwell commented Feb 27, 2019

I have been hitting this frequently while trying to work in 16.0, where it inserts a : but the item I wanted was the name without the :. It worked great in 15.x.

@sharwell
Copy link
Member

See #32204

@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Feb 27, 2019

Yeah sorry for any previous confusion. My overall position is: don't change behavior here. We're already taking on a huge change just having a new completion infrastructure. let's try to keep behavior as consistent as possible. In the future, if we strongly feel like it's worthwhile, we can take targetted behavior changes if appropriate. But that should happen once all of completion has stabilized again.

@ivanbasov ivanbasov modified the milestones: 16.0, 16.1 Feb 28, 2019
@sharwell sharwell modified the milestones: 16.1, 16.1.P2 Apr 3, 2019
@sharwell
Copy link
Member

sharwell commented Apr 3, 2019

I still hit this all the time.

@ivanbasov ivanbasov modified the milestones: 16.1.P2, 16.0.P3 Apr 19, 2019
@jinujoseph jinujoseph removed this from the 16.0.P3 milestone Apr 23, 2019
@jinujoseph jinujoseph modified the milestones: 16.1.P3, 16.1 Apr 23, 2019
@ivanbasov ivanbasov modified the milestones: 16.1, 16.2 Apr 30, 2019
@jinujoseph jinujoseph added Need Design Review The end user experience design needs to be reviewed and approved. and removed Need Design Review The end user experience design needs to be reviewed and approved. labels Jun 9, 2019
@jinujoseph jinujoseph modified the milestones: 16.2, 16.3.P1 Jun 11, 2019
@jinujoseph jinujoseph removed the Need Design Review The end user experience design needs to be reviewed and approved. label Jun 17, 2019
@sharwell
Copy link
Member

sharwell commented Jul 6, 2019

Design review conclusion: To avoid muscle memory regressions, async completion in 16.x should be following the same behavior that 15.9 and earlier did for this scenario.

@jinujoseph jinujoseph modified the milestones: 16.3.P1, 16.3.P3, 16.3 Aug 5, 2019
@jinujoseph
Copy link
Contributor

reported at DC

@ivanbasov ivanbasov modified the milestones: 16.3, 16.4.P1 Aug 23, 2019
@sharwell sharwell moved this to Complete in IDE: Design review Aug 22, 2023
svick added a commit to postsharp/Metalama.Compiler that referenced this issue Jan 8, 2025
svick added a commit to postsharp/Metalama.Compiler that referenced this issue Jan 12, 2025
…initialization-exceptions

dotnet#33667 Improve reporting of exceptions in service initialization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug IDE-IntelliSense Completion, Signature Help, Quick Info Regression
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants