mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Use interpolated strings 5b (#18996)
This commit is contained in:
@@ -5302,9 +5302,9 @@ namespace System.Management.Automation
|
||||
{
|
||||
WriteLine(
|
||||
lineNumber == invocationInfo.ScriptLineNumber ?
|
||||
string.Format(CultureInfo.CurrentCulture, "{0,5}:* {1}", lineNumber, _lines[lineNumber - 1])
|
||||
string.Create(CultureInfo.CurrentCulture, $"{lineNumber,5}:* { _lines[lineNumber - 1]}")
|
||||
:
|
||||
string.Format(CultureInfo.CurrentCulture, "{0,5}: {1}", lineNumber, _lines[lineNumber - 1]),
|
||||
string.Create(CultureInfo.CurrentCulture, $"{lineNumber,5}: { _lines[lineNumber - 1]}"),
|
||||
host,
|
||||
output);
|
||||
|
||||
|
||||
@@ -639,10 +639,10 @@ namespace System.Management.Automation
|
||||
!string.IsNullOrEmpty(sshConnectionInfo.UserName) &&
|
||||
!System.Environment.UserName.Equals(sshConnectionInfo.UserName, StringComparison.Ordinal))
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "[{0}@{1}]: {2}", sshConnectionInfo.UserName, sshConnectionInfo.ComputerName, basePrompt);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"[{sshConnectionInfo.UserName}@{sshConnectionInfo.ComputerName}]: {basePrompt}");
|
||||
}
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "[{0}]: {1}", runspace.ConnectionInfo.ComputerName, basePrompt);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"[{runspace.ConnectionInfo.ComputerName}]: {basePrompt}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -935,8 +935,7 @@ namespace System.Management.Automation.Internal.Host
|
||||
|
||||
if (defaultChoiceKeys.Count == 1)
|
||||
{
|
||||
defaultPrompt = StringUtil.Format(InternalHostUserInterfaceStrings.DefaultChoice,
|
||||
defaultChoicesStr);
|
||||
defaultPrompt = StringUtil.Format(InternalHostUserInterfaceStrings.DefaultChoice, defaultChoicesStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace System.Management.Automation.Host
|
||||
string
|
||||
ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0},{1}", X, Y);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"{X},{Y}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -257,7 +257,7 @@ namespace System.Management.Automation.Host
|
||||
string
|
||||
ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0},{1}", Width, Height);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"{Width},{Height}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -566,7 +566,7 @@ namespace System.Management.Automation.Host
|
||||
string
|
||||
ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", VirtualKeyCode, Character, ControlKeyState, KeyDown);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"{VirtualKeyCode},{Character},{ControlKeyState},{KeyDown}");
|
||||
}
|
||||
/// <summary>
|
||||
/// Overrides <see cref="System.Object.Equals(object)"/>
|
||||
@@ -796,7 +796,7 @@ namespace System.Management.Automation.Host
|
||||
string
|
||||
ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0},{1} ; {2},{3}", Left, Top, Right, Bottom);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"{Left},{Top} ; {Right},{Bottom}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1024,7 +1024,7 @@ namespace System.Management.Automation.Host
|
||||
string
|
||||
ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "'{0}' {1} {2} {3}", Character, ForegroundColor, BackgroundColor, BufferCellType);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"'{Character}' {ForegroundColor} {BackgroundColor} {BufferCellType}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1413,7 +1413,7 @@ namespace System.Management.Automation.Host
|
||||
if (string.Equals(hotkeysAndPlainLabels[0, i], "?", StringComparison.Ordinal))
|
||||
{
|
||||
Exception e = PSTraceSource.NewArgumentException(
|
||||
string.Format(Globalization.CultureInfo.InvariantCulture, "choices[{0}].Label", i),
|
||||
string.Create(Globalization.CultureInfo.InvariantCulture, $"choices[{i}].Label"),
|
||||
InternalHostUserInterfaceStrings.InvalidChoiceHotKeyError);
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -912,7 +912,7 @@ namespace System.Management.Automation.PSTasks
|
||||
|
||||
private Runspace GetRunspace(int taskId)
|
||||
{
|
||||
var runspaceName = string.Format(CultureInfo.InvariantCulture, "{0}:{1}", PSTask.RunspaceName, taskId);
|
||||
var runspaceName = string.Create(CultureInfo.InvariantCulture, $"{PSTask.RunspaceName}:{taskId}");
|
||||
|
||||
if (_useRunspacePool && _runspacePool.TryDequeue(out Runspace runspace))
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace System.Management.Automation.Interpreter
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "->{0} C({1}) S({2})", Index, ContinuationStackDepth, StackDepth);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"->{Index} C({ContinuationStackDepth}) S({StackDepth})");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace System.Management.Automation.Interpreter
|
||||
{
|
||||
if (j.ContainsTarget(_node))
|
||||
{
|
||||
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Label target already defined: {0}", _node.Name));
|
||||
throw new InvalidOperationException(string.Create(CultureInfo.InvariantCulture, $"Label target already defined: {_node.Name}"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace System.Management.Automation.Interpreter
|
||||
|
||||
if (HasMultipleDefinitions)
|
||||
{
|
||||
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Ambiguous jump {0}", _node.Name));
|
||||
throw new InvalidOperationException(string.Create(CultureInfo.InvariantCulture, $"Ambiguous jump {_node.Name}"));
|
||||
}
|
||||
|
||||
// We didn't find an outward jump. Look for a jump across blocks
|
||||
|
||||
@@ -92,11 +92,7 @@ namespace System.Management.Automation.Interpreter
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0} [{1}-{2}] [{3}->{4}]",
|
||||
(IsFault ? "fault" : "catch(" + ExceptionType.Name + ")"),
|
||||
StartIndex, EndIndex,
|
||||
HandlerStartIndex, HandlerEndIndex
|
||||
);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"{(IsFault ? "fault" : "catch(" + ExceptionType.Name + ")")} [{StartIndex}-{EndIndex}] [{HandlerStartIndex}->{HandlerEndIndex}]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,11 +227,11 @@ namespace System.Management.Automation.Interpreter
|
||||
{
|
||||
if (IsClear)
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}: clear", Index);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"{Index}: clear");
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}: [{1}-{2}] '{3}'", Index, StartLine, EndLine, FileName);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"{Index}: [{StartLine}-{EndLine}] '{FileName}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace System.Management.Automation.Interpreter
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}: {1} {2}", Index, IsBoxed ? "boxed" : null, InClosure ? "in closure" : null);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"{Index}: {(IsBoxed ? "boxed" : null)} {(InClosure ? "in closure" : null)}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace System.Management.Automation.Interpreter
|
||||
|
||||
public override string ToDebugString(int instructionIndex, object cookie, Func<int, int> labelIndexer, IList<object> objects)
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "LoadCached({0}: {1})", _index, objects[(int)_index]);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"LoadCached({_index}: {objects[(int)_index]})");
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
Reference in New Issue
Block a user