mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Use interpolated strings 2 (#18978)
This commit is contained in:
@@ -248,7 +248,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.Fail(string.Format(CultureInfo.InvariantCulture, "Invalid parameter set name: {0}", ParameterSetName));
|
||||
Debug.Fail(string.Create(CultureInfo.InvariantCulture, $"Invalid parameter set name: {ParameterSetName}"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
break;
|
||||
|
||||
default:
|
||||
WriteDebug(string.Format(CultureInfo.InvariantCulture, "Invalid parameter set name: {0}", ParameterSetName));
|
||||
WriteDebug(string.Create(CultureInfo.InvariantCulture, $"Invalid parameter set name: {ParameterSetName}"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -492,7 +492,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
foreach (string log in _providersByLogMap.Keys)
|
||||
{
|
||||
logQuery = new EventLogQuery(log, PathType.LogName, AddProviderPredicatesToFilter(_providersByLogMap[log]));
|
||||
WriteVerbose(string.Format(CultureInfo.InvariantCulture, "Log {0} will be queried", log));
|
||||
WriteVerbose(string.Create(CultureInfo.InvariantCulture, $"Log {log} will be queried"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,7 +680,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
foreach (string resolvedPath in resolvedPaths)
|
||||
{
|
||||
_resolvedPaths.Add(resolvedPath);
|
||||
WriteVerbose(string.Format(CultureInfo.InvariantCulture, "Found file {0}", resolvedPath));
|
||||
WriteVerbose(string.Create(CultureInfo.InvariantCulture, $"Found file {resolvedPath}"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -908,7 +908,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
break;
|
||||
|
||||
default:
|
||||
WriteDebug(string.Format(CultureInfo.InvariantCulture, "Invalid parameter set name: {0}", ParameterSetName));
|
||||
WriteDebug(string.Create(CultureInfo.InvariantCulture, $"Invalid parameter set name: {ParameterSetName}"));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2047,7 +2047,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
||
|
||||
(wildProvPattern.IsMatch(provName)))
|
||||
{
|
||||
WriteVerbose(string.Format(CultureInfo.InvariantCulture, "Found matching provider: {0}", provName));
|
||||
WriteVerbose(string.Create(CultureInfo.InvariantCulture, $"Found matching provider: {provName}"));
|
||||
AddLogsForProviderToInternalMap(eventLogSession, provName);
|
||||
bMatched = true;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Invalid parameter set name: {0}", ParameterSetName));
|
||||
Debug.Assert(false, $"Invalid parameter set name: {ParameterSetName}");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -248,7 +248,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
try
|
||||
{
|
||||
var halPath = CIMHelper.EscapePath(System.IO.Path.Combine(systemDirectory, "hal.dll"));
|
||||
var query = string.Format("SELECT * FROM CIM_DataFile Where Name='{0}'", halPath);
|
||||
var query = string.Create(CultureInfo.InvariantCulture, $"SELECT * FROM CIM_DataFile Where Name='{halPath}'");
|
||||
var instance = session.QueryFirstInstance(query);
|
||||
|
||||
if (instance != null)
|
||||
|
||||
@@ -618,7 +618,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
break;
|
||||
|
||||
default:
|
||||
Dbg.Diagnostics.Assert(false, string.Format(System.Globalization.CultureInfo.InvariantCulture, "One of the predefined parameter sets should have been specified, instead we got: {0}", ParameterSetName));
|
||||
Dbg.Diagnostics.Assert(false, string.Create(System.Globalization.CultureInfo.InvariantCulture, $"One of the predefined parameter sets should have been specified, instead we got: {ParameterSetName}"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1151,7 +1151,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
temp = temp.Substring(4);
|
||||
}
|
||||
|
||||
type = string.Format(System.Globalization.CultureInfo.InvariantCulture, "#TYPE {0}", temp);
|
||||
type = string.Create(System.Globalization.CultureInfo.InvariantCulture, $"#TYPE {temp}");
|
||||
}
|
||||
|
||||
return type;
|
||||
|
||||
+1
-1
@@ -296,7 +296,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
private static readonly Random _idGenerator = new();
|
||||
|
||||
private static string GetGroupLabel(Type inputType)
|
||||
=> string.Format("{0} ({1}) <{2:X8}>", inputType.Name, inputType.FullName, _idGenerator.Next());
|
||||
=> string.Create(System.Globalization.CultureInfo.InvariantCulture, $"{inputType.Name} ({inputType.FullName}) <{_idGenerator.Next():X8}>");
|
||||
|
||||
private void FlushInputBuffer()
|
||||
{
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
foreach (object item in propertyValueItems)
|
||||
{
|
||||
sb.AppendFormat(CultureInfo.InvariantCulture, "{0}, ", item.ToString());
|
||||
sb.Append(CultureInfo.InvariantCulture, $"{item}, ");
|
||||
}
|
||||
|
||||
sb = sb.Length > length ? sb.Remove(sb.Length - 2, 2) : sb;
|
||||
@@ -161,7 +161,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat(CultureInfo.InvariantCulture, "{0}, ", propValuePropertyValue.ToString());
|
||||
sb.Append(CultureInfo.InvariantCulture, $"{propValuePropertyValue}, ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-26
@@ -2247,13 +2247,13 @@ function Get-PSImplicitRemotingSessionOption
|
||||
RunspaceConnectionInfo runspaceConnectionInfo = _remoteRunspaceInfo.Runspace.ConnectionInfo as RunspaceConnectionInfo;
|
||||
if (runspaceConnectionInfo != null)
|
||||
{
|
||||
result.AppendFormat(null, "-Culture '{0}' ", CodeGeneration.EscapeSingleQuotedStringContent(runspaceConnectionInfo.Culture.ToString()));
|
||||
result.AppendFormat(null, "-UICulture '{0}' ", CodeGeneration.EscapeSingleQuotedStringContent(runspaceConnectionInfo.UICulture.ToString()));
|
||||
result.Append(null, $"-Culture '{CodeGeneration.EscapeSingleQuotedStringContent(runspaceConnectionInfo.Culture.ToString())}' ");
|
||||
result.Append(null, $"-UICulture '{CodeGeneration.EscapeSingleQuotedStringContent(runspaceConnectionInfo.UICulture.ToString())}' ");
|
||||
|
||||
result.AppendFormat(null, "-CancelTimeOut {0} ", runspaceConnectionInfo.CancelTimeout);
|
||||
result.AppendFormat(null, "-IdleTimeOut {0} ", runspaceConnectionInfo.IdleTimeout);
|
||||
result.AppendFormat(null, "-OpenTimeOut {0} ", runspaceConnectionInfo.OpenTimeout);
|
||||
result.AppendFormat(null, "-OperationTimeOut {0} ", runspaceConnectionInfo.OperationTimeout);
|
||||
result.Append(null, $"-CancelTimeOut {runspaceConnectionInfo.CancelTimeout} ");
|
||||
result.Append(null, $"-IdleTimeOut {runspaceConnectionInfo.IdleTimeout} ");
|
||||
result.Append(null, $"-OpenTimeOut {runspaceConnectionInfo.OpenTimeout} ");
|
||||
result.Append(null, $"-OperationTimeOut {runspaceConnectionInfo.OperationTimeout} ");
|
||||
}
|
||||
|
||||
WSManConnectionInfo wsmanConnectionInfo = _remoteRunspaceInfo.Runspace.ConnectionInfo as WSManConnectionInfo;
|
||||
@@ -2275,33 +2275,18 @@ function Get-PSImplicitRemotingSessionOption
|
||||
|
||||
if (wsmanConnectionInfo.MaximumReceivedDataSizePerCommand.HasValue)
|
||||
{
|
||||
result.AppendFormat(
|
||||
CultureInfo.InvariantCulture,
|
||||
"-MaximumReceivedDataSizePerCommand {0} ",
|
||||
wsmanConnectionInfo.MaximumReceivedDataSizePerCommand.Value);
|
||||
result.Append(CultureInfo.InvariantCulture, $"-MaximumReceivedDataSizePerCommand {wsmanConnectionInfo.MaximumReceivedDataSizePerCommand.Value} ");
|
||||
}
|
||||
|
||||
if (wsmanConnectionInfo.MaximumReceivedObjectSize.HasValue)
|
||||
{
|
||||
result.AppendFormat(
|
||||
CultureInfo.InvariantCulture,
|
||||
"-MaximumReceivedObjectSize {0} ",
|
||||
wsmanConnectionInfo.MaximumReceivedObjectSize.Value);
|
||||
result.Append(CultureInfo.InvariantCulture, $"-MaximumReceivedObjectSize {wsmanConnectionInfo.MaximumReceivedObjectSize.Value} ");
|
||||
}
|
||||
|
||||
result.AppendFormat(
|
||||
CultureInfo.InvariantCulture,
|
||||
"-MaximumRedirection {0} ",
|
||||
wsmanConnectionInfo.MaximumConnectionRedirectionCount);
|
||||
result.Append(CultureInfo.InvariantCulture, $"-MaximumRedirection {wsmanConnectionInfo.MaximumConnectionRedirectionCount} ");
|
||||
|
||||
result.AppendFormat(
|
||||
CultureInfo.InvariantCulture,
|
||||
"-ProxyAccessType {0} ",
|
||||
wsmanConnectionInfo.ProxyAccessType.ToString());
|
||||
result.AppendFormat(
|
||||
CultureInfo.InvariantCulture,
|
||||
"-ProxyAuthentication {0} ",
|
||||
wsmanConnectionInfo.ProxyAuthentication.ToString());
|
||||
result.Append(CultureInfo.InvariantCulture, $"-ProxyAccessType {wsmanConnectionInfo.ProxyAccessType} ");
|
||||
result.Append(CultureInfo.InvariantCulture, $"-ProxyAuthentication {wsmanConnectionInfo.ProxyAuthentication} ");
|
||||
result.Append(this.GenerateProxyCredentialParameter(wsmanConnectionInfo));
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// Gets the hexadecimal representation of the <see cref="Offset64"/> value.
|
||||
/// </summary>
|
||||
public string HexOffset { get => string.Format(CultureInfo.CurrentCulture, "{0:X16}", Offset64); }
|
||||
public string HexOffset => string.Create(CultureInfo.CurrentCulture, $"{Offset64:X16}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the input objects used to create the <see cref="ByteCollection"/>.
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
int statusCode = WebResponseHelper.GetStatusCode(response);
|
||||
string statusDescription = WebResponseHelper.GetStatusDescription(response);
|
||||
raw.AppendFormat("{0} {1} {2}", protocol, statusCode, statusDescription);
|
||||
raw.Append($"{protocol} {statusCode} {statusDescription}");
|
||||
raw.AppendLine();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
// NOTE: Tests use this verbose output to verify the encoding.
|
||||
WriteVerbose(string.Format(System.Globalization.CultureInfo.InvariantCulture, $"Content encoding: {encodingVerboseName}"));
|
||||
WriteVerbose(string.Create(System.Globalization.CultureInfo.InvariantCulture, $"Content encoding: {encodingVerboseName}"));
|
||||
|
||||
bool convertSuccess = false;
|
||||
|
||||
|
||||
+5
-5
@@ -744,7 +744,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
encodedValue = WebUtility.UrlEncode(value.ToString());
|
||||
}
|
||||
|
||||
bodyBuilder.AppendFormat("{0}={1}", encodedKey, encodedValue);
|
||||
bodyBuilder.Append($"{encodedKey}={encodedValue}");
|
||||
}
|
||||
|
||||
return bodyBuilder.ToString();
|
||||
@@ -768,14 +768,14 @@ namespace Microsoft.PowerShell.Commands
|
||||
private string GetBasicAuthorizationHeader()
|
||||
{
|
||||
var password = new NetworkCredential(null, Credential.Password).Password;
|
||||
string unencoded = string.Format($"{Credential.UserName}:{password}");
|
||||
string unencoded = string.Create(CultureInfo.InvariantCulture, $"{Credential.UserName}:{password}");
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(unencoded);
|
||||
return string.Format($"Basic {Convert.ToBase64String(bytes)}");
|
||||
return string.Create(CultureInfo.InvariantCulture, $"Basic {Convert.ToBase64String(bytes)}");
|
||||
}
|
||||
|
||||
private string GetBearerAuthorizationHeader()
|
||||
{
|
||||
return string.Format($"Bearer {new NetworkCredential(string.Empty, Token).Password}");
|
||||
return string.Create(CultureInfo.InvariantCulture, $"Bearer {new NetworkCredential(string.Empty, Token).Password}");
|
||||
}
|
||||
|
||||
private void ProcessAuthentication()
|
||||
@@ -790,7 +790,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
else
|
||||
{
|
||||
Diagnostics.Assert(false, string.Format($"Unrecognized Authentication value: {Authentication}"));
|
||||
Diagnostics.Assert(false, string.Create(CultureInfo.InvariantCulture, $"Unrecognized Authentication value: {Authentication}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
return headers;
|
||||
}
|
||||
|
||||
internal static string GetProtocol(HttpResponseMessage response) => string.Format(CultureInfo.InvariantCulture, $"HTTP/{response.Version}");
|
||||
internal static string GetProtocol(HttpResponseMessage response) => string.Create(CultureInfo.InvariantCulture, $"HTTP/{response.Version}");
|
||||
|
||||
internal static int GetStatusCode(HttpResponseMessage response) => (int)response.StatusCode;
|
||||
|
||||
|
||||
@@ -17,36 +17,36 @@ namespace Microsoft.PowerShell.Commands
|
||||
private static string s_windowsUserAgent;
|
||||
|
||||
// Format the user-agent string from the various component parts
|
||||
internal static string UserAgent => string.Format(CultureInfo.InvariantCulture, $"{Compatibility} ({PlatformName}; {OS}; {Culture}) {App}");
|
||||
internal static string UserAgent => string.Create(CultureInfo.InvariantCulture, $"{Compatibility} ({PlatformName}; {OS}; {Culture}) {App}");
|
||||
|
||||
/// <summary>
|
||||
/// Useragent string for InternetExplorer (9.0).
|
||||
/// </summary>
|
||||
public static string InternetExplorer => string.Format(CultureInfo.InvariantCulture, $"{Compatibility} (compatible; MSIE 9.0; {PlatformName}; {OS}; {Culture})");
|
||||
public static string InternetExplorer => string.Create(CultureInfo.InvariantCulture, $"{Compatibility} (compatible; MSIE 9.0; {PlatformName}; {OS}; {Culture})");
|
||||
|
||||
/// <summary>
|
||||
/// Useragent string for Firefox (4.0).
|
||||
/// </summary>
|
||||
public static string FireFox => string.Format(CultureInfo.InvariantCulture, $"{Compatibility} ({PlatformName}; {OS}; {Culture}) Gecko/20100401 Firefox/4.0");
|
||||
public static string FireFox => string.Create(CultureInfo.InvariantCulture, $"{Compatibility} ({PlatformName}; {OS}; {Culture}) Gecko/20100401 Firefox/4.0");
|
||||
|
||||
/// <summary>
|
||||
/// Useragent string for Chrome (7.0).
|
||||
/// </summary>
|
||||
public static string Chrome => string.Format(CultureInfo.InvariantCulture, $"{Compatibility} ({PlatformName}; {OS}; {Culture}) AppleWebKit/534.6 (KHTML, like Gecko) Chrome/7.0.500.0 Safari/534.6");
|
||||
public static string Chrome => string.Create(CultureInfo.InvariantCulture, $"{Compatibility} ({PlatformName}; {OS}; {Culture}) AppleWebKit/534.6 (KHTML, like Gecko) Chrome/7.0.500.0 Safari/534.6");
|
||||
|
||||
/// <summary>
|
||||
/// Useragent string for Opera (9.0).
|
||||
/// </summary>
|
||||
public static string Opera => string.Format(CultureInfo.InvariantCulture, $"Opera/9.70 ({PlatformName}; {OS}; {Culture}) Presto/2.2.1");
|
||||
public static string Opera => string.Create(CultureInfo.InvariantCulture, $"Opera/9.70 ({PlatformName}; {OS}; {Culture}) Presto/2.2.1");
|
||||
|
||||
/// <summary>
|
||||
/// Useragent string for Safari (5.0).
|
||||
/// </summary>
|
||||
public static string Safari => string.Format(CultureInfo.InvariantCulture, $"{Compatibility} ({PlatformName}; {OS}; {Culture}) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16");
|
||||
public static string Safari => string.Create(CultureInfo.InvariantCulture, $"{Compatibility} ({PlatformName}; {OS}; {Culture}) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16");
|
||||
|
||||
internal static string Compatibility => "Mozilla/5.0";
|
||||
|
||||
internal static string App => string.Format(CultureInfo.InvariantCulture, $"PowerShell/{PSVersionInfo.PSVersion}");
|
||||
internal static string App => string.Create(CultureInfo.InvariantCulture, $"PowerShell/{PSVersionInfo.PSVersion}");
|
||||
|
||||
internal static string PlatformName
|
||||
{
|
||||
|
||||
@@ -439,7 +439,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteObject(string.Format(CultureInfo.InvariantCulture, "<?xml version=\"1.0\" encoding=\"{0}\"?>", Encoding.UTF8.WebName));
|
||||
WriteObject(string.Create(CultureInfo.InvariantCulture, $"<?xml version=\"1.0\" encoding=\"{Encoding.UTF8.WebName}\"?>"));
|
||||
WriteObject("<Objects>");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0},{1}", X, Y);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"{X},{Y}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", Left, Top, Right, Bottom);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"{Left},{Top},{Right},{Bottom}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "Size: {0}, Visible: {1}", Size, Visible);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"Size: {Size}, Visible: {Visible}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1249,8 +1249,7 @@ namespace Microsoft.PowerShell
|
||||
{
|
||||
if (firstLeftTrailingRow >= 0)
|
||||
{
|
||||
throw PSTraceSource.NewArgumentException(string.Format(CultureInfo.InvariantCulture, "contents[{0}, {1}]",
|
||||
firstLeftTrailingRow, contentsRegion.Left));
|
||||
throw PSTraceSource.NewArgumentException(string.Create(CultureInfo.InvariantCulture, $"contents[{firstLeftTrailingRow}, {contentsRegion.Left}]"));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1265,8 +1264,7 @@ namespace Microsoft.PowerShell
|
||||
if (leftExisting[r, 0].BufferCellType == BufferCellType.Leading ^
|
||||
contents[r, contentsRegion.Left].BufferCellType == BufferCellType.Trailing)
|
||||
{
|
||||
throw PSTraceSource.NewArgumentException(string.Format(CultureInfo.InvariantCulture, "contents[{0}, {1}]",
|
||||
r, contentsRegion.Left));
|
||||
throw PSTraceSource.NewArgumentException(string.Create(CultureInfo.InvariantCulture, $"contents[{r}, {contentsRegion.Left}]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1275,8 +1273,7 @@ namespace Microsoft.PowerShell
|
||||
{
|
||||
if (firstRightLeadingRow >= 0)
|
||||
{
|
||||
throw PSTraceSource.NewArgumentException(string.Format(CultureInfo.InvariantCulture, "contents[{0}, {1}]",
|
||||
firstRightLeadingRow, contentsRegion.Right));
|
||||
throw PSTraceSource.NewArgumentException(string.Create(CultureInfo.InvariantCulture, $"contents[{firstRightLeadingRow}, {contentsRegion.Right}]"));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1291,8 +1288,7 @@ namespace Microsoft.PowerShell
|
||||
if (rightExisting[r, 0].BufferCellType == BufferCellType.Leading ^
|
||||
contents[r, contentsRegion.Right].BufferCellType == BufferCellType.Leading)
|
||||
{
|
||||
throw PSTraceSource.NewArgumentException(string.Format(CultureInfo.InvariantCulture, "contents[{0}, {1}]",
|
||||
r, contentsRegion.Right));
|
||||
throw PSTraceSource.NewArgumentException(string.Create(CultureInfo.InvariantCulture, $"contents[{r}, {contentsRegion.Right}]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1312,7 +1308,7 @@ namespace Microsoft.PowerShell
|
||||
contents[r, c].Character != 0)
|
||||
{
|
||||
// trailing character is not 0
|
||||
throw PSTraceSource.NewArgumentException(string.Format(CultureInfo.InvariantCulture, "contents[{0}, {1}]", r, c));
|
||||
throw PSTraceSource.NewArgumentException(string.Create(CultureInfo.InvariantCulture, $"contents[{r}, {c}]"));
|
||||
}
|
||||
|
||||
if (contents[r, c].BufferCellType == BufferCellType.Leading)
|
||||
@@ -1327,7 +1323,7 @@ namespace Microsoft.PowerShell
|
||||
{
|
||||
// for a 2 cell character, either there is no trailing BufferCell or
|
||||
// the trailing BufferCell's character is not 0
|
||||
throw PSTraceSource.NewArgumentException(string.Format(CultureInfo.InvariantCulture, "contents[{0}, {1}]", r, c));
|
||||
throw PSTraceSource.NewArgumentException(string.Create(CultureInfo.InvariantCulture, $"contents[{r}, {c}]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1522,7 +1518,7 @@ namespace Microsoft.PowerShell
|
||||
// to write is larger than bufferLimit. In that case, the algorithm writes one row
|
||||
// at a time => bufferSize.Y == 1. Then, we can safely leave bufferSize.Y unchanged
|
||||
// to retry with a smaller bufferSize.X.
|
||||
Dbg.Assert(bufferSize.Y == 1, string.Format(CultureInfo.InvariantCulture, "bufferSize.Y should be 1, but is {0}", bufferSize.Y));
|
||||
Dbg.Assert(bufferSize.Y == 1, string.Create(CultureInfo.InvariantCulture, $"bufferSize.Y should be 1, but is {bufferSize.Y}"));
|
||||
bufferSize.X = (short)Math.Min(colsRemaining, bufferLimit);
|
||||
continue;
|
||||
}
|
||||
@@ -1650,7 +1646,7 @@ namespace Microsoft.PowerShell
|
||||
// to write is larger than bufferLimit. In that case, the algorithm writes one row
|
||||
// at a time => bufferSize.Y == 1. Then, we can safely leave bufferSize.Y unchanged
|
||||
// to retry with a smaller bufferSize.X.
|
||||
Dbg.Assert(bufferSize.Y == 1, string.Format(CultureInfo.InvariantCulture, "bufferSize.Y should be 1, but is {0}", bufferSize.Y));
|
||||
Dbg.Assert(bufferSize.Y == 1, string.Create(CultureInfo.InvariantCulture, $"bufferSize.Y should be 1, but is {bufferSize.Y}"));
|
||||
bufferSize.X = (short)Math.Min(colsRemaining, bufferLimit);
|
||||
continue;
|
||||
}
|
||||
@@ -1975,7 +1971,7 @@ namespace Microsoft.PowerShell
|
||||
// to write is larger than bufferLimit. In that case, the algorithm reads one row
|
||||
// at a time => bufferSize.Y == 1. Then, we can safely leave bufferSize.Y unchanged
|
||||
// to retry with a smaller bufferSize.X.
|
||||
Dbg.Assert(bufferSize.Y == 1, string.Format(CultureInfo.InvariantCulture, "bufferSize.Y should be 1, but is {0}", bufferSize.Y));
|
||||
Dbg.Assert(bufferSize.Y == 1, string.Create(CultureInfo.InvariantCulture, $"bufferSize.Y should be 1, but is {bufferSize.Y}"));
|
||||
bufferSize.X = (short)Math.Min(colsRemaining, bufferLimit);
|
||||
continue;
|
||||
}
|
||||
@@ -2145,7 +2141,7 @@ namespace Microsoft.PowerShell
|
||||
// to write is larger than bufferLimit. In that case, the algorithm reads one row
|
||||
// at a time => bufferSize.Y == 1. Then, we can safely leave bufferSize.Y unchanged
|
||||
// to retry with a smaller bufferSize.X.
|
||||
Dbg.Assert(bufferSize.Y == 1, string.Format(CultureInfo.InvariantCulture, "bufferSize.Y should be 1, but is {0}", bufferSize.Y));
|
||||
Dbg.Assert(bufferSize.Y == 1, string.Create(CultureInfo.InvariantCulture, $"bufferSize.Y should be 1, but is {bufferSize.Y}"));
|
||||
bufferSize.X = (short)Math.Min(colsRemaining, bufferLimit);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -639,8 +639,7 @@ namespace Microsoft.PowerShell
|
||||
{
|
||||
int actualNumberOfInput = ConsoleControl.ReadConsoleInput(handle, ref inputRecords);
|
||||
Dbg.Assert(actualNumberOfInput == 1,
|
||||
string.Format(CultureInfo.InvariantCulture, "ReadConsoleInput returns {0} number of input event records",
|
||||
actualNumberOfInput));
|
||||
string.Create(CultureInfo.InvariantCulture, $"ReadConsoleInput returns {actualNumberOfInput} number of input event records"));
|
||||
if (actualNumberOfInput == 1)
|
||||
{
|
||||
if (((ConsoleControl.InputRecordEventTypes)inputRecords[0].EventType) ==
|
||||
@@ -1532,7 +1531,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0},{1}", X, Y);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"{X},{Y}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1548,7 +1547,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", Left, Top, Right, Bottom);
|
||||
return string.Create(CultureInfo.InvariantCulture, $"{Left},{Top},{Right},{Bottom}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace Microsoft.PowerShell
|
||||
{
|
||||
throw PSTraceSource.NewArgumentException(nameof(descriptions),
|
||||
ConsoleHostUserInterfaceStrings.NullErrorTemplate,
|
||||
string.Format(CultureInfo.InvariantCulture, "descriptions[{0}]", descIndex));
|
||||
string.Create(CultureInfo.InvariantCulture, $"descriptions[{descIndex}]"));
|
||||
}
|
||||
|
||||
PSObject inputPSObject = null;
|
||||
@@ -152,7 +152,7 @@ namespace Microsoft.PowerShell
|
||||
if (string.IsNullOrEmpty(desc.ParameterAssemblyFullName))
|
||||
{
|
||||
string paramName =
|
||||
string.Format(CultureInfo.InvariantCulture, "descriptions[{0}].AssemblyFullName", descIndex);
|
||||
string.Create(CultureInfo.InvariantCulture, $"descriptions[{descIndex}].AssemblyFullName");
|
||||
throw PSTraceSource.NewArgumentException(paramName, ConsoleHostUserInterfaceStrings.NullOrEmptyErrorTemplate, paramName);
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ namespace Microsoft.PowerShell
|
||||
private string PromptCommandMode(string input, FieldDescription desc, out bool inputDone)
|
||||
{
|
||||
Dbg.Assert(input != null && input.StartsWith(PromptCommandPrefix, StringComparison.OrdinalIgnoreCase),
|
||||
string.Format(CultureInfo.InvariantCulture, "input should start with {0}", PromptCommandPrefix));
|
||||
string.Create(CultureInfo.InvariantCulture, $"input should start with {PromptCommandPrefix}"));
|
||||
Dbg.Assert(desc != null, "desc should never be null when PromptCommandMode is called");
|
||||
string command = input.Substring(1);
|
||||
|
||||
|
||||
+1
-1
@@ -426,7 +426,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
WriteLineToConsole(
|
||||
WrapToCurrentWindowWidth(
|
||||
string.Format(CultureInfo.InvariantCulture, "{0} - {1}", s, choices[i].HelpMessage)));
|
||||
string.Create(CultureInfo.InvariantCulture, $"{s} - {choices[i].HelpMessage}")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -353,7 +353,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
using var client = new HttpClient();
|
||||
|
||||
string userAgent = string.Format(CultureInfo.InvariantCulture, "PowerShell {0}", PSVersionInfo.GitCommitId);
|
||||
string userAgent = string.Create(CultureInfo.InvariantCulture, $"PowerShell {PSVersionInfo.GitCommitId}");
|
||||
client.DefaultRequestHeaders.Add("User-Agent", userAgent);
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user