dotnet/roslyn

"Convert to interpolated string" refactoring could simplify constant arguments

Open

#77,023 创建于 2025年2月4日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)C# (4,257 fork)batch import
Area-IDEhelp wanted

仓库指标

Star
 (20,414 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

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

贡献者指南