-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Fixes #18311 - Incorrect quick info for ValueTuple<T> #18489
Conversation
Need tests :) They can be added to: https://github.com/dotnet/roslyn/blob/master/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs Also, tagging @dotnet/roslyn-compiler as this changes compiler code. |
Fixing tests |
Also, does the same issue for VB? If so, we should fix that as well. |
VB is ok. Working on new tests. |
If there is any chance this same method is invoked again on the "rest" of the tuple (which nests the elements after the 7th), I'd recommend testing the case of an 8-tuple: |
Nice. LGTM and thanks! |
@@ -381,6 +381,11 @@ private bool CanUseTupleTypeName(INamedTypeSymbol tupleSymbol) | |||
{ | |||
INamedTypeSymbol currentUnderlying = tupleSymbol.TupleUnderlyingType; | |||
|
|||
if (currentUnderlying.Arity == 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be <= 1? Is there a similar issue with zero arity value tuples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For < 1 case CanUseTupleTypeName
method is not called. For zero arity everything works fine.
Still need quick info tests. Thanks! :) |
Need help. Cannot make unit test to work properly. |
Do you have the right usings in place in the test? |
Note: look at TestResources.NetFX.ValueTuple.tuplelib_cs as well. It appears as if some tests manually concat that in to get the definition of ValueTuple, since it's not part of mscorlib. |
I am using
|
You'll need to manually include the source for ValueTuple into the test. The mscorlib used in tests doesn't have ValueTuple yet. |
Thanks could fix the issue. Working on new tests. |
Your "Adding new tests" commit doesn't seem to be adding any new tests :) |
Sorry, committed wrong file. Fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDE side lgtm. Still needs compiler review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@dotnet/roslyn-compiler for a second review of the compiler change. |
Squashed commits for next review |
IL_0006: ldloc.0 | ||
IL_0007: ldfld ""(int) System.ValueTuple<int, int, int, int, int, int, int, (int)>.Rest"" | ||
IL_0007: ldfld ""ValueTuple<int> System.ValueTuple<int, int, int, int, int, int, int, ValueTuple<int>>.Rest"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The corresponding VB test should have required the same change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➡️ As an update, this is now corrected.
Consider adding a simple |
Updated VB logic and tests. Working on new symbol display tests. |
I believe the conclusion in #18298 was we want to display |
@dopare It's possible that this pull request fixed the following issue which I found during an investigation of #15508. If that is the case, then this pull request likely fixes the last remaining issue with that issue. void Foo()
{
ValueTuple<int> y = ValueTuple.Create(1);
y.Item1.ToString(); // Extract method for this line crashes the refactoring provider
} |
Added simple symbol display tests for C# and VB. |
@sharwell I have manually tested this in latest Visual Studio 2017 with and without my changes. Without my changes With my changes I could extract following method:
|
LGTM thanks. |
Squashed all commits |
@dopare The Extract Method tests are in ExtractMethodTests.cs and ExtractMethodTests.vb. I'm planning to add tests for the case I mentioned after this PR is merged, but if you want to tackle them now that you already fixed the issue feel free to. 😄 |
@sharwell Will add those tests. |
@sharwell Added new extract method tests for C# and VB. |
Look at @dopare, doing my work for me. 😎 |
Wow thanks 👍 |
Fixes #18311
Closes #15508
Hovering
var
will showSystem.ValueTuple<System.Int32>
Hovering
y
will show(local variable) ValueTuple<int> y