dotnet / format

Home for the dotnet-format command
MIT License
1.91k stars 172 forks source link

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

Open JackMcBride98 opened 2 months ago

JackMcBride98 commented 2 months ago

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?