Skip to content

Commit

Permalink
Merge pull request dotnet#59293 from CyrusNajmabadi/positionalRecordC…
Browse files Browse the repository at this point in the history
…ascade

Cascade between position record parameters and properties.
  • Loading branch information
CyrusNajmabadi authored Feb 7, 2022
2 parents 0e73c8c + 88de801 commit 4224320
Show file tree
Hide file tree
Showing 5 changed files with 470 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -727,5 +727,173 @@ end class
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordParameter1(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int {|Definition:$$y|})
{

}

class P
{
static void Main()
{
var f = new Goo(0, [|y|]: 1);
Console.WriteLine(f.[|y|]);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordParameter2(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int {|Definition:y|})
{

}

class P
{
static void Main()
{
var f = new Goo(0, [|$$y|]: 1);
Console.WriteLine(f.[|y|]);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordParameterWithExplicitProperty1(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int {|Definition:$$y|})
{
public int y { get; } = [|y|];
}

class P
{
static void Main()
{
var f = new Goo(0, [|y|]: 1);
Console.WriteLine(f.y);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordParameterWithExplicitProperty2(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int {|Definition:y|})
{
public int y { get; } = [|$$y|];
}

class P
{
static void Main()
{
var f = new Goo(0, [|y|]: 1);
Console.WriteLine(f.y);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordParameterWithExplicitProperty3(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int {|Definition:y|})
{
public int y { get; } = [|y|];
}

class P
{
static void Main()
{
var f = new Goo(0, [|$$y|]: 1);
Console.WriteLine(f.y);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordParameterWithNotPrimaryConstructor(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int y)
{
public Goo(int {|Definition:$$y|}) { }
}

class P
{
static void Main()
{
var f = new Goo([|y|]: 1);
Console.WriteLine(f.y);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function
End Class
End Namespace
Original file line number Diff line number Diff line change
Expand Up @@ -1214,5 +1214,207 @@ class C2_2 : I2
</Workspace>
Await TestAPI(input, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordProperty1(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int {|Definition:$$y|})
{

}

class P
{
static void Main()
{
var f = new Goo(0, [|y|]: 1);
Console.WriteLine(f.[|y|]);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordProperty2(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int {|Definition:y|})
{

}

class P
{
static void Main()
{
var f = new Goo(0, [|$$y|]: 1);
Console.WriteLine(f.[|y|]);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordProperty3(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int {|Definition:y|})
{

}

class P
{
static void Main()
{
var f = new Goo(0, [|y|]: 1);
Console.WriteLine(f.[|$$y|]);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordPropertyWithExplicitProperty1(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int y)
{
public int {|Definition:$$y|} { get; } = y;
}

class P
{
static void Main()
{
var f = new Goo(0, y: 1);
Console.WriteLine(f.[|y|]);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordPropertyWithExplicitProperty2(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int y)
{
public int {|Definition:y|} { get; } = y;
}

class P
{
static void Main()
{
var f = new Goo(0, y: 1);
Console.WriteLine(f.[|$$y|]);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordPropertyWithNotPrimaryConstructor1(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int y)
{
public Goo(int {|Definition:$$y|})
{
this.y = [|y|];
}
}

class P
{
static void Main()
{
var f = new Goo([|y|]: 1);
Console.WriteLine(f.y);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function

<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.FindReferences)>
Public Async Function TestRecordPropertyWithNotPrimaryConstructor2(kind As TestKind, host As TestHost) As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System;

record Goo(int x, int {|Definition:$$y|})
{
public Goo(int y)
{
this.[|y|] = y;
}
}

class P
{
static void Main()
{
var f = new Goo(y: 1);
Console.WriteLine(f.[|y|]);
}
}

</Document>
</Project>
</Workspace>
Await TestAPIAndFeature(input, kind, host)
End Function
End Class
End Namespace
Loading

0 comments on commit 4224320

Please sign in to comment.