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 @@ -2589,15 +2589,12 @@ private string GenerateConnectionStringForNewRunspace()
CodeGeneration.EscapeSingleQuotedStringContent(connectionInfo.AppName),
connectionInfo.UseDefaultWSManPort ?
string.Empty :
string.Format(CultureInfo.InvariantCulture,
"-Port {0} ", connectionInfo.Port),
string.Create(CultureInfo.InvariantCulture, $"-Port {connectionInfo.Port} "),
isSSLSpecified ? "-useSSL" : string.Empty);
}
else
{
return string.Format(CultureInfo.InvariantCulture,
"-connectionUri '{0}'",
CodeGeneration.EscapeSingleQuotedStringContent(GetConnectionString()));
return string.Create(CultureInfo.InvariantCulture, $"-connectionUri '{CodeGeneration.EscapeSingleQuotedStringContent(GetConnectionString())}'");
}
}

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

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

m_SessionObj.Put(helper.Service_CredSSP_Uri, inputXml, 0);
}
Expand Down Expand Up @@ -513,6 +511,7 @@ private void EnableClientSideSettings()
try
{
XmlDocument xmldoc = new XmlDocument();

// push the xml string with credssp enabled
xmldoc.LoadXml(m_SessionObj.Put(helper.CredSSP_RUri, newxmlcontent, 0));

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

// push the xml string with credssp enabled
xmldoc.LoadXml(m_SessionObj.Put(helper.Service_CredSSP_Uri, newxmlcontent, 0));
WriteObject(xmldoc.FirstChild);
Expand Down
14 changes: 2 additions & 12 deletions src/System.Management.Automation/DscSupport/CimDSCParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2534,12 +2534,7 @@ private static void ProcessMembers(StringBuilder sb, List<object> embeddedInstan

string arrayAffix = isArrayType ? "[]" : string.Empty;

sb.AppendFormat(CultureInfo.InvariantCulture,
" {0}{1} {2}{3};\n",
MapAttributesToMof(enumNames, attributes, embeddedInstanceType),
mofType,
member.Name,
arrayAffix);
sb.Append(CultureInfo.InvariantCulture, $" {MapAttributesToMof(enumNames, attributes, embeddedInstanceType)}{mofType} {member.Name}{arrayAffix};\n");
}
}

Expand Down Expand Up @@ -3096,12 +3091,7 @@ private static void ProcessMembers(Type type, StringBuilder sb, List<object> emb
var enumNames = memberType.IsEnum
? Enum.GetNames(memberType)
: null;
sb.AppendFormat(CultureInfo.InvariantCulture,
" {0}{1} {2}{3};\n",
MapAttributesToMof(enumNames, member.GetCustomAttributes(true), embeddedInstanceType),
mofType,
member.Name,
arrayAffix);
sb.Append(CultureInfo.InvariantCulture, $" {MapAttributesToMof(enumNames, member.GetCustomAttributes(true), embeddedInstanceType)}{mofType} {member.Name}{arrayAffix};\n");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,7 @@ private void LoadData(ExtendedTypeDefinition typeDefinition, TypeInfoDataBase db
ViewDefinition view = LoadViewFromObjectModel(typeDefinition.TypeNames, formatView, viewIndex++);
if (view != null)
{
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));
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}"));

// 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,10 +27,7 @@ private void LoadViewDefinitions(TypeInfoDataBase db, XmlNode viewDefinitionsNod
ViewDefinition view = LoadView(n, index++);
if (view != null)
{
ReportTrace(string.Format(CultureInfo.InvariantCulture,
"{0} view {1} is loaded from file {2}",
ControlBase.GetControlShapeName(view.mainControl),
view.name, view.loadingInfo.filePath));
ReportTrace(string.Create(CultureInfo.InvariantCulture, $"{ControlBase.GetControlShapeName(view.mainControl)} view {view.name} is loaded from file {view.loadingInfo.filePath}"));
// 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 @@ -238,16 +238,11 @@ private static void AddTypeNameHierarchy(IList<string> typeNamesWithNamespace, I
{
if (!string.IsNullOrEmpty(namespaceName))
{
string fullTypeName = string.Format(CultureInfo.InvariantCulture,
"Microsoft.Management.Infrastructure.CimInstance#{0}/{1}",
namespaceName,
className);
string fullTypeName = string.Create(CultureInfo.InvariantCulture, $"Microsoft.Management.Infrastructure.CimInstance#{namespaceName}/{className}");
typeNamesWithNamespace.Add(fullTypeName);
}

typeNamesWithoutNamespace.Add(string.Format(CultureInfo.InvariantCulture,
"Microsoft.Management.Infrastructure.CimInstance#{0}",
className));
typeNamesWithoutNamespace.Add(string.Create(CultureInfo.InvariantCulture, $"Microsoft.Management.Infrastructure.CimInstance#{className}"));
}

private static List<CimClass> GetInheritanceChain(CimInstance cimInstance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1161,9 +1161,7 @@ protected override PSProperty DoGetProperty(ManagementBaseObject wmiObject, stri
PSLevel.Informational,
PSTask.None,
PSKeyword.UseAlwaysOperational,
string.Format(CultureInfo.InvariantCulture,
"ManagementBaseObjectAdapter::DoGetProperty::PropertyName:{0}, Exception:{1}, StackTrace:{2}",
propertyName, e.Message, e.StackTrace),
string.Create(CultureInfo.InvariantCulture, $"ManagementBaseObjectAdapter::DoGetProperty::PropertyName:{propertyName}, Exception:{e.Message}, StackTrace:{e.StackTrace}"),
string.Empty,
string.Empty);
// ignore the exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,7 @@ protected override Expression VisitParameter(ParameterExpression node) {

protected override Expression VisitLambda<T>(Expression<T> node) {
Out(
string.Format(CultureInfo.CurrentCulture,
"{0} {1}<{2}>",
".Lambda",
GetLambdaName(node),
node.Type.ToString()
)
string.Create(CultureInfo.CurrentCulture, $".Lambda {GetLambdaName(node)}<{node.Type}>")
);

if (_lambdas == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,7 @@ protected override void ProcessRecord()
string restartServiceTarget = StringUtil.Format(RemotingErrorIdStrings.RestartWSManServiceTarget, "WinRM");

string restartWSManRequiredForUI = StringUtil.Format(RemotingErrorIdStrings.RestartWSManRequiredShowUI,
string.Format(CultureInfo.InvariantCulture,
"Set-PSSessionConfiguration {0} -ShowSecurityDescriptorUI",
shellName));
string.Create(CultureInfo.InvariantCulture, $"Set-PSSessionConfiguration {shellName} -ShowSecurityDescriptorUI"));

// gather -WhatIf, -Confirm parameter data and pass it to the script block
bool whatIf = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,7 @@ static OutOfProcessUtils()

internal static string CreateDataPacket(byte[] data, DataPriorityType streamType, Guid psGuid)
{
string result = string.Format(CultureInfo.InvariantCulture,
"<{0} {1}='{2}' {3}='{4}'>{5}</{0}>",
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));
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)}</{PS_OUT_OF_PROC_DATA_TAG}>");

return result;
}
Expand Down Expand Up @@ -131,11 +124,7 @@ internal static string CreateSignalAckPacket(Guid psGuid)
/// <returns></returns>
private static string CreatePSGuidPacket(string element, Guid psGuid)
{
string result = string.Format(CultureInfo.InvariantCulture,
"<{0} {1}='{2}' />",
element,
PS_OUT_OF_PROC_PSGUID_ATTRIBUTE,
psGuid.ToString());
string result = string.Create(CultureInfo.InvariantCulture, $"<{element} {PS_OUT_OF_PROC_PSGUID_ATTRIBUTE}='{psGuid}' />");

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,7 @@ internal override void ExecuteConnect(
_remoteSession.ExecuteConnect(inputData, out outputData);

// construct Xml to send back
string responseData = string.Format(System.Globalization.CultureInfo.InvariantCulture,
"<{0} xmlns=\"{1}\">{2}</{0}>",
WSManNativeApi.PS_CONNECTRESPONSE_XML_TAG,
WSManNativeApi.PS_XML_NAMESPACE,
Convert.ToBase64String(outputData));
string responseData = string.Create(System.Globalization.CultureInfo.InvariantCulture, $"<{WSManNativeApi.PS_CONNECTRESPONSE_XML_TAG} xmlns=\"{WSManNativeApi.PS_XML_NAMESPACE}\">{Convert.ToBase64String(outputData)}</{WSManNativeApi.PS_CONNECTRESPONSE_XML_TAG}>");

// TODO: currently using OperationComplete to report back the responseXml. This will need to change to use WSManReportObject
// that is currently internal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,7 @@ internal XmlDocument BuildXmlFromComments()

// The title is automatically generated
XmlElement title = _doc.CreateElement("maml:title", mamlURI);
string titleStr = string.Format(CultureInfo.InvariantCulture,
"\t\t\t\t-------------------------- {0} {1} --------------------------",
HelpDisplayStrings.ExampleUpperCase, count++);
string titleStr = string.Create(CultureInfo.InvariantCulture, $"\t\t\t\t-------------------------- {HelpDisplayStrings.ExampleUpperCase} {count++} --------------------------");
XmlText title_text = _doc.CreateTextNode(titleStr);
example_node.AppendChild(title).AppendChild(title_text);

Expand Down
14 changes: 3 additions & 11 deletions src/System.Management.Automation/utils/tracing/SysLogProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,7 @@ public void LogTransfer(Guid parentActivityId)
{
// NOTE: always log
int threadId = Environment.CurrentManagedThreadId;
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"));
string message = string.Create(CultureInfo.InvariantCulture, $"({PSVersionInfo.GitCommitId}:{threadId:X}:{PSChannel.Operational:X}) [Transfer]:{parentActivityId.ToString("B")} {Activity.ToString("B")}");

NativeMethods.SysLog(NativeMethods.SysLogPriority.Info, message);
}
Expand All @@ -307,9 +303,7 @@ public void SetActivity(Guid activity)
Activity = activity;

// NOTE: always log
string message = string.Format(CultureInfo.InvariantCulture,
"({0:X}:{1:X}:{2:X}) [Activity] {3}",
PSVersionInfo.GitCommitId, threadId, PSChannel.Operational, activity.ToString("B"));
string message = string.Create(CultureInfo.InvariantCulture, $"({PSVersionInfo.GitCommitId:X}:{threadId:X}:{PSChannel.Operational:X}) [Activity] {activity.ToString("B")}");
NativeMethods.SysLog(NativeMethods.SysLogPriority.Info, message);
}

Expand All @@ -333,9 +327,7 @@ public void Log(PSEventId eventId, PSChannel channel, PSTask task, PSOpcode opco
sb.Clear();

// add the message preamble
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);
sb.Append(CultureInfo.InvariantCulture, $"({PSVersionInfo.GitCommitId}:{threadId:X}:{channel:X}) [{eventId:G}:{task:G}.{opcode:G}.{level:G}] ");

// add the message
GetEventMessage(sb, eventId, args);
Expand Down
4 changes: 1 addition & 3 deletions src/TypeCatalogGen/TypeCatalogGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ private static string GetAssemblyStrongName(MetadataReader metadataReader)

// Convert bytes to hex format strings in lower case.
string publicKeyTokenString = BitConverter.ToString(publicKeyTokenBytes).Replace("-", string.Empty).ToLowerInvariant();
string strongAssemblyName = string.Format(CultureInfo.InvariantCulture,
"{0}, Version={1}, Culture={2}, PublicKeyToken={3}",
asmName, asmVersion, asmCulture, publicKeyTokenString);
string strongAssemblyName = string.Create(CultureInfo.InvariantCulture, $"{asmName}, Version={asmVersion}, Culture={asmCulture}, PublicKeyToken={publicKeyTokenString}");

return strongAssemblyName;
}
Expand Down