Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use char based StringBuilder.Append where possible #10012

Merged
merged 1 commit into from
Jun 21, 2024
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 @@ -17,17 +17,17 @@ public static string GetBadgeVersion(this NuGetFramework framework)

var builder = new StringBuilder();
builder.Append(framework.Version.Major);
builder.Append(".");
builder.Append('.');
builder.Append(framework.Version.Minor);

if (framework.Version.Build != 0)
{
builder.Append(".");
builder.Append('.');
builder.Append(framework.Version.Build);

if (framework.Version.Revision != 0)
{
builder.Append(".");
builder.Append('.');
builder.Append(framework.Version.Revision);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public static string ToFriendlyName(this NuGetFramework frameworkName, bool allo
sb.Append(String.Join(", ",
profiles.Select(s => NuGetFramework.Parse(s).ToFriendlyName(allowRecurseProfile: false))));

sb.Append(")");
sb.Append(')');
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void Append(
}
else
{
sb.Append(" ");
sb.Append(' ');
}

sb.AppendLine(HttpUtility.HtmlEncode(value.Trim()));
Expand Down
18 changes: 9 additions & 9 deletions src/NuGetGallery/OData/SearchService/SearchAdaptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public static Uri GetNextLink(Uri currentRequestUri, long? totalResultCount, obj
foreach (var queryParameter in queryParametersCollection)
{
queryBuilder.Append(Uri.EscapeDataString(queryParameter.Key));
queryBuilder.Append("=");
queryBuilder.Append('=');
if (queryParameter.Value != null)
{
if (queryParameter.Value is string)
Expand All @@ -381,7 +381,7 @@ public static Uri GetNextLink(Uri currentRequestUri, long? totalResultCount, obj
queryBuilder.Append(queryParameter.Value.ToString().ToLowerInvariant());
}
}
queryBuilder.Append("&");
queryBuilder.Append('&');
}

if (options.SelectExpand != null)
Expand All @@ -390,42 +390,42 @@ public static Uri GetNextLink(Uri currentRequestUri, long? totalResultCount, obj
{
queryBuilder.Append("$select=");
queryBuilder.Append(options.SelectExpand.RawSelect);
queryBuilder.Append("&");
queryBuilder.Append('&');
}
if (!string.IsNullOrEmpty(options.SelectExpand.RawExpand))
{
queryBuilder.Append("$expand=");
queryBuilder.Append(options.SelectExpand.RawExpand);
queryBuilder.Append("&");
queryBuilder.Append('&');
}
}

if (options.Filter != null)
{
queryBuilder.Append("$filter=");
queryBuilder.Append(options.Filter.RawValue);
queryBuilder.Append("&");
queryBuilder.Append('&');
}

if (options.OrderBy != null)
{
queryBuilder.Append("$orderby=");
queryBuilder.Append(options.OrderBy.RawValue);
queryBuilder.Append("&");
queryBuilder.Append('&');
}

if (skipCount > 0)
{
queryBuilder.Append("$skip=");
queryBuilder.Append(skipCount);
queryBuilder.Append("&");
queryBuilder.Append('&');
}

if (options.Top != null)
{
queryBuilder.Append("$top=");
queryBuilder.Append(options.Top.RawValue);
queryBuilder.Append("&");
queryBuilder.Append('&');
}

if (semVerLevelKey != null)
Expand All @@ -434,7 +434,7 @@ public static Uri GetNextLink(Uri currentRequestUri, long? totalResultCount, obj
{
queryBuilder.Append("semVerLevel=");
queryBuilder.Append(SemVerLevelKey.SemVerLevel2);
queryBuilder.Append("&");
queryBuilder.Append('&');
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/NuGetGallery.Core.Facts/TestUtils/TestPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private static string WriteDependencies(IEnumerable<PackageDependencyGroup> pack
{
builder.AppendFormat(" targetFramework=\"{0}\"", packageDependencyGroup.TargetFramework.GetShortFolderName());
}
builder.Append(">");
builder.Append('>');

foreach (var packageDependency in packageDependencyGroup.Packages)
{
Expand All @@ -188,7 +188,7 @@ private static string WriteDependencies(IEnumerable<PackageDependencyGroup> pack
{
builder.AppendFormat(" version=\"{0}\"", packageDependency.VersionRange);
}
builder.Append(">");
builder.Append('>');
builder.Append("</dependency>");
}

Expand Down