From 64d82f812d8bc3ce0ef4a435e56cfab73ff8cf33 Mon Sep 17 00:00:00 2001 From: CarloToso <105941898+CarloToso@users.noreply.github.com> Date: Fri, 20 Jan 2023 11:26:43 +0100 Subject: [PATCH] Use interpolated strings 9 (#18993) --- .../ScheduledJobStore.cs | 2 +- .../DscSupport/CimDSCParser.cs | 24 +++++++++---------- .../common/DisplayDatabase/typeDataQuery.cs | 4 ++-- .../cimSupport/cmdletization/ScriptWriter.cs | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.PowerShell.ScheduledJob/ScheduledJobStore.cs b/src/Microsoft.PowerShell.ScheduledJob/ScheduledJobStore.cs index 063176feae..e6bcd1c3b8 100644 --- a/src/Microsoft.PowerShell.ScheduledJob/ScheduledJobStore.cs +++ b/src/Microsoft.PowerShell.ScheduledJob/ScheduledJobStore.cs @@ -524,7 +524,7 @@ namespace Microsoft.PowerShell.ScheduledJob DateTime runStart) { string directoryPath = GetJobRunOutputDirectory(definitionName); - return string.reate(CultureInfo.InvariantCulture, $@"{directoryPath}\{ConvertDateTimeToJobRunName(runStart)}"); + return string.Create(CultureInfo.InvariantCulture, $@"{directoryPath}\{ConvertDateTimeToJobRunName(runStart)}"); } /// diff --git a/src/System.Management.Automation/DscSupport/CimDSCParser.cs b/src/System.Management.Automation/DscSupport/CimDSCParser.cs index 1347ac2c55..904103f451 100644 --- a/src/System.Management.Automation/DscSupport/CimDSCParser.cs +++ b/src/System.Management.Automation/DscSupport/CimDSCParser.cs @@ -2339,7 +2339,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal private static void GenerateMofForAst(TypeDefinitionAst typeAst, StringBuilder sb, List embeddedInstanceTypes) { var className = typeAst.Name; - sb.AppendFormat(CultureInfo.InvariantCulture, $"[ClassVersion(\"1.0.0\"), FriendlyName(\"{className}\")]\nclass {className}"); + sb.Append(CultureInfo.InvariantCulture, $"[ClassVersion(\"1.0.0\"), FriendlyName(\"{className}\")]\nclass {className}"); if (typeAst.Attributes.Any(static a => a.TypeName.GetReflectionAttributeType() == typeof(DscResourceAttribute))) { @@ -2912,19 +2912,19 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal { if (dscProperty.Key) { - sb.AppendFormat(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}key"); + sb.Append(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}key"); needComma = true; } if (dscProperty.Mandatory) { - sb.AppendFormat(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}required"); + sb.Append(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}required"); needComma = true; } if (dscProperty.NotConfigurable) { - sb.AppendFormat(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}read"); + sb.Append(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}read"); needComma = true; } @@ -2936,13 +2936,13 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal { bool valueMapComma = false; StringBuilder sbValues = new(", Values{"); - sb.AppendFormat(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}ValueMap{{"); + sb.Append(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}ValueMap{{"); needComma = true; foreach (var value in validateSet.ValidValues) { - sb.AppendFormat(CultureInfo.InvariantCulture, $"{(valueMapComma ? ", " : string.Empty)}\"{value}\""); - sbValues.AppendFormat(CultureInfo.InvariantCulture, $"{(valueMapComma ? ", " : string.Empty)}\"{value}\""); + sb.Append(CultureInfo.InvariantCulture, $"{(valueMapComma ? ", " : string.Empty)}\"{value}\""); + sbValues.Append(CultureInfo.InvariantCulture, $"{(valueMapComma ? ", " : string.Empty)}\"{value}\""); valueMapComma = true; } @@ -2961,11 +2961,11 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal if (enumNames != null) { - sb.AppendFormat(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}ValueMap{{"); + sb.Append(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}ValueMap{{"); needComma = false; foreach (var name in enumNames) { - sb.AppendFormat(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}\"{name}\""); + sb.Append(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}\"{name}\""); needComma = true; } @@ -2973,7 +2973,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal needComma = false; foreach (var name in enumNames) { - sb.AppendFormat(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}\"{name}\""); + sb.Append(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}\"{name}\""); needComma = true; } @@ -2981,7 +2981,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal } else if (embeddedInstanceType != null) { - sb.AppendFormat(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}EmbeddedInstance(\"{embeddedInstanceType}\")"); + sb.Append(CultureInfo.InvariantCulture, $"{(needComma ? ", " : string.Empty)}EmbeddedInstance(\"{embeddedInstanceType}\")"); } sb.Append(']'); @@ -3047,7 +3047,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal { var className = type.Name; // Friendly name is required by module validator to verify resource instance against the exclusive resource name list. - sb.AppendFormat(CultureInfo.InvariantCulture, $"[ClassVersion(\"1.0.0\"), FriendlyName(\"{className}\")]\nclass {className}"); + sb.Append(CultureInfo.InvariantCulture, $"[ClassVersion(\"1.0.0\"), FriendlyName(\"{className}\")]\nclass {className}"); if (type.GetCustomAttributes().Any()) { diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs index 0352db182f..2ae6a181f8 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs @@ -490,12 +490,12 @@ namespace Microsoft.PowerShell.Commands.Internal.Format sb.Append(isMatched ? "MATCH FOUND" : "NOT MATCH"); if (tr != null) { - sb.AppendFormat(CultureInfo.InvariantCulture, $" {ControlBase.GetControlShapeName(vd.mainControl)} NAME: {vd.name} TYPE: {tr.name}"); + sb.Append(CultureInfo.InvariantCulture, $" {ControlBase.GetControlShapeName(vd.mainControl)} NAME: {vd.name} TYPE: {tr.name}"); } else { TypeGroupReference tgr = togr as TypeGroupReference; - sb.AppendFormat(CultureInfo.InvariantCulture, $" {ControlBase.GetControlShapeName(vd.mainControl)} NAME: {vd.name} GROUP: {tgr.name}"); + sb.Append(CultureInfo.InvariantCulture, $" {ControlBase.GetControlShapeName(vd.mainControl)} NAME: {vd.name} GROUP: {tgr.name}"); } ActiveTracer.WriteLine(sb.ToString()); diff --git a/src/System.Management.Automation/cimSupport/cmdletization/ScriptWriter.cs b/src/System.Management.Automation/cimSupport/cmdletization/ScriptWriter.cs index fb5e2d6656..a0e0969470 100644 --- a/src/System.Management.Automation/cimSupport/cmdletization/ScriptWriter.cs +++ b/src/System.Management.Automation/cimSupport/cmdletization/ScriptWriter.cs @@ -249,7 +249,7 @@ function __cmdletization_BindCommonParameters ? ("'" + CodeGeneration.EscapeSingleQuotedStringContent(cmdletMetadata.Obsolete.Message) + "'") : string.Empty; string newline = (attributes.Length > 0) ? Environment.NewLine : string.Empty; - attributes.AppendFormat(CultureInfo.InvariantCulture, $"{newline}[Obsolete({obsoleteMsg})]"); + attributes.Append(CultureInfo.InvariantCulture, $"{newline}[Obsolete({obsoleteMsg})]"); } return attributes.ToString();