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

Fix suggestions for dotted constant patterns in Color Color case #75373

Merged
Merged
Show file tree
Hide file tree
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 @@ -12868,6 +12868,310 @@ public static T Method<T>(this T s)
await VerifyItemExistsAsync(markup, "Method", displayTextSuffix: "<>");
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/75350")]
public async Task SwitchExpressionEnumColorColor_01()
{
//lang=c#-test
const string source = """
public sealed record OrderModel(int Id, Status Status)
{
public string StatusDisplay
{
get
{
return Status switch
{
Status.$$
};
}
}
}

public enum Status
{
Undisclosed,
Open,
Closed,
}
""";
await VerifyItemExistsAsync(source, "Undisclosed");
await VerifyItemIsAbsentAsync(source, "ToString");
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/75350")]
public async Task SwitchExpressionEnumColorColor_02()
{
//lang=c#-test
const string source = """
public sealed record OrderModel(int Id, Status Status)
{
public string StatusDisplay
{
get
{
return this switch
{
{ Status: Status.$$ }
};
}
}
}

public enum Status
{
Undisclosed,
Open,
Closed,
}
""";
await VerifyItemExistsAsync(source, "Undisclosed");
await VerifyItemIsAbsentAsync(source, "ToString");
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/75350")]
public async Task SwitchExpressionEnumColorColor_03()
{
//lang=c#-test
const string source = """
namespace Status;

public sealed record OrderModel(int Id, StatusEn Status)
{
public string StatusDisplay
{
get
{
return this switch
{
{ Status: Status.$$ }
};
}
}
}

public enum StatusEn
{
Undisclosed,
Open,
Closed,
}
""";
await VerifyItemExistsAsync(source, "StatusEn");
await VerifyItemIsAbsentAsync(source, "ToString");
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/75350")]
public async Task SwitchExpressionEnumColorColor_04()
{
//lang=c#-test
const string source = """
using Status = StatusEn;

public sealed record OrderModel(int Id, StatusEn Status)
{
public string StatusDisplay
{
get
{
return this switch
{
{ Status: Status.$$ }
};
}
}
}

public enum StatusEn
{
Undisclosed,
Open,
Closed,
}
""";
await VerifyItemExistsAsync(source, "Undisclosed");
await VerifyItemIsAbsentAsync(source, "ToString");
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/75350")]
public async Task SwitchExpressionEnumColorColor_05()
{
//lang=c#-test
const string source = """
using Status = StatusEn;

public sealed record OrderModel(int Id, StatusEn Status)
{
public string StatusDisplay
{
get
{
const StatusEn Status = StatusEn.Undisclosed;
return this switch
{
{ Status: Status.$$ }
};
}
}
}

public enum StatusEn
{
Undisclosed,
Open,
Closed,
}
""";
await VerifyItemExistsAsync(source, "Undisclosed");
await VerifyItemIsAbsentAsync(source, "ToString");
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/75350")]
public async Task ConstantPatternExpressionEnumColorColor_01()
{
//lang=c#-test
const string source = """
public sealed record OrderModel(int Id, Status Status)
{
public string StatusDisplay
{
get
{
if (Status is Status.$$)
;
}
}
}

public enum Status
{
Undisclosed,
Open,
Closed,
}
""";
await VerifyItemExistsAsync(source, "Undisclosed");
await VerifyItemIsAbsentAsync(source, "ToString");
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/75350")]
public async Task ConstantPatternExpressionEnumColorColor_02()
{
//lang=c#-test
const string source = """
public sealed record OrderModel(int Id, Status Status)
{
public string StatusDisplay
{
get
{
if (Status is (Status.$$)
;
}
}
}

public enum Status
{
Undisclosed,
Open,
Closed,
}
""";
await VerifyItemExistsAsync(source, "Undisclosed");
await VerifyItemIsAbsentAsync(source, "ToString");
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/75350")]
public async Task ConstantPatternExpressionEnumColorColor_03()
{
//lang=c#-test
const string source = """
namespace Status;

public sealed record OrderModel(int Id, StatusEn Status)
{
public string StatusDisplay
{
get
{
if (Status is (Status.$$)
;
}
}
}

public enum StatusEn
{
Undisclosed,
Open,
Closed,
}
""";
await VerifyItemExistsAsync(source, "StatusEn");
await VerifyItemIsAbsentAsync(source, "ToString");
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/75350")]
public async Task ConstantPatternExpressionEnumColorColor_04()
{
//lang=c#-test
const string source = """
using Status = StatusEn;

public sealed record OrderModel(int Id, StatusEn Status)
{
public string StatusDisplay
{
get
{
if (Status is (Status.$$)
;
}
}
}

public enum StatusEn
{
Undisclosed,
Open,
Closed,
}
""";
await VerifyItemExistsAsync(source, "Undisclosed");
await VerifyItemIsAbsentAsync(source, "ToString");
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/75350")]
public async Task ConstantPatternExpressionEnumColorColor_05()
{
//lang=c#-test
const string source = """
using Status = StatusEn;

public sealed record OrderModel(int Id, StatusEn Status)
{
public string StatusDisplay
{
get
{
const StatusEn Status = StatusEn.Undisclosed;
if (Status is (Status.$$)
;
}
}
}

public enum StatusEn
{
Undisclosed,
Open,
Closed,
}
""";
await VerifyItemExistsAsync(source, "Undisclosed");
await VerifyItemIsAbsentAsync(source, "ToString");
}

#region Collection expressions

[Fact]
Expand Down
Loading
Loading