diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs index be517c9864c..adcab254231 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs @@ -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} "); } diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/SearchTextParser.cs b/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/SearchTextParser.cs index 8900964fba2..2e0ac74e076 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/SearchTextParser.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/SearchTextParser.cs @@ -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()); } @@ -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); } /// diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs index b6a6d024396..de73b2155a6 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs @@ -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() { diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs index 6d51d972916..2e2e5acbfe3 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs @@ -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}'"); } } diff --git a/src/Microsoft.WSMan.Management/CredSSP.cs b/src/Microsoft.WSMan.Management/CredSSP.cs index 13e99c04f1f..c59daa39bfc 100644 --- a/src/Microsoft.WSMan.Management/CredSSP.cs +++ b/src/Microsoft.WSMan.Management/CredSSP.cs @@ -200,7 +200,10 @@ private void DisableServerSideSettings() return; } - string inputXml = string.Create(CultureInfo.InvariantCulture, $@"false"); + string inputXml = string.Format( + CultureInfo.InvariantCulture, + @"false", + helper.Service_CredSSP_XMLNmsp); m_SessionObj.Put(helper.Service_CredSSP_Uri, inputXml, 0); } @@ -591,8 +594,11 @@ private void EnableServerSideSettings() try { XmlDocument xmldoc = new XmlDocument(); - string newxmlcontent = string.Create(CultureInfo.InvariantCulture, $@"true"); - + string newxmlcontent = string.Format( + CultureInfo.InvariantCulture, + @"true", + 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); diff --git a/src/System.Management.Automation/DscSupport/CimDSCParser.cs b/src/System.Management.Automation/DscSupport/CimDSCParser.cs index ab7536b7e4f..fb903557655 100644 --- a/src/System.Management.Automation/DscSupport/CimDSCParser.cs +++ b/src/System.Management.Automation/DscSupport/CimDSCParser.cs @@ -2532,9 +2532,12 @@ private static void ProcessMembers(StringBuilder sb, List 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"); } } @@ -3082,16 +3085,21 @@ private static void ProcessMembers(Type type, StringBuilder sb, List 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"); } } diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs index d13177af484..5a241d0fed1 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs @@ -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); diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs index a92f7a6b105..c6d191284e6 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs @@ -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); } diff --git a/src/System.Management.Automation/engine/CommandMetadata.cs b/src/System.Management.Automation/engine/CommandMetadata.cs index aba83a1632d..df767f714b0 100644 --- a/src/System.Management.Automation/engine/CommandMetadata.cs +++ b/src/System.Management.Automation/engine/CommandMetadata.cs @@ -1009,6 +1009,7 @@ internal string GetBeginBlock() commandOrigin = string.Empty; } + string wrappedCommand = CodeGeneration.EscapeSingleQuotedStringContent(_wrappedCommand); if (_wrappedAnyCmdlet) { result = string.Create(CultureInfo.InvariantCulture, $@" @@ -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}) @@ -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 }} @@ -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) {{ diff --git a/src/System.Management.Automation/engine/GetCommandCommand.cs b/src/System.Management.Automation/engine/GetCommandCommand.cs index a3263799cda..81675d7b663 100644 --- a/src/System.Management.Automation/engine/GetCommandCommand.cs +++ b/src/System.Management.Automation/engine/GetCommandCommand.cs @@ -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; @@ -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; diff --git a/src/System.Management.Automation/engine/ManagementObjectAdapter.cs b/src/System.Management.Automation/engine/ManagementObjectAdapter.cs index cfe7ce32ee4..aa1c151e0e3 100644 --- a/src/System.Management.Automation/engine/ManagementObjectAdapter.cs +++ b/src/System.Management.Automation/engine/ManagementObjectAdapter.cs @@ -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) { diff --git a/src/System.Management.Automation/engine/ParameterSetInfo.cs b/src/System.Management.Automation/engine/ParameterSetInfo.cs index 2574c086b53..5d81b8553cf 100644 --- a/src/System.Management.Automation/engine/ParameterSetInfo.cs +++ b/src/System.Management.Automation/engine/ParameterSetInfo.cs @@ -238,14 +238,7 @@ 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 { @@ -253,25 +246,19 @@ private static void AppendFormatCommandParameterInfo(CommandParameterInfo parame 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); } } } diff --git a/src/System.Management.Automation/engine/debugger/debugger.cs b/src/System.Management.Automation/engine/debugger/debugger.cs index c7b116a4d5f..059c68643ab 100644 --- a/src/System.Management.Automation/engine/debugger/debugger.cs +++ b/src/System.Management.Automation/engine/debugger/debugger.cs @@ -5301,10 +5301,9 @@ private void DisplayScript(PSHost host, IList 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); diff --git a/src/System.Management.Automation/engine/hostifaces/HostUtilities.cs b/src/System.Management.Automation/engine/hostifaces/HostUtilities.cs index 63ea2e9dc4b..1f88f48eaf5 100644 --- a/src/System.Management.Automation/engine/hostifaces/HostUtilities.cs +++ b/src/System.Management.Automation/engine/hostifaces/HostUtilities.cs @@ -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); } /// diff --git a/src/System.Management.Automation/engine/interpreter/BranchLabel.cs b/src/System.Management.Automation/engine/interpreter/BranchLabel.cs index d8999084232..1bae16783a9 100644 --- a/src/System.Management.Automation/engine/interpreter/BranchLabel.cs +++ b/src/System.Management.Automation/engine/interpreter/BranchLabel.cs @@ -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); } } diff --git a/src/System.Management.Automation/engine/interpreter/LightCompiler.cs b/src/System.Management.Automation/engine/interpreter/LightCompiler.cs index 1243b1b6e3e..700850fb394 100644 --- a/src/System.Management.Automation/engine/interpreter/LightCompiler.cs +++ b/src/System.Management.Automation/engine/interpreter/LightCompiler.cs @@ -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); } } @@ -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); } } } diff --git a/src/System.Management.Automation/engine/interpreter/LocalVariables.cs b/src/System.Management.Automation/engine/interpreter/LocalVariables.cs index af916482260..0c1f6416741 100644 --- a/src/System.Management.Automation/engine/interpreter/LocalVariables.cs +++ b/src/System.Management.Automation/engine/interpreter/LocalVariables.cs @@ -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); } } diff --git a/src/System.Management.Automation/engine/interpreter/StackOperations.cs b/src/System.Management.Automation/engine/interpreter/StackOperations.cs index 74f926a37a3..51a5f03348c 100644 --- a/src/System.Management.Automation/engine/interpreter/StackOperations.cs +++ b/src/System.Management.Automation/engine/interpreter/StackOperations.cs @@ -60,7 +60,7 @@ public override int Run(InterpretedFrame frame) public override string ToDebugString(int instructionIndex, object cookie, Func labelIndexer, IList objects) { - return string.Create(CultureInfo.InvariantCulture, $"LoadCached({_index}: {objects[(int)_index]})"); + return string.Format(CultureInfo.InvariantCulture, "LoadCached({0}: {1})", _index, objects[(int)_index]); } public override string ToString() diff --git a/src/System.Management.Automation/engine/parser/DebugViewWriter.cs b/src/System.Management.Automation/engine/parser/DebugViewWriter.cs index 091ded80e19..cb280bdaf61 100644 --- a/src/System.Management.Automation/engine/parser/DebugViewWriter.cs +++ b/src/System.Management.Automation/engine/parser/DebugViewWriter.cs @@ -447,7 +447,12 @@ protected override Expression VisitParameter(ParameterExpression node) { protected override Expression VisitLambda(Expression node) { Out( - string.Create(CultureInfo.CurrentCulture, $".Lambda {GetLambdaName(node)}<{node.Type}>") + string.Format(CultureInfo.CurrentCulture, + "{0} {1}<{2}>", + ".Lambda", + GetLambdaName(node), + node.Type.ToString() + ) ); if (_lambdas == null) { diff --git a/src/System.Management.Automation/engine/parser/Parser.cs b/src/System.Management.Automation/engine/parser/Parser.cs index b8afb42472b..f110845afdf 100644 --- a/src/System.Management.Automation/engine/parser/Parser.cs +++ b/src/System.Management.Automation/engine/parser/Parser.cs @@ -8044,7 +8044,7 @@ private static void AssertErrorIdCorrespondsToMsgString(string errorId, string e } } - Diagnostics.Assert(msgCorrespondsToString, string.Create(CultureInfo.InvariantCulture, $"Parser error ID \"{errorId}\" must correspond to the error message \"{errorMsg}\"")); + Diagnostics.Assert(msgCorrespondsToString, $"Parser error ID \"{errorId}\" must correspond to the error message \"{errorMsg}\""); } private static object[] arrayOfOneArg diff --git a/src/System.Management.Automation/engine/parser/Position.cs b/src/System.Management.Automation/engine/parser/Position.cs index bc2aab73d9d..571a0c587f4 100644 --- a/src/System.Management.Automation/engine/parser/Position.cs +++ b/src/System.Management.Automation/engine/parser/Position.cs @@ -766,7 +766,9 @@ public string Text _endPosition.ColumnNumber - _startPosition.ColumnNumber); } - return string.Create(CultureInfo.InvariantCulture, $"{_startPosition.Line.AsSpan(_startPosition.ColumnNumber)}...{ _endPosition.Line.AsSpan(0, _endPosition.ColumnNumber)}"); + var start = _startPosition.Line.AsSpan(_startPosition.ColumnNumber); + var end = _endPosition.Line.AsSpan(0, _endPosition.ColumnNumber); + return string.Create(CultureInfo.InvariantCulture, $"{start}...{end}"); } else { diff --git a/src/System.Management.Automation/engine/parser/token.cs b/src/System.Management.Automation/engine/parser/token.cs index 85862c01395..11d0a632cb5 100644 --- a/src/System.Management.Automation/engine/parser/token.cs +++ b/src/System.Management.Automation/engine/parser/token.cs @@ -1290,7 +1290,14 @@ internal NumberToken(InternalScriptExtent scriptExtent, object value, TokenFlags internal override string ToDebugString(int indent) { - return string.Create(CultureInfo.InvariantCulture, $"{StringUtil.Padding(indent)}{Kind}: <{Text}> Value:<{_value}> Type:<{_value.GetType().Name}>"); + return string.Format( + CultureInfo.InvariantCulture, + "{0}{1}: <{2}> Value:<{3}> Type:<{4}>", + StringUtil.Padding(indent), + Kind, + Text, + _value, + _value.GetType().Name); } /// @@ -1331,7 +1338,13 @@ internal ParameterToken(InternalScriptExtent scriptExtent, string parameterName, internal override string ToDebugString(int indent) { - return string.Create(CultureInfo.InvariantCulture, $"{StringUtil.Padding(indent)}{Kind}: <-{_parameterName}{(_usedColon ? ":" : string.Empty)}>"); + return string.Format( + CultureInfo.InvariantCulture, + "{0}{1}: <-{2}{3}>", + StringUtil.Padding(indent), + Kind, + _parameterName, + _usedColon ? ":" : string.Empty); } } @@ -1358,7 +1371,13 @@ internal VariableToken(InternalScriptExtent scriptExtent, VariablePath path, Tok internal override string ToDebugString(int indent) { - return string.Create(CultureInfo.InvariantCulture, $"{StringUtil.Padding(indent)}{Kind}: <{Text}> Name:<{Name}>"); + return string.Format( + CultureInfo.InvariantCulture, + "{0}{1}: <{2}> Name:<{3}>", + StringUtil.Padding(indent), + Kind, + Text, + Name); } } @@ -1380,7 +1399,13 @@ internal StringToken(InternalScriptExtent scriptExtent, TokenKind kind, TokenFla internal override string ToDebugString(int indent) { - return string.Create(CultureInfo.InvariantCulture, $"{StringUtil.Padding(indent)}{Kind}: <{Text}> Value:<{Value}>"); + return string.Format( + CultureInfo.InvariantCulture, + "{0}{1}: <{2}> Value:<{3}>", + StringUtil.Padding(indent), + Kind, + Text, + Value); } } diff --git a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs index af13d2fab46..2a9d68bd55f 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs @@ -363,8 +363,12 @@ internal void ProcessRawData(byte[] data, if (!shouldProcess) { // we dont support this stream..so ignore the data - Dbg.Assert(false, - string.Create(CultureInfo.InvariantCulture, $"Data should be from one of the streams : {WSManNativeApi.WSMAN_STREAM_ID_STDIN} or {WSManNativeApi.WSMAN_STREAM_ID_STDOUT} or {WSManNativeApi.WSMAN_STREAM_ID_PROMPTRESPONSE}")); + Dbg.Assert(false, string.Format( + CultureInfo.InvariantCulture, + "Data should be from one of the streams : {0} or {1} or {2}", + WSManNativeApi.WSMAN_STREAM_ID_STDIN, + WSManNativeApi.WSMAN_STREAM_ID_STDOUT, + WSManNativeApi.WSMAN_STREAM_ID_PROMPTRESPONSE)); s_baseTracer.WriteLine("{0} is not a valid stream", stream); } // process data diff --git a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs index 0759f7bcb70..96a8b833885 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs @@ -75,7 +75,15 @@ static OutOfProcessUtils() internal static string CreateDataPacket(byte[] data, DataPriorityType streamType, Guid psGuid) { - string result = string.Create(CultureInfo.InvariantCulture, $"<{PS_OUT_OF_PROC_DATA_TAG} {PS_OUT_OF_PROC_STREAM_ATTRIBUTE}='{streamType}' {PS_OUT_OF_PROC_PSGUID_ATTRIBUTE}='{psGuid}'>{Convert.ToBase64String(data)}"); + string result = string.Format( + CultureInfo.InvariantCulture, + "<{0} {1}='{2}' {3}='{4}'>{5}", + PS_OUT_OF_PROC_DATA_TAG, + PS_OUT_OF_PROC_STREAM_ATTRIBUTE, + streamType.ToString(), + PS_OUT_OF_PROC_PSGUID_ATTRIBUTE, + psGuid.ToString(), + Convert.ToBase64String(data)); return result; } @@ -124,7 +132,12 @@ internal static string CreateSignalAckPacket(Guid psGuid) /// private static string CreatePSGuidPacket(string element, Guid psGuid) { - string result = string.Create(CultureInfo.InvariantCulture, $"<{element} {PS_OUT_OF_PROC_PSGUID_ATTRIBUTE}='{psGuid}' />"); + string result = string.Format( + CultureInfo.InvariantCulture, + "<{0} {1}='{2}' />", + element, + PS_OUT_OF_PROC_PSGUID_ATTRIBUTE, + psGuid.ToString()); return result; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs index 4f0af020ea4..c7bf908d56b 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs @@ -468,7 +468,12 @@ internal override void ExecuteConnect( _remoteSession.ExecuteConnect(inputData, out outputData); // construct Xml to send back - string responseData = string.Create(System.Globalization.CultureInfo.InvariantCulture, $"<{WSManNativeApi.PS_CONNECTRESPONSE_XML_TAG} xmlns=\"{WSManNativeApi.PS_XML_NAMESPACE}\">{Convert.ToBase64String(outputData)}"); + string responseData = string.Format( + System.Globalization.CultureInfo.InvariantCulture, + "<{0} xmlns=\"{1}\">{2}", + WSManNativeApi.PS_CONNECTRESPONSE_XML_TAG, + WSManNativeApi.PS_XML_NAMESPACE, + Convert.ToBase64String(outputData)); // TODO: currently using OperationComplete to report back the responseXml. This will need to change to use WSManReportObject // that is currently internal. diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs index b8e417da547..d344e5c386e 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs @@ -925,7 +925,12 @@ internal override void ConnectAsync() { // WSMan expects the data to be in XML format (which is text + xml tags) // so convert byte[] into base64 encoded format - string base64EncodedDataInXml = string.Create(CultureInfo.InvariantCulture, $"<{WSManNativeApi.PS_CONNECT_XML_TAG} xmlns=\"{WSManNativeApi.PS_XML_NAMESPACE}\">{Convert.ToBase64String(additionalData)}"); + string base64EncodedDataInXml = string.Format( + CultureInfo.InvariantCulture, + "<{0} xmlns=\"{1}\">{2}", + WSManNativeApi.PS_CONNECT_XML_TAG, + WSManNativeApi.PS_XML_NAMESPACE, + Convert.ToBase64String(additionalData)); _openContent = new WSManNativeApi.WSManData_ManToUn(base64EncodedDataInXml); } @@ -1093,7 +1098,12 @@ public override void CreateAsync() { // WSMan expects the data to be in XML format (which is text + xml tags) // so convert byte[] into base64 encoded format - string base64EncodedDataInXml = string.Create(CultureInfo.InvariantCulture, $"<{WSManNativeApi.PS_CREATION_XML_TAG} xmlns=\"{WSManNativeApi.PS_XML_NAMESPACE}\">{Convert.ToBase64String(additionalData)}"); + string base64EncodedDataInXml = string.Format( + CultureInfo.InvariantCulture, + "<{0} xmlns=\"{1}\">{2}", + WSManNativeApi.PS_CREATION_XML_TAG, + WSManNativeApi.PS_XML_NAMESPACE, + Convert.ToBase64String(additionalData)); _openContent = new WSManNativeApi.WSManData_ManToUn(base64EncodedDataInXml); } } @@ -1392,17 +1402,27 @@ 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.Create(CultureInfo.InvariantCulture, $"{connectionStr.TrimEnd('/')}?PSVersion={PSVersionInfo.PSVersion}{additionalUriSuffixString}"); + connectionStr = string.Format( + CultureInfo.InvariantCulture, + "{0}?PSVersion={1}{2}", // Trimming the last '/' as this will allow WSMan to // properly apply URLPrefix. // Ex: http://localhost?PSVersion=2.0 will be converted // to http://localhost:/?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.Create(CultureInfo.InvariantCulture, $"{connectionStr};PSVersion={PSVersionInfo.PSVersion}{additionalUriSuffixString}"); + connectionStr = string.Format( + CultureInfo.InvariantCulture, + "{0};PSVersion={1}{2}", + connectionStr, + PSVersionInfo.PSVersion, + additionalUriSuffixString); } WSManNativeApi.BaseWSManAuthenticationCredentials authCredentials; diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs index 79e5fb4c2f9..ca27ecaccae 100644 --- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs +++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs @@ -2239,7 +2239,12 @@ public override DynamicMetaObject FallbackBinaryOperation(DynamicMetaObject targ public override string ToString() { - return string.Create(CultureInfo.InvariantCulture, $"PSBinaryOperationBinder {GetOperatorText()}{(_scalarCompare ? " scalarOnly" : string.Empty)} ver:{_version}"); + return string.Format( + CultureInfo.InvariantCulture, + "PSBinaryOperationBinder {0}{1} ver:{2}", + GetOperatorText(), + _scalarCompare ? " scalarOnly" : string.Empty, + _version); } internal static void InvalidateCache() @@ -3790,7 +3795,11 @@ public override DynamicMetaObject FallbackConvert(DynamicMetaObject target, Dyna public override string ToString() { - return string.Create(CultureInfo.InvariantCulture, $"PSConvertBinder [{Microsoft.PowerShell.ToStringCodeMethods.Type(this.Type, true)}] ver:{_version}"); + return string.Format( + CultureInfo.InvariantCulture, + "PSConvertBinder [{0}] ver:{1}", + Microsoft.PowerShell.ToStringCodeMethods.Type(this.Type, true), + _version); } internal static void InvalidateCache() @@ -3959,7 +3968,13 @@ private PSGetIndexBinder(Tuple tu public override string ToString() { - return string.Create(CultureInfo.InvariantCulture, $"PSGetIndexBinder indexCount={this.CallInfo.ArgumentCount}{(_allowSlicing ? string.Empty : " slicing disallowed")}{(_constraints == null ? string.Empty : " constraints: " + _constraints)} ver:{_version}"); + return string.Format( + CultureInfo.InvariantCulture, + "PSGetIndexBinder indexCount={0}{1}{2} ver:{3}", + this.CallInfo.ArgumentCount, + _allowSlicing ? string.Empty : " slicing disallowed", + _constraints == null ? string.Empty : " constraints: " + _constraints, + _version); } internal static void InvalidateCache() @@ -4543,7 +4558,12 @@ private PSSetIndexBinder(Tuple tuple) public override string ToString() { - return string.Create(CultureInfo.InvariantCulture, $"PSSetIndexBinder indexCnt={CallInfo.ArgumentCount}{(_constraints == null ? string.Empty : " constraints: " + _constraints)} ver:{_version}"); + return string.Format( + CultureInfo.InvariantCulture, + "PSSetIndexBinder indexCnt={0}{1} ver:{2}", + CallInfo.ArgumentCount, + _constraints == null ? string.Empty : " constraints: " + _constraints, + _version); } internal static void InvalidateCache() @@ -5138,7 +5158,13 @@ private PSGetMemberBinder(string name, Type classScope, bool ignoreCase, bool @s public override string ToString() { - return string.Create(CultureInfo.InvariantCulture, $"GetMember: {Name}{(_static ? " static" : string.Empty)}{(_nonEnumerating ? " nonEnumerating" : string.Empty)} ver:{_version}"); + return string.Format( + CultureInfo.InvariantCulture, + "GetMember: {0}{1}{2} ver:{3}", + Name, + _static ? " static" : string.Empty, + _nonEnumerating ? " nonEnumerating" : string.Empty, + _version); } public override DynamicMetaObject FallbackGetMember(DynamicMetaObject target, DynamicMetaObject errorSuggestion) @@ -5970,7 +5996,12 @@ public PSSetMemberBinder(string name, bool ignoreCase, bool @static, Type classS public override string ToString() { - return string.Create(CultureInfo.InvariantCulture, $"SetMember: {(_static ? "static " : string.Empty)}{Name} ver:{_getMemberBinder._version}"); + return string.Format( + CultureInfo.InvariantCulture, + "SetMember: {0}{1} ver:{2}", + _static ? "static " : string.Empty, + Name, + _getMemberBinder._version); } private static Expression GetTransformedExpression(IEnumerable transformationAttributes, Expression originalExpression) @@ -6574,7 +6605,15 @@ private PSInvokeMemberBinder(string name, public override string ToString() { - return string.Create(CultureInfo.InvariantCulture, $"PSInvokeMember: {(_static ? "static " : string.Empty)}{(_propertySetter ? "propset " : string.Empty)}{Name} ver:{_getMemberBinder._version} args:{CallInfo.ArgumentCount} constraints:<{(_invocationConstraints != null ? _invocationConstraints.ToString() : string.Empty)}>"); + return string.Format( + CultureInfo.InvariantCulture, + "PSInvokeMember: {0}{1}{2} ver:{3} args:{4} constraints:<{5}>", + _static ? "static " : string.Empty, + _propertySetter ? "propset " : string.Empty, + Name, + _getMemberBinder._version, + CallInfo.ArgumentCount, + _invocationConstraints != null ? _invocationConstraints.ToString() : string.Empty); } public override DynamicMetaObject FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion) @@ -7568,7 +7607,12 @@ internal PSCreateInstanceBinder(CallInfo callInfo, PSMethodInvocationConstraints public override string ToString() { - return string.Create(CultureInfo.InvariantCulture, $"PSCreateInstanceBinder: ver:{_version} args:{_callInfo.ArgumentCount} constraints:<{(_constraints != null ? _constraints : string.Empty)}>"); + return string.Format( + CultureInfo.InvariantCulture, + "PSCreateInstanceBinder: ver:{0} args:{1} constraints:<{2}>", + _version, + _callInfo.ArgumentCount, + _constraints != null ? _constraints.ToString() : string.Empty); } public override DynamicMetaObject FallbackCreateInstance(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion) diff --git a/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs b/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs index a9c402f3e24..907c07e5916 100644 --- a/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs +++ b/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs @@ -1031,7 +1031,13 @@ internal FileRedirection(RedirectionStream from, bool appending, string file) public override string ToString() { - return string.Create(CultureInfo.InvariantCulture, $"{(FromStream == RedirectionStream.All ? "*" : ((int)FromStream).ToString(CultureInfo.InvariantCulture))}> {File}"); + return string.Format( + CultureInfo.InvariantCulture, + "{0}> {1}", + FromStream == RedirectionStream.All + ? "*" + : ((int)FromStream).ToString(CultureInfo.InvariantCulture), + File); } internal string File { get; } diff --git a/src/System.Management.Automation/help/CommandHelpProvider.cs b/src/System.Management.Automation/help/CommandHelpProvider.cs index 12e603e1aa9..0cbb42b821d 100644 --- a/src/System.Management.Automation/help/CommandHelpProvider.cs +++ b/src/System.Management.Automation/help/CommandHelpProvider.cs @@ -950,13 +950,21 @@ 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.Create(CultureInfo.InvariantCulture, $"MamlCommandHelpInfo#{mshSnapInId}#{cmdletName}")); + helpInfo.FullHelp.TypeNames.Insert( + index: 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.Create(CultureInfo.InvariantCulture, $"MamlCommandHelpInfo#{mshSnapInId}")); + helpInfo.FullHelp.TypeNames.Insert( + index: 1, + string.Create( + CultureInfo.InvariantCulture, + $"MamlCommandHelpInfo#{mshSnapInId}")); } AddCache(key, helpInfo); diff --git a/src/System.Management.Automation/help/HelpCommentsParser.cs b/src/System.Management.Automation/help/HelpCommentsParser.cs index 87da494dfcf..36d0cb6450e 100644 --- a/src/System.Management.Automation/help/HelpCommentsParser.cs +++ b/src/System.Management.Automation/help/HelpCommentsParser.cs @@ -361,7 +361,9 @@ internal XmlDocument BuildXmlFromComments() // The title is automatically generated XmlElement title = _doc.CreateElement("maml:title", mamlURI); - string titleStr = string.Create(CultureInfo.InvariantCulture, $"\t\t\t\t-------------------------- {HelpDisplayStrings.ExampleUpperCase} {count++} --------------------------"); + string titleStr = string.Format(CultureInfo.InvariantCulture, + "\t\t\t\t-------------------------- {0} {1} --------------------------", + HelpDisplayStrings.ExampleUpperCase, count++); XmlText title_text = _doc.CreateTextNode(titleStr); example_node.AppendChild(title).AppendChild(title_text); diff --git a/src/System.Management.Automation/help/ProviderHelpProvider.cs b/src/System.Management.Automation/help/ProviderHelpProvider.cs index 65fb3e9dfbd..afc0c71c6c2 100644 --- a/src/System.Management.Automation/help/ProviderHelpProvider.cs +++ b/src/System.Management.Automation/help/ProviderHelpProvider.cs @@ -236,12 +236,20 @@ 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.Create(CultureInfo.InvariantCulture, $"ProviderHelpInfo#{providerInfo.PSSnapInName}#{helpInfo.Name}")); + helpInfo.FullHelp.TypeNames.Insert( + index: 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.Create(CultureInfo.InvariantCulture, $"ProviderHelpInfo#{providerInfo.PSSnapInName}")); + helpInfo.FullHelp.TypeNames.Insert( + index: 1, + string.Create( + CultureInfo.InvariantCulture, + $"ProviderHelpInfo#{providerInfo.PSSnapInName}")); } AddCache(providerInfo.PSSnapInName + "\\" + helpInfo.Name, helpInfo); diff --git a/src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs b/src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs index 687a41588f4..17804d0360e 100644 --- a/src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs +++ b/src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs @@ -939,7 +939,13 @@ internal static PSSnapInInfo ReadCoreEngineSnapIn() "Help.format.ps1xml", "HelpV3.format.ps1xml", "PowerShellCore.format.ps1xml", "PowerShellTrace.format.ps1xml", "Registry.format.ps1xml"}); - string strongName = string.Create(CultureInfo.InvariantCulture, $"{s_coreSnapin.AssemblyName}, Version={assemblyVersion}, Culture={culture}, PublicKeyToken={publicKeyToken}"); + string strongName = string.Format( + CultureInfo.InvariantCulture, + "{0}, Version={1}, Culture={2}, PublicKeyToken={3}", + s_coreSnapin.AssemblyName, + assemblyVersion, + culture, + publicKeyToken); string moduleName = Path.Combine(applicationBase, s_coreSnapin.AssemblyName + ".dll"); diff --git a/src/System.Management.Automation/utils/tracing/SysLogProvider.cs b/src/System.Management.Automation/utils/tracing/SysLogProvider.cs index e1dec75ab16..f3ee184485e 100755 --- a/src/System.Management.Automation/utils/tracing/SysLogProvider.cs +++ b/src/System.Management.Automation/utils/tracing/SysLogProvider.cs @@ -288,7 +288,11 @@ public void LogTransfer(Guid parentActivityId) { // NOTE: always log int threadId = Environment.CurrentManagedThreadId; - string message = string.Create(CultureInfo.InvariantCulture, $"({PSVersionInfo.GitCommitId}:{threadId:X}:{PSChannel.Operational:X}) [Transfer]:{parentActivityId.ToString("B")} {Activity.ToString("B")}"); + string message = string.Format(CultureInfo.InvariantCulture, + "({0}:{1:X}:{2:X}) [Transfer]:{3} {4}", + PSVersionInfo.GitCommitId, threadId, PSChannel.Operational, + parentActivityId.ToString("B"), + Activity.ToString("B")); NativeMethods.SysLog(NativeMethods.SysLogPriority.Info, message); } @@ -303,7 +307,9 @@ public void SetActivity(Guid activity) Activity = activity; // NOTE: always log - string message = string.Create(CultureInfo.InvariantCulture, $"({PSVersionInfo.GitCommitId:X}:{threadId:X}:{PSChannel.Operational:X}) [Activity] {activity.ToString("B")}"); + string message = string.Format(CultureInfo.InvariantCulture, + "({0:X}:{1:X}:{2:X}) [Activity] {3}", + PSVersionInfo.GitCommitId, threadId, PSChannel.Operational, activity.ToString("B")); NativeMethods.SysLog(NativeMethods.SysLogPriority.Info, message); } @@ -327,7 +333,9 @@ public void Log(PSEventId eventId, PSChannel channel, PSTask task, PSOpcode opco sb.Clear(); // add the message preamble - sb.Append(CultureInfo.InvariantCulture, $"({PSVersionInfo.GitCommitId}:{threadId:X}:{channel:X}) [{eventId:G}:{task:G}.{opcode:G}.{level:G}] "); + sb.AppendFormat(CultureInfo.InvariantCulture, + "({0}:{1:X}:{2:X}) [{3:G}:{4:G}.{5:G}.{6:G}] ", + PSVersionInfo.GitCommitId, threadId, channel, eventId, task, opcode, level); // add the message GetEventMessage(sb, eventId, args); diff --git a/test/perf/benchmarks/Engine.Compiler.cs b/test/perf/benchmarks/Engine.Compiler.cs index 5869bc9ef07..10e0054a01c 100644 --- a/test/perf/benchmarks/Engine.Compiler.cs +++ b/test/perf/benchmarks/Engine.Compiler.cs @@ -23,7 +23,7 @@ public class Compiler static Compiler() { - string pattern = string.Create($"{Path.DirectorySeparatorChar}test{Path.DirectorySeparatorChar}perf{Path.DirectorySeparatorChar}benchmarks"); + string pattern = string.Format("{0}test{0}perf{0}benchmarks", Path.DirectorySeparatorChar); string location = typeof(Compiler).Assembly.Location; string testFilePath = null; diff --git a/test/perf/dotnet-tools/BenchmarkDotNet.Extensions/CommandLineOptions.cs b/test/perf/dotnet-tools/BenchmarkDotNet.Extensions/CommandLineOptions.cs index e3c2d2a82a7..aa60c7cc2e6 100644 --- a/test/perf/dotnet-tools/BenchmarkDotNet.Extensions/CommandLineOptions.cs +++ b/test/perf/dotnet-tools/BenchmarkDotNet.Extensions/CommandLineOptions.cs @@ -23,7 +23,7 @@ public static List ParseAndRemoveIntParameter(List argsList, str } else { - throw new ArgumentException(String.Create($"{parameter} must be followed by an integer")); + throw new ArgumentException($"{parameter} must be followed by an integer"); } }