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 compoud assignment suggestion incorrect #53969

Closed
vsfeedback opened this issue Jun 9, 2021 · 3 comments · Fixed by #54324
Closed

Intellisense compoud assignment suggestion incorrect #53969

vsfeedback opened this issue Jun 9, 2021 · 3 comments · Fixed by #54324
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it

Comments

@vsfeedback
Copy link

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


[severity:Other]
For this code Intellisense suggest to use compound assignment, but it changes the behavior of the code.
Original code:

            bool alwaysTrue = true;
            int pkOrder = 0;
            int? current = null;
            for (int i = 0; i < 10; i++)
            {
                current = alwaysTrue == true ? pkOrder = pkOrder + 1 : null;
                Console.WriteLine(current);
            }

Results the following output:
1
2
3
4
5
6
7
8
9
10

Intellisense suggestion for this:

            bool alwaysTrue = true;
            int pkOrder = 0;
            int? current = null;
            for (int i = 0; i < 10; i++)
            {
                current = alwaysTrue == true ? pkOrder++ : null;
                Console.WriteLine(current);
            }

Results:

0
1
2
3
4
5
6
7
8
9


Original Comments

Feedback Bot on 6/8/2021, 06:22 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)

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 9, 2021
@RikkiGibson
Copy link
Contributor

Maybe if the result of the assignment is used then the refactoring should give ++expr, and otherwise should give expr++ for readability.

@CyrusNajmabadi
Copy link
Member

the above code makes me cry :) But i liek @RikkiGibson 's suggestion.

@CyrusNajmabadi CyrusNajmabadi added Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 10, 2021
@banditoth
Copy link

the above code makes me cry :) But i liek @RikkiGibson 's suggestion.

Made for demonstration purposes ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants