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

Add tests for missing scenarios #69320

Merged
merged 1 commit into from
Aug 2, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -2781,6 +2781,35 @@ public void Type_Move_MultiFile()

#region Records

[Fact]
public void Record_Insert()
{
var src1 = "";
var src2 = "record C;";

var edits = GetTopEdits(src1, src2);

edits.VerifyEdits(
"Insert [record C;]@0");

edits.VerifySemantics(
new[] { SemanticEdit(SemanticEditKind.Insert, c => c.GetMember("C")) },
capabilities: EditAndContinueCapabilities.NewTypeDefinition);
}

[Fact]
public void Record_Insert_WithParameters()
{
var src1 = "";
var src2 = "record C(int A);";

var edits = GetTopEdits(src1, src2);

edits.VerifySemantics(
new[] { SemanticEdit(SemanticEditKind.Insert, c => c.GetMember("C")) },
capabilities: EditAndContinueCapabilities.NewTypeDefinition);
}

[Fact]
public void Record_Name_Update()
{
Expand Down Expand Up @@ -18090,6 +18119,78 @@ readonly struct S
});
}

[Fact]
[WorkItem("https://github.com/dotnet/roslyn/issues/69317")]
public void Property_Rename_ShadowingPrimaryParameter()
{
var src1 = @"
class C(int A, int B)
{
public int B { get; init; }

public int F() => B;
}
";
var src2 = @"
class C(int A, int B)
{
public int D { get; init; }

public int F() => B;
}
";
var edits = GetTopEdits(src1, src2);

// TODO: https://github.com/dotnet/roslyn/issues/69317
// Update D getter/setter to use deleted B property

edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.get_B"), deletedSymbolContainerProvider: c => c.GetMember("C")),
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.set_B"), deletedSymbolContainerProvider: c => c.GetMember("C")),
SemanticEdit(SemanticEditKind.Insert, c => c.GetMember("C.D")),
},
capabilities: EditAndContinueCapabilities.AddMethodToExistingType | EditAndContinueCapabilities.AddInstanceFieldToExistingType);
}

[Fact]
[WorkItem("https://github.com/dotnet/roslyn/issues/69317")]
[WorkItem("https://github.com/dotnet/roslyn/issues/69216")]
public void Property_Rename_ShadowingPrimaryParameter_WithInitializer()
{
var src1 = @"
class C(int A, int B)
{
public int B { get; init; } = B;

public int F() => B;
}
";
var src2 = @"
class C(int A, int B)
{
public int D { get; init; } = B;

public int F() => B;
}
";
var edits = GetTopEdits(src1, src2);

// TODO: https://github.com/dotnet/roslyn/issues/69317
// Update D getter/setter to use deleted B property

edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Update, c => c.GetPrimaryConstructor("C"), preserveLocalVariables: true),
//SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.get_B"), deletedSymbolContainerProvider: c => c.GetMember("C")),
//SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.set_B"), deletedSymbolContainerProvider: c => c.GetMember("C")),
//SemanticEdit(SemanticEditKind.Insert, c => c.GetMember("C.D")),
},
capabilities: EditAndContinueCapabilities.AddMethodToExistingType | EditAndContinueCapabilities.AddInstanceFieldToExistingType);
}

#endregion

#region Indexers
Expand Down