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
8 changes: 0 additions & 8 deletions src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,6 @@ internal static string GetSourceCodeInformation(bool withFileName, int depth)
{
StackTrace trace = new();
StackFrame frame = trace.GetFrame(depth);
// if (withFileName)
// {
// return string.Create(CultureInfo.CurrentUICulture, $"{frame.GetFileName().}#{frame.GetFileLineNumber()}:{frame.GetMethod().Name}:");
// }
// else
// {
// return string.Create(CultureInfo.CurrentUICulture, $"{frame.GetMethod()}:");
// }

return string.Create(CultureInfo.CurrentUICulture, $"{frame.GetMethod().DeclaringType.Name}::{frame.GetMethod().Name} ");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected virtual string GetPattern()
patterns.Add(rule.Pattern);
}

patterns.Add(string.Create(CultureInfo.InvariantCulture, $"(?<{FullTextRuleGroupName}>){ValuePattern}"));
patterns.Add(string.Format(CultureInfo.InvariantCulture, "(?<{0}>){1}", FullTextRuleGroupName, ValuePattern));

return string.Join("|", patterns.ToArray());
}
Expand Down Expand Up @@ -199,7 +199,12 @@ public SearchableRule(string uniqueId, SelectorFilterRule selectorFilterRule, Te
this.UniqueId = uniqueId;
this.selectorFilterRule = selectorFilterRule;
this.childRule = childRule;
this.Pattern = string.Create(CultureInfo.InvariantCulture, $"(?<{uniqueId}>){Regex.Escape(selectorFilterRule.DisplayName)}\\s*:\\s*{SearchTextParser.ValuePattern}");
this.Pattern = string.Format(
CultureInfo.InvariantCulture,
"(?<{0}>){1}\\s*:\\s*{2}",
uniqueId,
Regex.Escape(selectorFilterRule.DisplayName),
SearchTextParser.ValuePattern);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private void ProcessString(string originalString)
private static readonly Random _idGenerator = new();

private static string GetGroupLabel(Type inputType)
=> string.Create(System.Globalization.CultureInfo.InvariantCulture, $"{inputType.Name} ({inputType.FullName}) <{_idGenerator.Next():X8}>");
=> string.Format("{0} ({1}) <{2:X8}>", inputType.Name, inputType.FullName, _idGenerator.Next());

private void FlushInputBuffer()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2594,7 +2594,8 @@ private string GenerateConnectionStringForNewRunspace()
}
else
{
return string.Create(CultureInfo.InvariantCulture, $"-connectionUri '{CodeGeneration.EscapeSingleQuotedStringContent(GetConnectionString())}'");
string connectionString = CodeGeneration.EscapeSingleQuotedStringContent(GetConnectionString());
return string.Create(CultureInfo.InvariantCulture, $"-connectionUri '{connectionString}'");
}
}

Expand Down
12 changes: 9 additions & 3 deletions src/Microsoft.WSMan.Management/CredSSP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ private void DisableServerSideSettings()
return;
}

string inputXml = string.Create(CultureInfo.InvariantCulture, $@"<cfg:Auth xmlns:cfg=""{helper.Service_CredSSP_XMLNmsp}""><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>");
string inputXml = string.Format(
CultureInfo.InvariantCulture,
@"<cfg:Auth xmlns:cfg=""{0}""><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>",
helper.Service_CredSSP_XMLNmsp);

m_SessionObj.Put(helper.Service_CredSSP_Uri, inputXml, 0);
}
Expand Down Expand Up @@ -591,8 +594,11 @@ private void EnableServerSideSettings()
try
{
XmlDocument xmldoc = new XmlDocument();
string newxmlcontent = string.Create(CultureInfo.InvariantCulture, $@"<cfg:Auth xmlns:cfg=""{helper.Service_CredSSP_XMLNmsp}""><cfg:CredSSP>true</cfg:CredSSP></cfg:Auth>");

string newxmlcontent = string.Format(
CultureInfo.InvariantCulture,
@"<cfg:Auth xmlns:cfg=""{0}""><cfg:CredSSP>true</cfg:CredSSP></cfg:Auth>",
helper.Service_CredSSP_XMLNmsp);

// push the xml string with credssp enabled
xmldoc.LoadXml(m_SessionObj.Put(helper.Service_CredSSP_Uri, newxmlcontent, 0));
WriteObject(xmldoc.FirstChild);
Expand Down
24 changes: 16 additions & 8 deletions src/System.Management.Automation/DscSupport/CimDSCParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2532,9 +2532,12 @@ private static void ProcessMembers(StringBuilder sb, List<object> embeddedInstan
out embeddedInstanceType, embeddedInstanceTypes, ref enumNames);
}

string mofAttr = MapAttributesToMof(enumNames, attributes, embeddedInstanceType);
string arrayAffix = isArrayType ? "[]" : string.Empty;

sb.Append(CultureInfo.InvariantCulture, $" {MapAttributesToMof(enumNames, attributes, embeddedInstanceType)}{mofType} {member.Name}{arrayAffix};\n");
sb.Append(
CultureInfo.InvariantCulture,
$" {mofAttr}{mofType} {member.Name}{arrayAffix};\n");
}
}

Expand Down Expand Up @@ -3082,16 +3085,21 @@ private static void ProcessMembers(Type type, StringBuilder sb, List<object> emb
}

// TODO - validate type and name
bool isArrayType;
string embeddedInstanceType;
string mofType = MapTypeToMofType(memberType, member.Name, className, out isArrayType, out embeddedInstanceType,
string mofType = MapTypeToMofType(
memberType,
member.Name,
className,
out bool isArrayType,
out string embeddedInstanceType,
embeddedInstanceTypes);

var enumNames = memberType.IsEnum ? Enum.GetNames(memberType) : null;
string mofAttr = MapAttributesToMof(enumNames, member.GetCustomAttributes(true), embeddedInstanceType);
string arrayAffix = isArrayType ? "[]" : string.Empty;

var enumNames = memberType.IsEnum
? Enum.GetNames(memberType)
: null;
sb.Append(CultureInfo.InvariantCulture, $" {MapAttributesToMof(enumNames, member.GetCustomAttributes(true), embeddedInstanceType)}{mofType} {member.Name}{arrayAffix};\n");
sb.Append(
CultureInfo.InvariantCulture,
$" {mofAttr}{mofType} {member.Name}{arrayAffix};\n");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,13 @@ private void LoadData(ExtendedTypeDefinition typeDefinition, TypeInfoDataBase db
ViewDefinition view = LoadViewFromObjectModel(typeDefinition.TypeNames, formatView, viewIndex++);
if (view != null)
{
ReportTrace(string.Create(CultureInfo.InvariantCulture, $"{ControlBase.GetControlShapeName(view.mainControl)} view {view.name} is loaded from the 'FormatViewDefinition' at index {viewIndex - 1} in 'ExtendedTypeDefinition' with type name {typeDefinition.TypeName}"));
ReportTrace(string.Format(
CultureInfo.InvariantCulture,
"{0} view {1} is loaded from the 'FormatViewDefinition' at index {2} in 'ExtendedTypeDefinition' with type name {3}",
ControlBase.GetControlShapeName(view.mainControl),
view.name,
viewIndex - 1,
typeDefinition.TypeName));

// we are fine, add the view to the list
db.viewDefinitionsSection.viewDefinitionList.Add(view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ private void LoadViewDefinitions(TypeInfoDataBase db, XmlNode viewDefinitionsNod
ViewDefinition view = LoadView(n, index++);
if (view != null)
{
ReportTrace(string.Create(CultureInfo.InvariantCulture, $"{ControlBase.GetControlShapeName(view.mainControl)} view {view.name} is loaded from file {view.loadingInfo.filePath}"));
ReportTrace(string.Format(
CultureInfo.InvariantCulture,
"{0} view {1} is loaded from file {2}",
ControlBase.GetControlShapeName(view.mainControl),
view.name,
view.loadingInfo.filePath));
// we are fine, add the view to the list
db.viewDefinitionsSection.viewDefinitionList.Add(view);
}
Expand Down
8 changes: 5 additions & 3 deletions src/System.Management.Automation/engine/CommandMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@ internal string GetBeginBlock()
commandOrigin = string.Empty;
}

string wrappedCommand = CodeGeneration.EscapeSingleQuotedStringContent(_wrappedCommand);
if (_wrappedAnyCmdlet)
{
result = string.Create(CultureInfo.InvariantCulture, $@"
Expand All @@ -1019,7 +1020,7 @@ internal string GetBeginBlock()
$PSBoundParameters['OutBuffer'] = 1
}}

$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('{CodeGeneration.EscapeSingleQuotedStringContent(_wrappedCommand)}', [System.Management.Automation.CommandTypes]::{_wrappedCommandType})
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('{wrappedCommand}', [System.Management.Automation.CommandTypes]::{_wrappedCommandType})
$scriptCmd = {{& $wrappedCmd @PSBoundParameters }}

$steppablePipeline = $scriptCmd.GetSteppablePipeline({commandOrigin})
Expand All @@ -1033,7 +1034,7 @@ internal string GetBeginBlock()
{
result = string.Create(CultureInfo.InvariantCulture, $@"
try {{
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('{CodeGeneration.EscapeSingleQuotedStringContent(_wrappedCommand)}', [System.Management.Automation.CommandTypes]::{_wrappedCommandType})
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('{wrappedCommand}', [System.Management.Automation.CommandTypes]::{_wrappedCommandType})
$PSBoundParameters.Add('$args', $args)
$scriptCmd = {{& $wrappedCmd @PSBoundParameters }}

Expand Down Expand Up @@ -1066,9 +1067,10 @@ internal string GetProcessBlock()

internal string GetDynamicParamBlock()
{
string wrappedCommand = CodeGeneration.EscapeSingleQuotedStringContent(_wrappedCommand);
return string.Create(CultureInfo.InvariantCulture, $@"
try {{
$targetCmd = $ExecutionContext.InvokeCommand.GetCommand('{CodeGeneration.EscapeSingleQuotedStringContent(_wrappedCommand)}', [System.Management.Automation.CommandTypes]::{_wrappedCommandType}, $PSBoundParameters)
$targetCmd = $ExecutionContext.InvokeCommand.GetCommand('{wrappedCommand}', [System.Management.Automation.CommandTypes]::{_wrappedCommandType}, $PSBoundParameters)
$dynamicParams = @($targetCmd.Parameters.GetEnumerator() | Microsoft.PowerShell.Core\Where-Object {{ $_.Value.IsDynamic }})
if ($dynamicParams.Length -gt 0)
{{
Expand Down
14 changes: 12 additions & 2 deletions src/System.Management.Automation/engine/GetCommandCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,12 @@ private PSObject GetSyntaxObject(CommandInfo command)
switch (command)
{
case ExternalScriptInfo externalScript:
replacedSyntax = string.Create(CultureInfo.InvariantCulture, $"{aliasName} (alias) -> {externalScript.Path}{Environment.NewLine}{Environment.NewLine}{command.Syntax.Replace(command.Name, aliasName)}");
replacedSyntax = string.Format(
"{0} (alias) -> {1}{2}{3}",
aliasName,
string.Format("{0}{1}", externalScript.Path, Environment.NewLine),
Environment.NewLine,
command.Syntax.Replace(command.Name, aliasName));
break;
case ApplicationInfo app:
replacedSyntax = app.Path;
Expand All @@ -626,7 +631,12 @@ private PSObject GetSyntaxObject(CommandInfo command)
}
else
{
replacedSyntax = string.Create(CultureInfo.InvariantCulture, $"{aliasName} (alias) -> {command.Name}{Environment.NewLine}{command.Syntax.Replace(command.Name, aliasName)}");
replacedSyntax = string.Format(
"{0} (alias) -> {1}{2}{3}",
aliasName,
command.Name,
Environment.NewLine,
command.Syntax.Replace(command.Name, aliasName));
}

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,11 @@ protected static string GetEmbeddedObjectTypeName(PropertyData pData)
try
{
string cimType = (string)pData.Qualifiers["cimtype"].Value;
result = string.Create(CultureInfo.InvariantCulture, $"{typeof(ManagementObject).FullName}#{cimType.Replace("object:", string.Empty)}");
result = string.Format(
CultureInfo.InvariantCulture,
"{0}#{1}",
typeof(ManagementObject).FullName,
cimType.Replace("object:", string.Empty));
}
catch (ManagementException)
{
Expand Down
35 changes: 11 additions & 24 deletions src/System.Management.Automation/engine/ParameterSetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,40 +238,27 @@ private static void AppendFormatCommandParameterInfo(CommandParameterInfo parame

if (parameter.ParameterType == typeof(SwitchParameter))
{
if (parameter.IsMandatory)
{
result.Append($"-{parameter.Name}");
}
else
{
result.Append($"[-{parameter.Name}]");
}
result.AppendFormat(CultureInfo.InvariantCulture, parameter.IsMandatory ? "-{0}" : "[-{0}]", parameter.Name);
}
else
{
string parameterTypeString = GetParameterTypeString(parameter.ParameterType, parameter.Attributes);

if (parameter.IsMandatory)
{
if (parameter.Position != int.MinValue)
{
result.Append($"[-{parameter.Name}] <{parameterTypeString}>");
}
else
{
result.Append($"-{parameter.Name} <{parameterTypeString}>");
}
result.AppendFormat(
CultureInfo.InvariantCulture,
parameter.Position != int.MinValue ? "[-{0}] <{1}>" : "-{0} <{1}>",
parameter.Name,
parameterTypeString);
}
else
{
if (parameter.Position != int.MinValue)
{
result.Append($"[[-{parameter.Name}] <{parameterTypeString}>]");
}
else
{
result.Append($"[-{parameter.Name} <{parameterTypeString}>]");
}
result.AppendFormat(
CultureInfo.InvariantCulture,
parameter.Position != int.MinValue ? "[[-{0}] <{1}>]" : "[-{0} <{1}>]",
parameter.Name,
parameterTypeString);
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/System.Management.Automation/engine/debugger/debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5301,10 +5301,9 @@ private void DisplayScript(PSHost host, IList<PSObject> output, InvocationInfo i
for (int lineNumber = start; lineNumber <= _lines.Length && lineNumber < start + count; lineNumber++)
{
WriteLine(
lineNumber == invocationInfo.ScriptLineNumber ?
string.Create(CultureInfo.CurrentCulture, $"{lineNumber,5}:* { _lines[lineNumber - 1]}")
:
string.Create(CultureInfo.CurrentCulture, $"{lineNumber,5}: { _lines[lineNumber - 1]}"),
lineNumber == invocationInfo.ScriptLineNumber
? string.Format(CultureInfo.CurrentCulture, "{0,5}:* {1}", lineNumber, _lines[lineNumber - 1])
: string.Format(CultureInfo.CurrentCulture, "{0,5}: {1}", lineNumber, _lines[lineNumber - 1]),
host,
output);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,19 @@ runspace.ConnectionInfo is VMConnectionInfo ||
!string.IsNullOrEmpty(sshConnectionInfo.UserName) &&
!System.Environment.UserName.Equals(sshConnectionInfo.UserName, StringComparison.Ordinal))
{
return string.Create(CultureInfo.InvariantCulture, $"[{sshConnectionInfo.UserName}@{sshConnectionInfo.ComputerName}]: {basePrompt}");
return string.Format(
CultureInfo.InvariantCulture,
"[{0}@{1}]: {2}",
sshConnectionInfo.UserName,
sshConnectionInfo.ComputerName,
basePrompt);
}

return string.Create(CultureInfo.InvariantCulture, $"[{runspace.ConnectionInfo.ComputerName}]: {basePrompt}");
return string.Format(
CultureInfo.InvariantCulture,
"[{0}]: {1}",
runspace.ConnectionInfo.ComputerName,
basePrompt);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public RuntimeLabel(int index, int continuationStackDepth, int stackDepth)

public override string ToString()
{
return string.Create(CultureInfo.InvariantCulture, $"->{Index} C({ContinuationStackDepth}) S({StackDepth})");
return string.Format(CultureInfo.InvariantCulture, "->{0} C({1}) S({2})", Index, ContinuationStackDepth, StackDepth);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ internal bool IsInsideFinallyBlock(int index)

public override string ToString()
{
return string.Create(CultureInfo.InvariantCulture, $"{(IsFault ? "fault" : "catch(" + ExceptionType.Name + ")")} [{StartIndex}-{EndIndex}] [{HandlerStartIndex}->{HandlerEndIndex}]");
return string.Format(
CultureInfo.InvariantCulture,
"{0} [{1}-{2}] [{3}->{4}]",
IsFault ? "fault" : "catch(" + ExceptionType.Name + ")",
StartIndex,
EndIndex,
HandlerStartIndex,
HandlerEndIndex);
}
}

Expand Down Expand Up @@ -227,11 +234,11 @@ public override string ToString()
{
if (IsClear)
{
return string.Create(CultureInfo.InvariantCulture, $"{Index}: clear");
return string.Format(CultureInfo.InvariantCulture, "{0}: clear", Index);
}
else
{
return string.Create(CultureInfo.InvariantCulture, $"{Index}: [{StartLine}-{EndLine}] '{FileName}'");
return string.Format(CultureInfo.InvariantCulture, "{0}: [{1}-{2}] '{3}'", Index, StartLine, EndLine, FileName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ internal Expression LoadFromArray(Expression frameData, Expression closure)

public override string ToString()
{
return string.Create(CultureInfo.InvariantCulture, $"{Index}: {(IsBoxed ? "boxed" : null)} {(InClosure ? "in closure" : null)}");
return string.Format(CultureInfo.InvariantCulture, "{0}: {1} {2}", Index, IsBoxed ? "boxed" : null, InClosure ? "in closure" : null);
}
}

Expand Down
Loading