dotnet / dotnet/format

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

Open
#2,171 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
1.9k
Forks
173
Avg merge
10d 13h
Merged PRs (30d)
1

Description

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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.