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

Extract method refactoring should handle tuples in VB #13278

Merged
merged 6 commits into from
Aug 24, 2016

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Aug 20, 2016

Refactorings involving a VB tuple type would result in Object instead of the proper tuple type.
That is fixed by the change in CreateSimpleTypeSyntax (matching the corresponding C# code).

Beyond that, there was also a (sneaky) issue with the simplification code. It would leave (System.Int32, System.Int32), instead of simplifying to (Integer, Integer).
This was caused by ExpressionSyntaxExpressions.TryReduce looking up the type for System.Int32 (see call to SimplificationHelpers.GetOriginalSymbolInfo) but finding no symbol. The fix is in SyntaxFacts.IsInTypeOnlyContext. It turns out the same fix was already introduced in C# for some other scenario...

@CyrusNajmabadi @VSadov @dotnet/roslyn-compiler for review.

Fixes #13042

@@ -2412,6 +2412,20 @@ System.ValueTuple`2[System.ValueTuple`2[System.Int32,System.Object],System.Value

]]>)
End Sub

<Fact(Skip:="https://github.com/dotnet/roslyn/issues/13277"), WorkItem(13277, "https://github.com/dotnet/roslyn/issues/13277")>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we put workitem on the next line. Also, generally try to avoid lines that are too long for github.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I split the line.

@CyrusNajmabadi
Copy link
Member

LGTM, but i think you could really simplify the construction of the node.

@jcouv jcouv force-pushed the vb-extract-method branch 2 times, most recently from 21cf0d5 to 9d70d38 Compare August 22, 2016 18:26
Public Async Function TestTuples() As Task

Await TestAsync(
NewLines("Class Program \n Sub Main(args As String()) \n [|Dim x = (1, 2)|] \n M(x) \n End Sub
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need this either. VB natively supports multiline string literals now :) SO just make a single string literal that contains the test you want.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see what you mean now. Fixed

@CyrusNajmabadi
Copy link
Member

👍

@jcouv
Copy link
Member Author

jcouv commented Aug 22, 2016

@VSadov Could you review this small change? Thanks

@jcouv
Copy link
Member Author

jcouv commented Aug 23, 2016

@VSadov Please review when you have some time. Thanks

@VSadov
Copy link
Member

VSadov commented Aug 23, 2016

LGTM

@jcouv
Copy link
Member Author

jcouv commented Aug 23, 2016

Thanks Vlad.
@dotnet/roslyn-compiler for a second compiler review. Thanks

@jcouv
Copy link
Member Author

jcouv commented Aug 24, 2016

@dotnet/roslyn-compiler for a second compiler review. Thanks

TypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
var vt2 = comp.CreateErrorTypeSymbol(null, "ValueTuple", 2).Construct(intType, intType);

Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(vt2, default(ImmutableArray<string>)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor point: Since elementNames argument is optional, consider dropping that parameter so it's clear the ArgumentException is from the vt2 argument.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

@cston
Copy link
Member

cston commented Aug 24, 2016

LGTM

@jcouv
Copy link
Member Author

jcouv commented Aug 24, 2016

Thanks! I'll wait for all-green, then merge.

@jcouv jcouv merged commit bcc8af4 into dotnet:master Aug 24, 2016
@jcouv jcouv deleted the vb-extract-method branch August 24, 2016 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VB tuples: Extract Method/Local for a tuple literal treats it as Object
5 participants