-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Remove dedicated tuple type symbol #39370
Conversation
15cb3e3
to
c517383
Compare
Any implication on hte public roslyn surface area here? would this be observable to clients of the API? i.e. would someone now see Generate TypeArguments on a tuple symbol where they didn't before? #Resolved |
@CyrusNajmabadi Yes, there is some impact. It is detailed here. For example, |
interesting! when you make the change LMK if there is any ide fallout. i'd be curious to see what sort of impact this has on consumptive code. Note: IDE has special serialization/deserializtion logic here for Tuples: https://github.com/dotnet/roslyn/blob/master/src/Workspaces/Core/Portable/SymbolKey/SymbolKey.TupleTypeSymbolKey.cs My hope is that you will be able to get rid of this almost entirely and just use the named-type-symbolkey serialization logic. Though... perhaps taht won't be possible since there still needs to be some way to funnel the element-names around. But perhaps we can unify this in some cleaner way versus what we have right now. Thanks! #Resolved |
ebe37eb
to
28692cc
Compare
bd53057
to
49f3922
Compare
8b5d7ff
to
a485e8a
Compare
88a8e27
to
16197a2
Compare
@@ -123,6 +124,10 @@ public override ImmutableArray<Location> Locations | |||
{ | |||
get | |||
{ | |||
if (IsTupleType) | |||
{ | |||
return TupleData.Locations; |
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.
Locations [](start = 37, length = 9)
I assume this is an improvement in the user experience. Nit: add an empty line after the }
, and in the next method too. #Resolved
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.
Yes, we need to keep locations pointing to where various tuples and tuple element names are defined in source.
Without this, GoToDefinition and FindAllReferences works badly.
In reply to: 357376280 [](ancestors = 357376280)
This is confusing. We didn't even give an error about it, we just emitted them? What if source had contained a private Refers to: src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs:5878 in e8059fb. [](commit_id = e8059fb, deletion_comment = False) |
No can do. This results in bad XML: In reply to: 565184831 [](ancestors = 565184831) Refers to: src/Compilers/CSharp/Portable/Symbols/Tuples/TupleTypeSymbol.cs:229 in e8059fb. [](commit_id = e8059fb, deletion_comment = False) |
Unsure (they are currently allowed, but I'm not sure if that's dangerous). I'd rather separate this question from this PR, as it is existing behavior. File an issue? In reply to: 565187780 [](ancestors = 565187780) Refers to: src/Compilers/CSharp/Portable/Symbols/Tuples/TupleTypeSymbol.cs:547 in e8059fb. [](commit_id = e8059fb, deletion_comment = False) |
I'm open to making this scenario an error, but I'm not sure how much I care. In reply to: 565645020 [](ancestors = 565645020) Refers to: src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs:5878 in e8059fb. [](commit_id = e8059fb, deletion_comment = False) |
Filed #40417 for "GetType" I think "ReferenceEquals" is okay, but we can discuss that in that issue. Thanks In reply to: 566164166 [](ancestors = 566164166,565187780) Refers to: src/Compilers/CSharp/Portable/Symbols/Tuples/TupleTypeSymbol.cs:547 in e8059fb. [](commit_id = e8059fb, deletion_comment = False) |
Done reviewing (Iteration 18). Only two remaining substantive comments: one in |
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 changes LGTM.
Dim actualNames = rootCodeModel.CodeElements.OfType(Of EnvDTE.CodeElement).Select(Function(e) e.Name).ToArray() | ||
Assert.Equal(names.Length, rootCodeModel.CodeElements.Count) |
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.
unintentional change? #Resolved
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.
This made debugging failures easier (you get to access the actualNames
local) #Resolved
@@ -421,7 +421,7 @@ public override object VisitNamedType(INamedTypeSymbol namedTypeSymbol) | |||
WriteType(SymbolKeyType.ErrorType); | |||
ErrorTypeSymbolKey.Create(namedTypeSymbol, this); | |||
} | |||
else if (namedTypeSymbol.IsTupleType) | |||
else if (namedTypeSymbol.IsTupleType && namedTypeSymbol.TupleUnderlyingType != namedTypeSymbol) |
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.
Should we be using the symbol comparer for comparing symbols? #Resolved
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.
All CI checks are passing. Overriding to merge. |
Yay, thanks! |
This lowers the minimum required VS version. Note: 3.4 introduces test failures related to tuple underlying type resolution - probably related to this change: dotnet/roslyn#39370
Fixes #20648
Makes tuples be generic types and removes the
TupleTypeSymbol
wrapping.Instead, we're adding tuple element names and virtual fields directly onto
NamedTypeSymbol
(storing them in an optionalTupleUncommonData
) withAddOrWrapTupleMembers
.Diagnostics now always prefer tuple syntax, while IL verification always uses
System.ValueTuple<...>
.Impacted APIs are
Arity
,TypeArguments
andOriginalDefinition
.VB will be handled separately, but following the same model.
The IDE code was updated:
ValueTupleRef
was added to the tests, which caused some refactorings to generate betterGetHashCode
methodsSystem.ValueTuple
definitionStatus: a couple of IDE tests are still failing.