Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use interpolated strings in place of StringBuilder.AppendFormat where possible. #62160

Merged
merged 5 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/coreclr/ToolBox/SOS/DacTableGen/diautil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ private String GetTypeString(IDiaSymbol s)
else if (tag == SymTagEnum.SymTagBaseType)
{
BasicType bt = (BasicType) s.baseType;
str.AppendFormat("(base type={0}, len={1:d})", bt.ToString(), s.length);
str.Append($"(base type={bt}, len={s.length:d})");
}
else if (tag == SymTagEnum.SymTagArrayType)
{
Expand Down Expand Up @@ -677,7 +677,7 @@ private String GetTypeString(IDiaSymbol s)
try
{
succ = true;
str.AppendFormat("[{0:d}]", s.length/s.type.length );
str.Append($"[{s.length/s.type.length:d}]");
}
catch (Exception)
{
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ private unsafe double ReadILDouble()

public static void AppendOffset(StringBuilder sb, int offset)
{
sb.Append("IL_");
sb.AppendFormat("{0:X4}", offset);
sb.Append($"IL_{offset:X4}");
}

private static void PadForInstructionArgument(StringBuilder sb)
Expand Down
16 changes: 8 additions & 8 deletions src/coreclr/tools/r2rdump/CoreDisTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,17 +396,17 @@ private void ProbeX64Quirks(RuntimeFunction rtf, int imageOffset, int rtfOffset,
{
if (targetName != null)
{
translated.AppendFormat("[{0}]", targetName);
translated.Append($"[{targetName}]");
}
else
{
translated.AppendFormat("[0x{0:x4}]", target);
translated.Append($"[0x{target:x4}]");
}
translated.Append(instruction, rightBracketPlusOne, instruction.Length - rightBracketPlusOne);
}
else
{
translated.AppendFormat("[0x{0:x4}]", target);
translated.Append($"[0x{target:x4}]");
translated.Append(instruction, rightBracketPlusOne, instruction.Length - rightBracketPlusOne);
if (targetName != null)
{
Expand Down Expand Up @@ -449,17 +449,17 @@ private void ProbeX86Quirks(RuntimeFunction rtf, int imageOffset, int rtfOffset,
{
if (targetName != null)
{
translated.AppendFormat("[{0}]", targetName);
translated.Append($"[{targetName}]");
}
else
{
translated.AppendFormat("[0x{0:x4}]", target);
translated.Append($"[0x{target:x4}]");
}
translated.Append(instruction, rightBracketPlusOne, instruction.Length - rightBracketPlusOne);
}
else
{
translated.AppendFormat("[0x{0:x4}]", target);
translated.Append($"[0x{target:x4}]");
translated.Append(instruction, rightBracketPlusOne, instruction.Length - rightBracketPlusOne);
if (targetName != null)
{
Expand Down Expand Up @@ -818,7 +818,7 @@ private void ProbeArm64Quirks(RuntimeFunction rtf, int imageOffset, int rtfOffse
}
else
{
translated.AppendFormat("#0x{0:x4}", targetPage);
translated.Append($"#0x{targetPage:x4}");
}

instruction = translated.ToString();
Expand All @@ -843,7 +843,7 @@ private void ProbeArm64Quirks(RuntimeFunction rtf, int imageOffset, int rtfOffse
}
else
{
translated.AppendFormat("#0x{0:x}", target & 0xfff);
translated.Append($"#0x{target & 0xfff:x}");
if (targetName != null)
{
AppendComment(translated, "import{" + targetName + "}");
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/tools/r2rdump/R2RDiff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,23 +281,23 @@ private void ShowDiff(Dictionary<string, int> leftObjects, Dictionary<string, in
StringBuilder line = new StringBuilder();
if (inLeft)
{
line.AppendFormat("{0,10}", leftSize);
line.Append($"{leftSize,10}");
}
else
{
line.Append(' ', 10);
}
if (inRight)
{
line.AppendFormat("{0,11}", rightSize);
line.Append($"{rightSize,11}");
}
else
{
line.Append(' ', 11);
}
if (leftSize != rightSize)
{
line.AppendFormat("{0,11}", rightSize - leftSize);
line.Append($"{rightSize - leftSize,11}");
}
else
{
Expand Down