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
2 changes: 1 addition & 1 deletion .globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ dotnet_diagnostic.CA1832.severity = suggestion
dotnet_diagnostic.CA1833.severity = suggestion

# CA1834: Consider using 'StringBuilder.Append(char)' when applicable
dotnet_diagnostic.CA1834.severity = suggestion
dotnet_diagnostic.CA1834.severity = warning

# CA1835: Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync'
dotnet_diagnostic.CA1835.severity = suggestion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ internal void ThrowInvalidProperty(
{
if (propList.Length > 0)
{
propList.Append(",");
propList.Append(',');
}

propList.Append(property);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,15 @@ protected static string CreateQuery(CimBaseCommand cmdlet)
StringBuilder propertyList = new StringBuilder();
if (cmd.SelectProperties == null)
{
propertyList.Append("*");
propertyList.Append('*');
}
else
{
foreach (string property in cmd.SelectProperties)
{
if (propertyList.Length > 0)
{
propertyList.Append(",");
propertyList.Append(',');
}

propertyList.Append(property);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ internal void WriteOperationStartMessage(string operation, Hashtable parameterLi
{
if (parameters.Length > 0)
{
parameters.Append(",");
parameters.Append(',');
}

parameters.Append(string.Format(CultureInfo.CurrentUICulture, @"'{0}' = {1}", key, parameterList[key]));
Expand Down
36 changes: 18 additions & 18 deletions src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ public SwitchParameter Oldest
private const string SelectCloser = "</Select>";
private const string suppressOpener = "<Suppress>*";
private const string suppressCloser = "</Suppress>";
private const string propOpen = "[";
private const string propClose = "]";
private const char propOpen = '[';
private const char propClose = ']';
private const string filePrefix = "file://";
private const string NamedDataTemplate = "((EventData[Data[@Name='{0}']='{1}']) or (UserData/*/{0}='{1}'))";
private const string DataTemplate = "(EventData/Data='{0}')";
Expand Down Expand Up @@ -1353,21 +1353,21 @@ private string HandleEventIdHashValue(object value)
Array idsArray = value as Array;
if (idsArray != null)
{
ret.Append("(");
ret.Append('(');
for (int i = 0; i < idsArray.Length; i++)
{
ret.Append(SystemEventIDTemplate).Append(idsArray.GetValue(i).ToString()).Append(")");
ret.Append(SystemEventIDTemplate).Append(idsArray.GetValue(i).ToString()).Append(')');
if (i < (idsArray.Length - 1))
{
ret.Append(" or ");
}
}

ret.Append(")");
ret.Append(')');
}
else
{
ret.Append(SystemEventIDTemplate).Append(value).Append(")");
ret.Append(SystemEventIDTemplate).Append(value).Append(')');
}

return ret.ToString();
Expand All @@ -1383,21 +1383,21 @@ private string HandleLevelHashValue(object value)
Array levelsArray = value as Array;
if (levelsArray != null)
{
ret.Append("(");
ret.Append('(');
for (int i = 0; i < levelsArray.Length; i++)
{
ret.Append(SystemLevelTemplate).Append(levelsArray.GetValue(i).ToString()).Append(")");
ret.Append(SystemLevelTemplate).Append(levelsArray.GetValue(i).ToString()).Append(')');
if (i < (levelsArray.Length - 1))
{
ret.Append(" or ");
}
}

ret.Append(")");
ret.Append(')');
}
else
{
ret.Append(SystemLevelTemplate).Append(value).Append(")");
ret.Append(SystemLevelTemplate).Append(value).Append(')');
}

return ret.ToString();
Expand Down Expand Up @@ -1571,7 +1571,7 @@ private string HandleDataHashValue(object value)
Array dataArray = value as Array;
if (dataArray != null)
{
ret.Append("(");
ret.Append('(');
for (int i = 0; i < dataArray.Length; i++)
{
ret.AppendFormat(CultureInfo.InvariantCulture, DataTemplate, dataArray.GetValue(i).ToString());
Expand All @@ -1581,7 +1581,7 @@ private string HandleDataHashValue(object value)
}
}

ret.Append(")");
ret.Append(')');
}
else
{
Expand All @@ -1602,7 +1602,7 @@ private string HandleNamedDataHashValue(string key, object value)
Array dataArray = value as Array;
if (dataArray != null)
{
ret.Append("(");
ret.Append('(');
for (int i = 0; i < dataArray.Length; i++)
{
ret.AppendFormat(CultureInfo.InvariantCulture,
Expand All @@ -1614,7 +1614,7 @@ private string HandleNamedDataHashValue(string key, object value)
}
}

ret.Append(")");
ret.Append(')');
}
else
{
Expand Down Expand Up @@ -1920,14 +1920,14 @@ private string BuildProvidersPredicate(StringCollection providers)
StringBuilder predicate = new StringBuilder("System/Provider[");
for (int i = 0; i < providers.Count; i++)
{
predicate.Append("@Name='").Append(providers[i]).Append("'");
predicate.Append("@Name='").Append(providers[i]).Append('\'');
if (i < (providers.Count - 1))
{
predicate.Append(" or ");
}
}

predicate.Append("]");
predicate.Append(']');

return predicate.ToString();
}
Expand Down Expand Up @@ -1964,14 +1964,14 @@ private string BuildAllProvidersPredicate()

for (int i = 0; i < uniqueProviderNames.Count; i++)
{
predicate.Append("@Name='").Append(uniqueProviderNames[i]).Append("'");
predicate.Append("@Name='").Append(uniqueProviderNames[i]).Append('\'');
if (i < uniqueProviderNames.Count - 1)
{
predicate.Append(" or ");
}
}

predicate.Append("]");
predicate.Append(']');

return predicate.ToString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal QueryInstancesJob(CimJobContext jobContext, CimQuery cimQuery, string w
var wqlQueryBuilder = new StringBuilder();
wqlQueryBuilder.Append("SELECT * FROM ");
wqlQueryBuilder.Append(this.JobContext.ClassName);
wqlQueryBuilder.Append(" ");
wqlQueryBuilder.Append(' ');
wqlQueryBuilder.Append(wqlCondition);
_wqlQuery = wqlQueryBuilder.ToString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ protected override void ProcessRecord()
{
queryString.Append("HotFixID= '");
queryString.Append(Id[i].Replace("'", "\\'"));
queryString.Append("'");
queryString.Append('\'');
if (i < Id.Length - 1)
{
queryString.Append(" Or ");
}
}

queryString.Append(")");
queryString.Append(')');
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,15 +561,15 @@ private void WriteColumns(List<MshParameter> mshParams)
{
COLTag.Append(" width = \"");
COLTag.Append(width);
COLTag.Append("\"");
COLTag.Append('"');
}

string alignment = p.GetEntry(ConvertHTMLParameterDefinitionKeys.AlignmentEntryKey) as string;
if (alignment != null)
{
COLTag.Append(" align = \"");
COLTag.Append(alignment);
COLTag.Append("\"");
COLTag.Append('"');
}

COLTag.Append("/>");
Expand All @@ -593,7 +593,7 @@ private void WriteListEntry()

// for writing the property name
WritePropertyName(Listtag, p);
Listtag.Append(":");
Listtag.Append(':');
Listtag.Append("</td>");

// for writing the property value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ private string UFormatDateString(DateTime dateTime)
break;

case 'n':
sb.Append("\n");
sb.Append('\n');
break;

case 'p':
Expand Down Expand Up @@ -508,7 +508,7 @@ private string UFormatDateString(DateTime dateTime)
break;

case 't':
sb.Append("\t");
sb.Append('\t');
break;

case 'U':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private static string BuildName(List<ObjectCommandPropertyValue> propValues)
{
if (propValuePropertyValue is ICollection propertyValueItems)
{
sb.Append("{");
sb.Append('{');
var length = sb.Length;

foreach (object item in propertyValueItems)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2316,7 +2316,7 @@ private string GenerateNewPSSessionOption()
result.Append("-ApplicationArguments $(");
result.Append("& $script:ImportCliXml -Path $(");
result.Append("& $script:JoinPath -Path $PSScriptRoot -ChildPath ApplicationArguments.xml");
result.Append(")");
result.Append(')');
result.Append(") ");
}

Expand Down Expand Up @@ -2953,7 +2953,7 @@ private string GenerateArrayString(IEnumerable<string> listOfStrings)
}

arrayString.Insert(0, "@(");
arrayString.Append(")");
arrayString.Append(')');

return arrayString.ToString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ private string FormatDictionary(IDictionary content)
{
if (0 < bodyBuilder.Length)
{
bodyBuilder.Append("&");
bodyBuilder.Append('&');
}

object value = content[key];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2523,7 +2523,7 @@ internal void Run(bool inputLoopIsNested)
if (inBlockMode)
{
s_tracer.WriteLine("adding line to block");
inputBlock.Append("\n");
inputBlock.Append('\n');
inputBlock.Append(line);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public override

StringBuilder fieldPromptList = new StringBuilder(fieldPrompt);
// fieldPromptList = fieldPrompt + "[i] :"
fieldPromptList.Append("[");
fieldPromptList.Append('[');

while (true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public override void Fail(string message, string detailMessage)
StringBuilder failMessage = new StringBuilder(message);
if (detailMessage != null)
{
failMessage.Append(" ");
failMessage.Append(' ');
failMessage.Append(detailMessage);
}

Expand Down
20 changes: 10 additions & 10 deletions src/Microsoft.WSMan.Management/ConfigProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2328,7 +2328,7 @@ private PSObject GetItemPSObjectWithTypeName(string Name, string TypeNameOfEleme
if (mshObject != null)
{
types.Append(mshObject.ImmediateBaseObject.GetType().FullName);
types.Append("#");
types.Append('#');
types.Append(ExtendedTypeName);
mshObject.TypeNames.Insert(0, types.ToString());
}
Expand Down Expand Up @@ -2426,16 +2426,16 @@ private string GetInputStringForCreate(string ResourceURI, Hashtable value, stri
sbvalues.Append(key);
if (value[key] == null)
{
sbvalues.Append(" ");
sbvalues.Append(' ');
sbvalues.Append(WSManStringLiterals.ATTR_NIL);
nilns = " " + WSManStringLiterals.NS_XSI;
}

sbvalues.Append(">");
sbvalues.Append('>');
sbvalues.Append(EscapeValuesForXML(((Hashtable)value)[key].ToString()));
sbvalues.Append("</p:");
sbvalues.Append(key);
sbvalues.Append(">");
sbvalues.Append('>');
}
}
}
Expand Down Expand Up @@ -2942,17 +2942,17 @@ private string GetURIWithFilter(string uri, Hashtable cmdlinevalues)
{
if (uri.Contains("Config/Listener"))
{
sburi.Append("?");
sburi.Append('?');
sburi.Append(GetFilterString(cmdlinevalues, PKeyListener));
}
else if (uri.Contains("Config/Service/certmapping"))
{
sburi.Append("?");
sburi.Append('?');
sburi.Append(GetFilterString(cmdlinevalues, PKeyCertMapping));
}
else if (uri.Contains("Config/Plugin"))
{
sburi.Append("?");
sburi.Append('?');
sburi.Append(GetFilterString(cmdlinevalues, PKeyPlugin));
}
}
Expand All @@ -2968,9 +2968,9 @@ private string GetFilterString(Hashtable cmdlinevalues, string[] pkey)
if (cmdlinevalues.Contains(key))
{
filter.Append(key);
filter.Append("=");
filter.Append('=');
filter.Append(cmdlinevalues[key].ToString());
filter.Append("+");
filter.Append('+');
}
}

Expand Down Expand Up @@ -3102,7 +3102,7 @@ private void WritePSObjectPropertiesAsWSManElementObjects(PSObject psobject, str
if (mshObject != null)
{
types.Append(mshObject.ImmediateBaseObject.GetType().FullName);
types.Append("#");
types.Append('#');
types.Append(ExtendedTypeName);
mshObject.TypeNames.Insert(0, types.ToString());
}
Expand Down
Loading