-
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
Fix reference finding for tuple fields and anonymous type properties #69804
base: main
Are you sure you want to change the base?
Changes from 15 commits
29de8bb
1e5132f
2b9c62a
08fcd62
071e032
e72fae9
d951355
1d2622a
6c3cfe7
51b9253
cf79756
38309f1
1c3dfd1
70754f3
5adca8f
dbad8fb
8ba66b3
7b40bc8
48efc1f
df8c23e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -409,6 +409,227 @@ partial class Program | |
]]> | ||
</DocumentFromSourceGenerator> | ||
</Project> | ||
</Workspace> | ||
Await TestAPIAndFeature(input, kind, host) | ||
End Function | ||
|
||
<WorkItem("https://github.com/dotnet/roslyn/issues/52621")> | ||
<WpfTheory, CombinatorialData> | ||
Public Async Function TestImplicitlyNamedTuples(kind As TestKind, host As TestHost) As Task | ||
Dim input = | ||
<Workspace> | ||
<Project Language="C#" CommonReferencesNetCoreApp="true"> | ||
<Document><![CDATA[ | ||
using System; | ||
|
||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
int {|Definition:x|} = 4, y = 5; | ||
var z = ($$[|{|Definition:x|}|], y); | ||
z = ([|x|]: 0, y: 1); | ||
z = ([|x|]: y, y: [|x|]); | ||
} | ||
} | ||
]]> | ||
</Document> | ||
</Project> | ||
</Workspace> | ||
Await TestAPIAndFeature(input, kind, host) | ||
End Function | ||
|
||
<WorkItem("https://github.com/dotnet/roslyn/issues/52621")> | ||
<WpfTheory, CombinatorialData> | ||
Public Async Function TestImplicitTupleSwitchStatement(kind As TestKind, host As TestHost) As Task | ||
Dim input = | ||
<Workspace> | ||
<Project Language="C#" CommonReferencesNetCoreApp="true"> | ||
<Document><![CDATA[ | ||
using System; | ||
|
||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
int {|Definition:x|} = 4, y = 5; | ||
int z = 3; | ||
switch ($$[|{|Definition:x|}|], y) | ||
{ | ||
case (1, 0): | ||
z += [|x|]; | ||
break; | ||
case (1, 1): | ||
z += [|x|]; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
]]> | ||
</Document> | ||
</Project> | ||
</Workspace> | ||
Await TestAPIAndFeature(input, kind, host) | ||
End Function | ||
|
||
<WorkItem("https://github.com/dotnet/roslyn/issues/52621")> | ||
<WpfTheory, CombinatorialData> | ||
Public Async Function TestTupleDeconstruction(kind As TestKind, host As TestHost) As Task | ||
Dim input = | ||
<Workspace> | ||
<Project Language="C#" CommonReferencesNetCoreApp="true"> | ||
<Document><![CDATA[ | ||
using System; | ||
|
||
class C | ||
{ | ||
(int, int) M() | ||
{ | ||
return (1, 1); | ||
} | ||
|
||
void M2() | ||
{ | ||
int {|Definition:x|}; | ||
int y; | ||
|
||
($$[|{|Definition:x|}|], y) = M(); | ||
|
||
[|x|] = 0; | ||
} | ||
} | ||
]]> | ||
</Document> | ||
</Project> | ||
</Workspace> | ||
Await TestAPIAndFeature(input, kind, host) | ||
End Function | ||
|
||
<WorkItem("https://github.com/dotnet/roslyn/issues/52621")> | ||
<WpfTheory, CombinatorialData> | ||
Public Async Function TestTupleSwappedFields(kind As TestKind, host As TestHost) As Task | ||
Dim input = | ||
<Workspace> | ||
<Project Language="C#" CommonReferencesNetCoreApp="true"> | ||
<Document><![CDATA[ | ||
using System; | ||
|
||
class C | ||
{ | ||
void M(int {|Definition:left|}, int right) | ||
{ | ||
var r = ($$[|{|Definition:left|}|], right); | ||
r = (right, [|{|Definition:left|}|]); | ||
} | ||
} | ||
]]> | ||
</Document> | ||
</Project> | ||
</Workspace> | ||
Await TestAPIAndFeature(input, kind, host) | ||
End Function | ||
|
||
<WorkItem("https://github.com/dotnet/roslyn/issues/52621")> | ||
<WpfTheory, CombinatorialData> | ||
Public Async Function TestTupleNonLocal(kind As TestKind, host As TestHost) As Task | ||
Dim input = | ||
<Workspace> | ||
<Project Language="C#" CommonReferencesNetCoreApp="true"> | ||
<Document><![CDATA[ | ||
using System; | ||
|
||
class C | ||
{ | ||
int {|Definition:Property|} { get; set; } | ||
|
||
void M(string a) | ||
{ | ||
var r = (a.Length, $$[|{|Definition:Property|}|]); | ||
r = ([|Property|], [|Property|]: [|Property|]); | ||
} | ||
} | ||
]]> | ||
</Document> | ||
</Project> | ||
</Workspace> | ||
Await TestAPIAndFeature(input, kind, host) | ||
End Function | ||
|
||
<WorkItem("https://github.com/dotnet/roslyn/issues/52621")> | ||
<WpfTheory, CombinatorialData> | ||
Public Async Function TestTupleExplicitNames(kind As TestKind, host As TestHost) As Task | ||
Dim input = | ||
<Workspace> | ||
<Project Language="C#" CommonReferencesNetCoreApp="true"> | ||
<Document><![CDATA[ | ||
using System; | ||
|
||
class C | ||
{ | ||
void M(int a, int b) | ||
{ | ||
var t = ($$[|{|Definition:x|}|]: a, y: b); | ||
t = ([|x|]: b, y: a); | ||
b = t.[|x|]; | ||
} | ||
} | ||
]]> | ||
</Document> | ||
</Project> | ||
</Workspace> | ||
Await TestAPIAndFeature(input, kind, host) | ||
End Function | ||
|
||
<WorkItem("https://github.com/dotnet/roslyn/issues/52621")> | ||
<WpfTheory, CombinatorialData> | ||
Public Async Function TestTupleExplicitNamesSameAsLocals01(kind As TestKind, host As TestHost) As Task | ||
Dim input = | ||
<Workspace> | ||
<Project Language="C#" CommonReferencesNetCoreApp="true"> | ||
<Document><![CDATA[ | ||
using System; | ||
|
||
class C | ||
{ | ||
void M(int x, int y) | ||
{ | ||
var t = ($$[|{|Definition:x|}|]: x, y: y); | ||
t = ([|x|]: y, y: x); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add test where there is also an implicit name. i.e. |
||
t = ([|x|]: x, y: y); | ||
b = t.[|x|]; | ||
} | ||
} | ||
]]> | ||
</Document> | ||
</Project> | ||
</Workspace> | ||
Await TestAPIAndFeature(input, kind, host) | ||
End Function | ||
|
||
<WorkItem("https://github.com/dotnet/roslyn/issues/52621")> | ||
<WpfTheory, CombinatorialData> | ||
Public Async Function TestTupleExplicitNamesSameAsLocals02(kind As TestKind, host As TestHost) As Task | ||
Dim input = | ||
<Workspace> | ||
<Project Language="C#" CommonReferencesNetCoreApp="true"> | ||
<Document><![CDATA[ | ||
using System; | ||
|
||
class C | ||
{ | ||
void M(int {|Definition:x|}, int y) | ||
{ | ||
var t = (x: $$[|x|], y: y); | ||
t = (x: y, y: [|x|]); | ||
t = (x: [|x|], y: y); | ||
b = t.x; | ||
} | ||
} | ||
]]> | ||
</Document> | ||
</Project> | ||
</Workspace> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm finding the tests hard to totally understand because they don't show both implicit and explicit named-props in anonymous-types, and implicit and explicit arguments for tuples. |
||
Await TestAPIAndFeature(input, kind, host) | ||
End Function | ||
|
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.
add an example where there is a named-arg for 'a'. like
new { a = "", ...}
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.
add test where the $$ is on the defintion. add test where $$ is on the
a
innew { a = "", ...