dotnet/roslyn

"Convert to interpolated string" refactoring could simplify constant arguments

Open

#77.023 aperta il 4 feb 2025

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-IDEhelp wanted

Metriche repository

Star
 (20.414 star)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

Repro:

string s = string.Format("{0}={1}", "Key", null);

Run "Convert to interpolated string" on this. It produces:

string s = $"{"Key"}={null}";

but it could have produced:

string s = $"Key=";

or since there are no other holes in this particular case:

string s = "Key=";

Guida contributor