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

Simplify interpolation (IDE0071) - false positive with Enum and FormattableString #2171

Open
JackMcBride98 opened this issue Apr 22, 2024 · 0 comments

Comments

@JackMcBride98
Copy link

JackMcBride98 commented Apr 22, 2024

We have the below Enum

public enum EmployeeType
{
    Azure,
    Manual,
}

Then when using FormattableSqlString

await dataContext.Database.ExecuteSqlInterpolatedAsync(
    $"UPDATE Employees SET Discriminator = {EmployeeType.Azure.ToString()}, AzureId = {azureId} WHERE EmployeeId = {employee.EmployeeId};");

This sets the Discriminator to "Azure". Without the .ToString() call on the enum, it sets it to 0

Running dotnet format removes the .ToString() call on the EmployeeType enum, which changes the behaviour.
I've fixed for now by using nameof(), but this defo seems an issue.

Is this the correct place for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant