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

remove some redundant ToString #10051

Merged
merged 1 commit into from
Jul 9, 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 @@ -279,7 +279,7 @@ private async Task RunUpdate(string stringContentOutput, Uri indexStorageUri, st
{
if (indexEntries[i].Name.Equals(UPDATE_ENTRY_NAME))
{
indexEntries[i].Id = updateUriBuilder.Uri.AbsoluteUri.ToString();
indexEntries[i].Id = updateUriBuilder.Uri.AbsoluteUri;
indexEntries[i].Updated = DateTime.UtcNow;
break;
}
Expand Down Expand Up @@ -320,14 +320,14 @@ private async Task RunRegenerate(string stringContentOutput, Uri indexStorageUri
new IndexEntry
{
Name=BASE_ENTRY_NAME,
Id=baseUriBuilder.Uri.AbsoluteUri.ToString(),
Id=baseUriBuilder.Uri.AbsoluteUri,
Updated=updatedTime,
Comment="The base data for vulnerability update periodically"
},
new IndexEntry
{
Name=UPDATE_ENTRY_NAME,
Id=updateUriBuilder.Uri.AbsoluteUri.ToString(),
Id=updateUriBuilder.Uri.AbsoluteUri,
Updated=updatedTime,
Comment="The patch data for the vulnerability. Contains all the vulnerabilities since base was last updated."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static IDiagnosticsSource SafeGetSource(this IDiagnosticsService self, st
}
catch(Exception ex)
{
System.Diagnostics.Trace.WriteLine("Error getting trace source: " + ex.ToString());
System.Diagnostics.Trace.WriteLine($"Error getting trace source: {ex}");
return NullDiagnosticsSource.Instance;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ private async Task<string> CopyFileAsync(
_trace.TraceEvent(
LogLevel.Information,
eventId: 0,
message: $"Source blob ('{srcBlob.Uri.ToString()}') doesn't have the Sha512 hash.");
message: $"Source blob ('{srcBlob.Uri}') doesn't have the Sha512 hash.");
}
if (!destinationBlobHasSha512Hash)
{
_trace.TraceEvent(
LogLevel.Information,
eventId: 0,
message: $"Destination blob ('{destBlob.Uri.ToString()}') doesn't have the Sha512 hash.");
message: $"Destination blob ('{destBlob.Uri}') doesn't have the Sha512 hash.");
}
if (sourceBlobHasSha512Hash && destinationBlobHasSha512Hash && sourceBlobSha512Hash == destinationBlobSha512Hash && srcBlob.Properties.Length == destBlob.Properties.Length)
{
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery.Services/Storage/ContentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private async Task<IHtmlString> GetContentItemCore(string name, string[] extensi
ContentItem cachedItem = null;
if (ContentCache.TryGetValue(name, out cachedItem) && DateTime.UtcNow < cachedItem.ExpiryUtc)
{
Trace.Verbose("Cache Valid. Expires at: " + cachedItem.ExpiryUtc.ToString());
Trace.Verbose("Cache Valid. Expires at: " + cachedItem.ExpiryUtc);
return cachedItem.Content;
}
Trace.Verbose("Cache Expired.");
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/App_Code/ViewHelpers.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ string dataKey = "___AccordionCounter_" + groupName;
int lastId = (int)(HttpContext.Current.Items[dataKey] ?? 0);
int id = lastId + 1;
HttpContext.Current.Items[dataKey] = id;
string name = groupName + "-" + id.ToString();
string name = groupName + "-" + id;
string actionsId = name + "-actions";

var hlp = new AccordionHelper(name, formModelStatePrefix, expanded, page);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private ListPackageItemViewModel SetupInternal(ListPackageItemViewModel viewMode
viewModel.CanDeprecate = CanPerformAction(currentUser, package, ActionsRequiringPermissions.DeprecatePackage);
viewModel.CanDisplayTfmBadges = _featureFlagService.IsDisplayTfmBadgesEnabled(currentUser);

PackageFrameworkCompatibility packageFrameworkCompatibility = _frameworkCompatibilityFactory.Create(package.SupportedFrameworks, package.Id, package.Version.ToString(), includeComputedBadges);
PackageFrameworkCompatibility packageFrameworkCompatibility = _frameworkCompatibilityFactory.Create(package.SupportedFrameworks, package.Id, package.Version, includeComputedBadges);
viewModel.FrameworkBadges = viewModel.CanDisplayTfmBadges ? packageFrameworkCompatibility?.Badges : new PackageFrameworkCompatibilityBadges();

viewModel.SetShortDescriptionFrom(viewModel.Description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private async Task EnsureDiagnostics()
var resp = await _searchClient.GetDiagnostics();
if (!resp.IsSuccessStatusCode)
{
Trace.Error("HTTP Error when retrieving diagnostics: " + ((int)resp.StatusCode).ToString());
Trace.Error("HTTP Error when retrieving diagnostics: " + ((int)resp.StatusCode));
_diagCache = new JObject();
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/Infrastructure/TracingHttpHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
resp = await base.SendAsync(request, cancellationToken);
}

string message = ((int)resp.StatusCode).ToString() + " " + request.RequestUri.AbsoluteUri;
string message = ((int)resp.StatusCode) + " " + request.RequestUri.AbsoluteUri;
if (resp.IsSuccessStatusCode)
{
Trace.Information(message);
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/Telemetry/CustomerResourceIdEnricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class CustomerResourceIdEnricher : ITelemetryInitializer
private const string CustomerResourceId = "CustomerResourceId";
private const string CustomerResourceIdConstant = "CustomerResourceIdConstant";
private const string Prefix = "/tenants/";
private static readonly string Empty = Prefix + Guid.Empty.ToString();
private static readonly string Empty = Prefix + Guid.Empty;

private static readonly HashSet<string> CustomMetricNames = new HashSet<string>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void DeleteTestBlobs(string connectionString)
foreach (var container in containers)
{
var blobs = container.ListBlobs(
prefix: TestRunId.ToString(),
prefix: TestRunId,
useFlatBlobListing: true);

foreach (var blob in blobs.OfType<CloudBlockBlob>())
Expand Down
2 changes: 1 addition & 1 deletion tests/NuGetGallery.Core.Facts/TestUtils/TestPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private static string WritePackageTypes(IEnumerable<NuGet.Packaging.Core.Package

if (packageType.Version != null)
{
output.AppendFormat(" version=\"{0}\"", packageType.Version.ToString());
output.AppendFormat(" version=\"{0}\"", packageType.Version);
}

output.Append("/>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public TheDisplayPackageMethod()
public async Task IsIndexCheckOnlyHappensForRecentlyChangedPackages(DateTime created, DateTime? lastEdited, int searchTimes)
{
// Arrange
var id = "Test" + Guid.NewGuid().ToString();
var id = "Test" + Guid.NewGuid();
var packageService = new Mock<IPackageService>();
var diagnosticsService = new Mock<IDiagnosticsService>();
var searchClient = new Mock<ISearchClient>();
Expand Down Expand Up @@ -9614,7 +9614,7 @@ public async Task WillRedirectToPackageDetailsPageAfterSuccessfullyCreatingSymbo

public class TheUploadProgressAction : TestContainer
{
private static readonly string FakeUploadName = "upload-" + TestUtility.FakeUserName + Guid.Empty.ToString();
private static readonly string FakeUploadName = "upload-" + TestUtility.FakeUserName + Guid.Empty;

[Fact]
public void WillReturnHttpNotFoundForUnknownUser()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void NormalizesNavigationLinksWhenSet(string requestUri)
// Assert
Assert.Equal(expectedNormalizedLink, oDataEntry.ReadLink.ToString());
Assert.Equal(expectedNormalizedLink, oDataEntry.EditLink.ToString());
Assert.Equal(expectedNormalizedLink, oDataEntry.Id.ToString());
Assert.Equal(expectedNormalizedLink, oDataEntry.Id);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ public async Task CleansUpLicenseIfDbUpdateFails(PackageStatus packageStatus, bo
await Assert.ThrowsAsync<Exception>(() => _target.CommitPackageAsync(_package, _packageFile));

_licenseFileService.Verify(
lfs => lfs.DeleteLicenseFileAsync(_package.Id, _package.NormalizedVersion.ToString()),
lfs => lfs.DeleteLicenseFileAsync(_package.Id, _package.NormalizedVersion),
expectedLicenseDelete ? Times.Once() : Times.Never());
}

Expand Down Expand Up @@ -720,11 +720,11 @@ public async Task CleansUpReadmeIfDbUpdateFails(PackageStatus packageStatus, boo
await Assert.ThrowsAsync<Exception>(() => _target.CommitPackageAsync(_package, _packageFile));

_licenseFileService.Verify(
lfs => lfs.DeleteLicenseFileAsync(_package.Id, _package.NormalizedVersion.ToString()),
lfs => lfs.DeleteLicenseFileAsync(_package.Id, _package.NormalizedVersion),
expectedFileDelete ? Times.Once() : Times.Never());

_readmeFileService.Verify(
lfs => lfs.DeleteReadmeFileAsync(_package.Id, _package.NormalizedVersion.ToString()),
lfs => lfs.DeleteReadmeFileAsync(_package.Id, _package.NormalizedVersion),
expectedFileDelete ? Times.Once() : Times.Never());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private List<string> GetPIIOperationsFromRoute()
var piiRoutes = _currentRoutes.Where((r) =>
{
Route webRoute = r as Route;
return webRoute != null ? IsPIIUrl(webRoute.Url.ToString()) : false;
return webRoute != null ? IsPIIUrl(webRoute.Url) : false;
}).Select((r) =>
{
var dd = ((Route)r).Defaults;
Expand All @@ -255,7 +255,7 @@ private List<string> GetPIIRoutesUrls()
var piiRoutes = _currentRoutes.Where((r) =>
{
Route webRoute = r as Route;
return webRoute != null ? IsPIIUrl(webRoute.Url.ToString()) : false;
return webRoute != null ? IsPIIUrl(webRoute.Url) : false;
}).Select((r) => ((Route)r).Url).Distinct().ToList();

return piiRoutes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void HasACaseForAllIssueTypes(ValidationIssue issue)
var template = GetTemplate();

// Assert
Assert.Contains("case ValidationIssueCode." + issue.IssueCode.ToString(), template);
Assert.Contains("case ValidationIssueCode." + issue.IssueCode, template);
}

[Theory]
Expand Down