提交 0a387174 编写于 作者: V Vladimir Sadov 提交者: GitHub

Merge pull request #16805 from VSadov/fix14600

Some more automated tests and test cleanup for the PR#16659
...@@ -4,12 +4,13 @@ Imports System.Threading.Tasks ...@@ -4,12 +4,13 @@ Imports System.Threading.Tasks
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
Partial Public Class FindReferencesTests Partial Public Class FindReferencesTests
Dim tuple2Doc As XElement =
<Document> Dim tuple2 As XCData =
<![CDATA[
namespace System namespace System
{ {
// struct with two values // struct with two values
public struct ValueTuple&lt;T1, T2> public struct ValueTuple<T1, T2>
{ {
public T1 Item1; public T1 Item1;
public T2 Item2; public T2 Item2;
...@@ -26,14 +27,13 @@ namespace System ...@@ -26,14 +27,13 @@ namespace System
} }
} }
} }
</Document> ]]>
<WpfFact, Trait(Traits.Feature, Traits.Features.FindReferences)> <WpfFact, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestTupleFieldSameTuples01() As Task Public Async Function TestTupleFieldSameTuples01() As Task
Dim input = Dim input =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document><![CDATA[ <Document><![CDATA[
class Program class Program
...@@ -48,6 +48,8 @@ namespace System ...@@ -48,6 +48,8 @@ namespace System
} }
]]> ]]>
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -59,7 +61,6 @@ namespace System ...@@ -59,7 +61,6 @@ namespace System
Dim input = Dim input =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document><![CDATA[ <Document><![CDATA[
class Program class Program
...@@ -74,6 +75,7 @@ namespace System ...@@ -74,6 +75,7 @@ namespace System
} }
]]> ]]>
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -85,7 +87,6 @@ namespace System ...@@ -85,7 +87,6 @@ namespace System
Dim input = Dim input =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document><![CDATA[ <Document><![CDATA[
class Program class Program
...@@ -100,6 +101,8 @@ namespace System ...@@ -100,6 +101,8 @@ namespace System
} }
]]> ]]>
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -111,7 +114,6 @@ namespace System ...@@ -111,7 +114,6 @@ namespace System
Dim input = Dim input =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document><![CDATA[ <Document><![CDATA[
class Program1 class Program1
...@@ -130,6 +132,8 @@ namespace System ...@@ -130,6 +132,8 @@ namespace System
} }
]]> ]]>
<%= tuple2 %>
</Document> </Document>
<Document><![CDATA[ <Document><![CDATA[
...@@ -156,7 +160,6 @@ namespace System ...@@ -156,7 +160,6 @@ namespace System
Dim input = Dim input =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document><![CDATA[ <Document><![CDATA[
class Program class Program
...@@ -171,6 +174,8 @@ namespace System ...@@ -171,6 +174,8 @@ namespace System
} }
]]> ]]>
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -182,7 +187,6 @@ namespace System ...@@ -182,7 +187,6 @@ namespace System
Dim input = Dim input =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document><![CDATA[ <Document><![CDATA[
class Program class Program
...@@ -197,6 +201,8 @@ namespace System ...@@ -197,6 +201,8 @@ namespace System
} }
]]> ]]>
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -208,7 +214,6 @@ namespace System ...@@ -208,7 +214,6 @@ namespace System
Dim input = Dim input =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document><![CDATA[ <Document><![CDATA[
class Program class Program
...@@ -224,11 +229,122 @@ namespace System ...@@ -224,11 +229,122 @@ namespace System
} }
]]> ]]>
<%= tuple2 %>
</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestTupleFieldItem01() As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document><![CDATA[
class Program
{
static void Main(string[] args)
{
var x = ({|Definition:Alice|}:1, Bob: 2);
var y = (Alice:1, Bob: 2);
var z = x.$$[|Item1|];
}
}
]]>
<%= tuple2 %>
</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestTupleFieldItem02() As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document><![CDATA[
class Program
{
static void Main(string[] args)
{
var x = ($$[|{|Definition:Alice|}|]:1, Bob: 2);
var y = ([|Alice|]:1, Bob: 2);
var z = x.Item1;
}
}
]]>
<%= tuple2 %>
</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestTupleFieldItem03() As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document><![CDATA[
class Program
{
static void Main(string[] args)
{
var x = ({|Definition:1|}, Bob: 2);
var y = (Alice:1, Bob: 2);
var z = x.$$[|Item1|];
var z1 = x.[|Item1|];
}
}
]]>
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
Await TestAPIAndFeature(input) Await TestAPIAndFeature(input)
End Function End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestTupleFieldItem04() As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document><![CDATA[
class Program
{
static void Main(string[] args)
{
System.ValueTuple<int, int> x = (1, Bob: 2);
var y = (Alice:1, Bob: 2);
var z = x.$$[|Item1|];
var z1 = x.[|Item1|];
}
}
]]>
<%= tuple2 %>
</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input)
End Function
End Class End Class
End Namespace End Namespace
...@@ -768,12 +768,12 @@ class C ...@@ -768,12 +768,12 @@ class C
#End Region #End Region
#Region "CSharp TupleTests" #Region "CSharp TupleTests"
Dim tuple2Doc As XElement = Dim tuple2 As XCData =
<Document> <![CDATA[
namespace System namespace System
{ {
// struct with two values // struct with two values
public struct ValueTuple&lt;T1, T2> public struct ValueTuple<T1, T2>
{ {
public T1 Item1; public T1 Item1;
public T2 Item2; public T2 Item2;
...@@ -790,14 +790,13 @@ namespace System ...@@ -790,14 +790,13 @@ namespace System
} }
} }
} }
</Document> ]]>
<WpfFact, Trait(Traits.Feature, Traits.Features.GoToDefinition)> <WpfFact, Trait(Traits.Feature, Traits.Features.GoToDefinition)>
Public Async Function TestCSharpGotoDefinitionTupleFieldEqualTuples01() As Task Public Async Function TestCSharpGotoDefinitionTupleFieldEqualTuples01() As Task
Dim workspace = Dim workspace =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document> <Document>
class Program class Program
{ {
...@@ -811,6 +810,8 @@ namespace System ...@@ -811,6 +810,8 @@ namespace System
var z2 = y.Alice; var z2 = y.Alice;
} }
} }
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -849,7 +850,6 @@ namespace System ...@@ -849,7 +850,6 @@ namespace System
Dim workspace = Dim workspace =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document> <Document>
class Program class Program
{ {
...@@ -860,6 +860,8 @@ namespace System ...@@ -860,6 +860,8 @@ namespace System
var z = x.$$Program; var z = x.$$Program;
} }
} }
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -872,7 +874,6 @@ namespace System ...@@ -872,7 +874,6 @@ namespace System
Dim workspace = Dim workspace =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document> <Document>
class Program class Program
{ {
...@@ -883,6 +884,8 @@ namespace System ...@@ -883,6 +884,8 @@ namespace System
var z = x.Program; var z = x.Program;
} }
} }
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -895,7 +898,6 @@ namespace System ...@@ -895,7 +898,6 @@ namespace System
Dim workspace = Dim workspace =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document> <Document>
class Program class Program
{ {
...@@ -906,6 +908,8 @@ namespace System ...@@ -906,6 +908,8 @@ namespace System
var z = x.$$Program; var z = x.$$Program;
} }
} }
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -918,7 +922,6 @@ namespace System ...@@ -918,7 +922,6 @@ namespace System
Dim workspace = Dim workspace =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document> <Document>
class Program class Program
{ {
...@@ -929,6 +932,8 @@ namespace System ...@@ -929,6 +932,8 @@ namespace System
var z1 = x.$$Alice; var z1 = x.$$Alice;
} }
} }
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -941,7 +946,6 @@ namespace System ...@@ -941,7 +946,6 @@ namespace System
Dim workspace = Dim workspace =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document> <Document>
class Program class Program
{ {
...@@ -952,6 +956,8 @@ namespace System ...@@ -952,6 +956,8 @@ namespace System
var z1 = x.Alice; var z1 = x.Alice;
} }
} }
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -964,7 +970,6 @@ namespace System ...@@ -964,7 +970,6 @@ namespace System
Dim workspace = Dim workspace =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document> <Document>
class Program class Program
{ {
...@@ -975,6 +980,8 @@ namespace System ...@@ -975,6 +980,8 @@ namespace System
var z1 = x.$$Item1; var z1 = x.$$Item1;
} }
} }
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -987,7 +994,6 @@ namespace System ...@@ -987,7 +994,6 @@ namespace System
Dim workspace = Dim workspace =
<Workspace> <Workspace>
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<%= tuple2Doc %>
<Document> <Document>
class Program class Program
{ {
...@@ -998,6 +1004,8 @@ namespace System ...@@ -998,6 +1004,8 @@ namespace System
var z1 = x.$$Item1; var z1 = x.$$Item1;
} }
} }
<%= tuple2 %>
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -1005,6 +1013,29 @@ namespace System ...@@ -1005,6 +1013,29 @@ namespace System
Await TestAsync(workspace) Await TestAsync(workspace)
End Function End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.GoToDefinition)>
Public Async Function TestCSharpGotoDefinitionTupleFieldItem03() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
class Program
{
static void Main(string[] args)
{
System.ValueTuple&lt;short, short&gt; x = (1, Bob: 2);
var z1 = x.$$Item1;
}
}
<%= tuple2 %>
</Document>
</Project>
</Workspace>
Await TestAsync(workspace, expectedResult:=False)
End Function
#End Region #End Region
#Region "CSharp Venus Tests" #Region "CSharp Venus Tests"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册