dotnet/roslyn

"Convert to interpolated string" refactoring could simplify constant arguments

Open

#77.023 geöffnet am 4. Feb. 2025

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (4.257 Forks)batch import
Area-IDEhelp wanted

Repository-Metriken

Stars
 (20.414 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

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=";

Contributor Guide