Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ public override
{
string msg = StringUtil.Format(ConsoleHostUserInterfaceStrings.RankZeroArrayErrorTemplate, desc.Name);
ArgumentException innerException = PSTraceSource.NewArgumentException(
string.Format(CultureInfo.InvariantCulture,
"descriptions[{0}].AssemblyFullName", descIndex));
string.Create(CultureInfo.InvariantCulture, $"descriptions[{descIndex}].AssemblyFullName"));
PromptingException e = new PromptingException(msg, innerException, "ZeroRankArray", ErrorCategory.InvalidOperation);
throw e;
}
Expand All @@ -203,8 +202,7 @@ public override

while (true)
{
fieldPromptList.Append(
string.Format(CultureInfo.InvariantCulture, "{0}]: ", inputList.Count));
fieldPromptList.AppendFormat(CultureInfo.InvariantCulture, $"{inputList.Count}]: ");
bool endListInput = false;
object convertedObj = null;
_ = PromptForSingleItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ private void WriteChoicePrompt(string[,] hotkeysAndPlainLabels,
defaultStr = hotkeysAndPlainLabels[1, defaultChoice];
}

defaultChoicesBuilder.Append(string.Format(CultureInfo.InvariantCulture,
"{0}{1}", prepend, defaultStr));
defaultChoicesBuilder.AppendFormat(CultureInfo.InvariantCulture, $"{prepend}{defaultStr}");
prepend = ",";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,7 @@ protected string ComputeCurrentXPath()
path.Insert(0, "/");
if (sf.index != -1)
{
path.Insert(1, string.Format(CultureInfo.InvariantCulture,
"{0}[{1}]", sf.node.Name, sf.index + 1));
path.Insert(1, string.Create(CultureInfo.InvariantCulture, $"{sf.node.Name}[{sf.index + 1}]"));
}
else
{
Expand Down
3 changes: 1 addition & 2 deletions src/System.Management.Automation/engine/MshMemberInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3365,8 +3365,7 @@ internal override PSMemberInfoInternalCollection<PSMemberInfo> InternalMembers
break;
default:
Diagnostics.Assert(false,
string.Format(CultureInfo.InvariantCulture,
"PSInternalMemberSet cannot process {0}", name));
string.Create(CultureInfo.InvariantCulture, $"PSInternalMemberSet cannot process {name}"));
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,7 @@ private Collection<int> EmulatePromptForMultipleChoice(string caption,
defaultStr = hotkeysAndPlainLabels[1, defaultChoice];
}

defaultChoicesBuilder.Append(string.Format(Globalization.CultureInfo.InvariantCulture,
"{0}{1}", prepend, defaultStr));
defaultChoicesBuilder.AppendFormat(Globalization.CultureInfo.InvariantCulture, $"{prepend}{defaultStr}");
prepend = ",";
}

Expand Down
12 changes: 4 additions & 8 deletions src/System.Management.Automation/engine/parser/token.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,8 +1290,7 @@ internal NumberToken(InternalScriptExtent scriptExtent, object value, TokenFlags

internal override string ToDebugString(int indent)
{
return string.Format(CultureInfo.InvariantCulture,
"{0}{1}: <{2}> Value:<{3}> Type:<{4}>", StringUtil.Padding(indent), Kind, Text, _value, _value.GetType().Name);
return string.Create(CultureInfo.InvariantCulture, $"{StringUtil.Padding(indent)}{Kind}: <{Text}> Value:<{_value}> Type:<{_value.GetType().Name}>");
}

/// <summary>
Expand Down Expand Up @@ -1332,8 +1331,7 @@ internal ParameterToken(InternalScriptExtent scriptExtent, string parameterName,

internal override string ToDebugString(int indent)
{
return string.Format(CultureInfo.InvariantCulture,
"{0}{1}: <-{2}{3}>", StringUtil.Padding(indent), Kind, _parameterName, _usedColon ? ":" : string.Empty);
return string.Create(CultureInfo.InvariantCulture, $"{StringUtil.Padding(indent)}{Kind}: <-{_parameterName}{(_usedColon ? ":" : string.Empty)}>");
}
}

Expand All @@ -1360,8 +1358,7 @@ internal VariableToken(InternalScriptExtent scriptExtent, VariablePath path, Tok

internal override string ToDebugString(int indent)
{
return string.Format(CultureInfo.InvariantCulture,
"{0}{1}: <{2}> Name:<{3}>", StringUtil.Padding(indent), Kind, Text, Name);
return string.Create(CultureInfo.InvariantCulture, $"{StringUtil.Padding(indent)}{Kind}: <{Text}> Name:<{Name}>");
}
}

Expand All @@ -1383,8 +1380,7 @@ internal StringToken(InternalScriptExtent scriptExtent, TokenKind kind, TokenFla

internal override string ToDebugString(int indent)
{
return string.Format(CultureInfo.InvariantCulture,
"{0}{1}: <{2}> Value:<{3}>", StringUtil.Padding(indent), Kind, Text, Value);
return string.Create(CultureInfo.InvariantCulture, $"{StringUtil.Padding(indent)}{Kind}: <{Text}> Value:<{Value}>");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3307,8 +3307,7 @@ protected void ProcessJobFailure(ExecutionCmdletHelper helper, out Exception fai
errorId = "InvalidSessionState";
if (!string.IsNullOrEmpty(failureException.Source))
{
errorId = string.Format(System.Globalization.CultureInfo.InvariantCulture,
"{0},{1}", errorId, failureException.Source);
errorId = string.Create(System.Globalization.CultureInfo.InvariantCulture, $"{errorId},{failureException.Source}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ internal static string ParseEscapeWSManErrorMessage(string errorMessage)
Collection<PSToken> tokens = PSParser.Tokenize(errorMessage, out parserErrors);
if (parserErrors.Count > 0)
{
tracer.WriteLine(string.Format(CultureInfo.InvariantCulture,
"There were errors parsing string '{0}'", errorMessage);
tracer.WriteLine(string.Create(CultureInfo.InvariantCulture, $"There were errors parsing string '{errorMessage}'");
return errorMessage;
}

Expand Down Expand Up @@ -1399,25 +1398,17 @@ private void Initialize(Uri connectionUri, WSManConnectionInfo connectionInfo)
if (string.IsNullOrEmpty(connectionUri.Query))
{
// if there is no query string already, create one..see RFC 3986
connectionStr = string.Format(CultureInfo.InvariantCulture,
"{0}?PSVersion={1}{2}",
connectionStr = string.Create(CultureInfo.InvariantCulture, $"{connectionStr.TrimEnd('/')}?PSVersion={PSVersionInfo.PSVersion}{additionalUriSuffixString}");
// Trimming the last '/' as this will allow WSMan to
// properly apply URLPrefix.
// Ex: http://localhost?PSVersion=2.0 will be converted
// to http://localhost:<port>/<urlprefix>?PSVersion=2.0
// by WSMan
connectionStr.TrimEnd('/'),
PSVersionInfo.PSVersion,
additionalUriSuffixString);
}
else
{
// if there is already a query string, append using & .. see RFC 3986
connectionStr = string.Format(CultureInfo.InvariantCulture,
"{0};PSVersion={1}{2}",
connectionStr,
PSVersionInfo.PSVersion,
additionalUriSuffixString);
connectionStr = string.Create(CultureInfo.InvariantCulture, $"{connectionStr};PSVersion={PSVersionInfo.PSVersion}{additionalUriSuffixString}");
}

WSManNativeApi.BaseWSManAuthenticationCredentials authCredentials;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7577,8 +7577,7 @@ internal PSCreateInstanceBinder(CallInfo callInfo, PSMethodInvocationConstraints

public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture,
"PSCreateInstanceBinder: ver:{0} args:{1} constraints:<{2}>", _version, _callInfo.ArgumentCount, _constraints != null ? _constraints.ToString() : string.Empty);
return string.Create(CultureInfo.InvariantCulture, $"PSCreateInstanceBinder: ver:{_version} args:{_callInfo.ArgumentCount} constraints:<{(_constraints != null ? _constraints : string.Empty)}>");
}

public override DynamicMetaObject FallbackCreateInstance(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
Expand Down
3 changes: 1 addition & 2 deletions src/System.Management.Automation/help/AliasHelpInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ private AliasHelpInfo(AliasInfo aliasInfo)
}

_fullHelpObject.TypeNames.Clear();
_fullHelpObject.TypeNames.Add(string.Format(Globalization.CultureInfo.InvariantCulture,
"AliasHelpInfo#{0}", Name));
_fullHelpObject.TypeNames.Add(string.Create(Globalization.CultureInfo.InvariantCulture, $"AliasHelpInfo#{Name}"));
_fullHelpObject.TypeNames.Add("AliasHelpInfo");
_fullHelpObject.TypeNames.Add("HelpInfo");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ internal Uri LookupUriFromCommandInfo()
string commandToSearch = commandName;
if (!string.IsNullOrEmpty(moduleName))
{
commandToSearch = string.Format(CultureInfo.InvariantCulture,
"{0}\\{1}", moduleName, commandName);
commandToSearch = string.Create(CultureInfo.InvariantCulture, $"{moduleName}\\{commandName}");
}

ExecutionContext context = LocalPipeline.GetExecutionContextFromTLS();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -950,15 +950,13 @@ private void AddToCommandCache(string mshSnapInId, string cmdletName, MamlComman

// Add snapin qualified type name for this command at the top..
// this will enable customizations of the help object.
helpInfo.FullHelp.TypeNames.Insert(0, string.Format(CultureInfo.InvariantCulture,
"MamlCommandHelpInfo#{0}#{1}", mshSnapInId, cmdletName));
helpInfo.FullHelp.TypeNames.Insert(0, string.Create(CultureInfo.InvariantCulture, $"MamlCommandHelpInfo#{mshSnapInId}#{cmdletName}"));

if (!string.IsNullOrEmpty(mshSnapInId))
{
key = mshSnapInId + "\\" + key;
// Add snapin name to the typenames of this object
helpInfo.FullHelp.TypeNames.Insert(1, string.Format(CultureInfo.InvariantCulture,
"MamlCommandHelpInfo#{0}", mshSnapInId));
helpInfo.FullHelp.TypeNames.Insert(1, string.Create(CultureInfo.InvariantCulture, $"MamlCommandHelpInfo#{mshSnapInId}"));
}

AddCache(key, helpInfo);
Expand Down
3 changes: 1 addition & 2 deletions src/System.Management.Automation/help/HelpCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,7 @@ public static string GetHelpUri(PSObject commandInfoPSObject)
string cmdName = cmdInfo.Name;
if (!string.IsNullOrEmpty(cmdInfo.ModuleName))
{
cmdName = string.Format(CultureInfo.InvariantCulture,
"{0}\\{1}", cmdInfo.ModuleName, cmdInfo.Name);
cmdName = string.Create(CultureInfo.InvariantCulture, $"{cmdInfo.ModuleName}\\{cmdInfo.Name}");
}

if (DoesCurrentRunspaceIncludeCoreHelpCmdlet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,12 @@ private void LoadHelpFile(ProviderInfo providerInfo)
this.HelpSystem.TraceErrors(helpInfo.Errors);
// Add snapin qualified type name for this command..
// this will enable customizations of the help object.
helpInfo.FullHelp.TypeNames.Insert(0, string.Format(CultureInfo.InvariantCulture,
"ProviderHelpInfo#{0}#{1}", providerInfo.PSSnapInName, helpInfo.Name));
helpInfo.FullHelp.TypeNames.Insert(0, string.Create(CultureInfo.InvariantCulture, $"ProviderHelpInfo#{providerInfo.PSSnapInName}#{helpInfo.Name}"));

if (!string.IsNullOrEmpty(providerInfo.PSSnapInName))
{
helpInfo.FullHelp.Properties.Add(new PSNoteProperty("PSSnapIn", providerInfo.PSSnapIn));
helpInfo.FullHelp.TypeNames.Insert(1, string.Format(CultureInfo.InvariantCulture,
"ProviderHelpInfo#{0}", providerInfo.PSSnapInName));
helpInfo.FullHelp.TypeNames.Insert(1, string.Create(CultureInfo.InvariantCulture, $"ProviderHelpInfo#{providerInfo.PSSnapInName}"));
}

AddCache(providerInfo.PSSnapInName + "\\" + helpInfo.Name, helpInfo);
Expand Down