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

Ensure rename works for property pattern members #9440

Merged
merged 2 commits into from
Mar 3, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 164 additions & 0 deletions src/EditorFeatures/Test2/Rename/RenameEngineTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -5834,6 +5834,170 @@ class [|C|]
End Using
End Sub

<WorkItem(9079, "https://github.com/dotnet/roslyn/issues/9079")>
<Fact, Trait(Traits.Feature, Traits.Features.Rename)>
Public Sub RenameFieldInPropertyPattern()
Using result = RenameEngineResult.Create(
<Workspace>
<Project Language="C#" AssemblyName="Project1" CommonReferences="true">
<Document><![CDATA[
public class Expression { }
public class Constant : Expression
{
public readonly int Value;
public Constant(int Value)
{
this.Value = Value;
}
}
public class Plus : Expression
{
public readonly Expression [|$$Left|], Right;
public Plus(Expression Left, Expression Right)
{
this.[|Left|] = Left;
this.Right = Right;
}
}
public class X
{
public static void Main()
{
Expression expr = new Plus(new Plus(new Constant(1), new Plus(new Constant(2), new Constant(3))), new Constant(6));

if (expr is Plus { [|Left|] is Plus p,Right is Constant c })
{
}
]]>
</Document>
</Project>
</Workspace>, renameTo:="Quack")
End Using
End Sub

<WorkItem(9079, "https://github.com/dotnet/roslyn/issues/9079")>
<Fact, Trait(Traits.Feature, Traits.Features.Rename)>
Public Sub RenameTypeInPropertyPattern()
Using result = RenameEngineResult.Create(
<Workspace>
<Project Language="C#" AssemblyName="Project1" CommonReferences="true">
<Document><![CDATA[
public class Expression { }
public class Constant : Expression
{
public readonly int Value;
public Constant(int Value)
{
this.Value = Value;
}
}
public class [|$$Plus|] : Expression
{
public readonly Expression Left, Right;
public [|Plus|](Expression Left, Expression Right)
{
this.Left = Left;
this.Right = Right;
}
}
public class X
{
public static void Main()
{
Expression expr = new [|Plus|](new [|Plus|](new Constant(1), new [|Plus|](new Constant(2), new Constant(3))), new Constant(6));

if (expr is [|Plus|] { Left is [|Plus|] p,Right is Constant c })
{
}
]]>
</Document>
</Project>
</Workspace>, renameTo:="Snort")
End Using
End Sub

<WorkItem(9079, "https://github.com/dotnet/roslyn/issues/9079")>
<Fact, Trait(Traits.Feature, Traits.Features.Rename)>
Public Sub RenameTypeInPropertyPattern02()
Using result = RenameEngineResult.Create(
<Workspace>
<Project Language="C#" AssemblyName="Project1" CommonReferences="true">
<Document><![CDATA[
public class Expression { }
public class Constant : Expression
{
public readonly int Value;
public Constant(int Value)
{
this.Value = Value;
}
}
public class [|Plus|] : Expression
{
public readonly Expression Left, Right;
public [|Plus|](Expression Left, Expression Right)
{
this.Left = Left;
this.Right = Right;
}
}
public class X
{
public static void Main()
{
Expression expr = new [|Plus|](new [|Plus|](new Constant(1), new [|Plus|](new Constant(2), new Constant(3))), new Constant(6));

if (expr is [|$$Plus|] { Left is [|Plus|] p,Right is Constant c })
{
}
]]>
</Document>
</Project>
</Workspace>, renameTo:="Middle")
End Using
End Sub

<WorkItem(9080, "https://github.com/dotnet/roslyn/issues/9080")>
<Fact, Trait(Traits.Feature, Traits.Features.Rename)>
Public Sub RenameFieldFromPropertyPattern()
Using result = RenameEngineResult.Create(
<Workspace>
<Project Language="C#" AssemblyName="Project1" CommonReferences="true">
<Document><![CDATA[
public class Expression { }
public class Constant : Expression
{
public readonly int Value;
public Constant(int Value)
{
this.Value = Value;
}
}
public class Plus : Expression
{
public readonly Expression [|Left|], Right;
public Plus(Expression Left, Expression Right)
{
this.[|Left|] = Left;
this.Right = Right;
}
}
public class X
{
public static void Main()
{
Expression expr = new Plus(new Plus(new Constant(1), new Plus(new Constant(2), new Constant(3))), new Constant(6));

if (expr is Plus { [|$$Left|] is Plus p,Right is Constant c })
{
}
]]>
</Document>
</Project>
</Workspace>, renameTo:="Woof")
End Using
End Sub

<WorkItem(1009633, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1009633")>
<Fact, Trait(Traits.Feature, Traits.Features.Rename)>
Public Sub RenameWithTryCatchBlock1()
Expand Down