Skip to content

Commit

Permalink
IDE0049 "Name can be simplified" cleanup (#35680)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiYanni authored Sep 27, 2023
2 parents 44f0fd5 + 13f25fc commit 0aa624d
Show file tree
Hide file tree
Showing 60 changed files with 171 additions and 171 deletions.
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/Internal/ProcessRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public ProcessState(Process process, IReporter reporter)
// events.
//
// See the remarks here: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.waitforexit#System_Diagnostics_Process_WaitForExit_System_Int32_
if (!_process.WaitForExit(Int32.MaxValue))
if (!_process.WaitForExit(int.MaxValue))
{
throw new TimeoutException();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/Microsoft.DotNet.Cli.Sln.Internal/SlnFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ private SlnSectionType ToSectionType(int curLineNum, string s)
}
throw new InvalidSolutionFormatException(
curLineNum,
String.Format(LocalizableStrings.InvalidSectionTypeError, s));
string.Format(LocalizableStrings.InvalidSectionTypeError, s));
}

private string FromSectionType(bool isProjectSection, SlnSectionType type)
Expand Down
24 changes: 12 additions & 12 deletions src/Cli/Microsoft.DotNet.Cli.Utils/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ internal enum JobObjectLimitFlags : uint
[StructLayout(LayoutKind.Sequential)]
internal struct JobObjectBasicLimitInformation
{
public Int64 PerProcessUserTimeLimit;
public Int64 PerJobUserTimeLimit;
public long PerProcessUserTimeLimit;
public long PerJobUserTimeLimit;
public JobObjectLimitFlags LimitFlags;
public UIntPtr MinimumWorkingSetSize;
public UIntPtr MaximumWorkingSetSize;
public UInt32 ActiveProcessLimit;
public uint ActiveProcessLimit;
public UIntPtr Affinity;
public UInt32 PriorityClass;
public UInt32 SchedulingClass;
public uint PriorityClass;
public uint SchedulingClass;
}

[StructLayout(LayoutKind.Sequential)]
internal struct IoCounters
{
public UInt64 ReadOperationCount;
public UInt64 WriteOperationCount;
public UInt64 OtherOperationCount;
public UInt64 ReadTransferCount;
public UInt64 WriteTransferCount;
public UInt64 OtherTransferCount;
public ulong ReadOperationCount;
public ulong WriteOperationCount;
public ulong OtherOperationCount;
public ulong ReadTransferCount;
public ulong WriteTransferCount;
public ulong OtherTransferCount;
}

[StructLayout(LayoutKind.Sequential)]
Expand Down Expand Up @@ -73,7 +73,7 @@ internal struct PROCESS_BASIC_INFORMATION
internal static extern SafeWaitHandle CreateJobObjectW(IntPtr lpJobAttributes, string lpName);

[DllImport("kernel32.dll", SetLastError = true)]
internal static extern bool SetInformationJobObject(IntPtr hJob, JobObjectInfoClass jobObjectInformationClass, IntPtr lpJobObjectInformation, UInt32 cbJobObjectInformationLength);
internal static extern bool SetInformationJobObject(IntPtr hJob, JobObjectInfoClass jobObjectInformationClass, IntPtr lpJobObjectInformation, uint cbJobObjectInformationLength);

[DllImport("kernel32.dll", SetLastError = true)]
internal static extern bool AssignProcessToJobObject(IntPtr hJob, IntPtr hProcess);
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/Microsoft.DotNet.Cli.Utils/RuntimeEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private static string GetFreeBSDVersion()
// This is same as sysctl kern.version
// FreeBSD 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu Sep 29 01:43:23 UTC 2016 [email protected]:/usr/obj/usr/src/sys/GENERIC
// What we want is major release as minor releases should be compatible.
String version = RuntimeInformation.OSDescription;
string version = RuntimeInformation.OSDescription;
try
{
// second token up to first dot
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/Microsoft.DotNet.Cli.Utils/UILanguageOverride.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private static bool CurrentPlatformOfficiallySupportsUTF8Encoding()

private static bool ForceUniversalEncodingOptInEnabled()
{
return String.Equals(Environment.GetEnvironmentVariable("DOTNET_CLI_FORCE_UTF8_ENCODING"), "true", StringComparison.OrdinalIgnoreCase);
return string.Equals(Environment.GetEnvironmentVariable("DOTNET_CLI_FORCE_UTF8_ENCODING"), "true", StringComparison.OrdinalIgnoreCase);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override void Elevate()
}
}

private void ServerExited(Object sender, EventArgs e)
private void ServerExited(object sender, EventArgs e)
{
_log?.LogMessage($"Elevated command instance has exited.");
}
Expand Down
6 changes: 3 additions & 3 deletions src/Cli/dotnet/ReleasePropertyProjectLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public IEnumerable<string> GetCustomDefaultConfigurationValueIfSpecified()
// Setup
Debug.Assert(_propertyToCheck == MSBuildPropertyNames.PUBLISH_RELEASE || _propertyToCheck == MSBuildPropertyNames.PACK_RELEASE, "Only PackRelease or PublishRelease are currently expected.");
var nothing = Enumerable.Empty<string>();
if (String.Equals(Environment.GetEnvironmentVariable(EnvironmentVariableNames.DISABLE_PUBLISH_AND_PACK_RELEASE), "true", StringComparison.OrdinalIgnoreCase))
if (string.Equals(Environment.GetEnvironmentVariable(EnvironmentVariableNames.DISABLE_PUBLISH_AND_PACK_RELEASE), "true", StringComparison.OrdinalIgnoreCase))
{
return nothing;
}
Expand Down Expand Up @@ -160,7 +160,7 @@ public IEnumerable<string> GetCustomDefaultConfigurationValueIfSpecified()
HashSet<string> configValues = new HashSet<string>();
object projectDataLock = new object();

if (String.Equals(Environment.GetEnvironmentVariable(EnvironmentVariableNames.DOTNET_CLI_LAZY_PUBLISH_AND_PACK_RELEASE_FOR_SOLUTIONS), "true", StringComparison.OrdinalIgnoreCase))
if (string.Equals(Environment.GetEnvironmentVariable(EnvironmentVariableNames.DOTNET_CLI_LAZY_PUBLISH_AND_PACK_RELEASE_FOR_SOLUTIONS), "true", StringComparison.OrdinalIgnoreCase))
{
// Evaluate only one project for speed if this environment variable is used. Will break more customers if enabled (adding 8.0 project to SLN with other project TFMs with no Publish or PackRelease.)
return GetSingleProjectFromSolution(sln, globalProps);
Expand Down Expand Up @@ -197,7 +197,7 @@ public IEnumerable<string> GetCustomDefaultConfigurationValueIfSpecified()
// 1) This error should not be thrown in VS because it is part of the SDK CLI code
// 2) If PublishRelease or PackRelease is disabled via opt out, or Configuration is specified, we won't get to this code, so we won't error
// 3) This code only gets hit if we are in a solution publish setting, so we don't need to worry about it failing other publish scenarios
throw new GracefulException(Strings.SolutionProjectConfigurationsConflict, _propertyToCheck, String.Join("\n", (configuredProjects).Select(x => x.FullPath)));
throw new GracefulException(Strings.SolutionProjectConfigurationsConflict, _propertyToCheck, string.Join("\n", (configuredProjects).Select(x => x.FullPath)));
}
return configuredProjects.FirstOrDefault();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/SlnFileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private static string GetMatchingProjectKey(IDictionary<string, string> projectK
return projectKey;
}

var keyWithoutWhitespace = String.Concat(solutionKey.Where(c => !Char.IsWhiteSpace(c)));
var keyWithoutWhitespace = string.Concat(solutionKey.Where(c => !char.IsWhiteSpace(c)));
if (projectKeys.TryGetValue(keyWithoutWhitespace, out projectKey))
{
return projectKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static LaunchSettingsApplyResult TryApplyLaunchSettings(string launchSett
if (caseInsensitiveProfileMatches.Count() > 1)
{
throw new GracefulException(LocalizableStrings.DuplicateCaseInsensitiveLaunchProfileNames,
String.Join(",\n", caseInsensitiveProfileMatches.Select(p => $"\t{p.Name}").ToArray()));
string.Join(",\n", caseInsensitiveProfileMatches.Select(p => $"\t{p.Name}").ToArray()));
}
else if (!caseInsensitiveProfileMatches.Any())
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/commands/dotnet-run/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public int Execute()
//NOTE: MSBuild variables are not expanded like they are in VS
targetCommand.EnvironmentVariable(entry.Key, value);
}
if (String.IsNullOrEmpty(targetCommand.CommandArgs) && launchSettings.CommandLineArgs != null)
if (string.IsNullOrEmpty(targetCommand.CommandArgs) && launchSettings.CommandLineArgs != null)
{
targetCommand.SetCommandArgs(launchSettings.CommandLineArgs);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/commands/dotnet-test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private static TestCommand FromParseResult(ParseResult result, string[] settings
result.OptionValuesToBeForwarded(TestCommandParser.GetCommand()) // all msbuild-recognized tokens
.Concat(unMatchedNonSettingsArgs); // all tokens that the test-parser doesn't explicitly track (minus the settings tokens)

VSTestTrace.SafeWriteTrace(() => $"MSBuild args from forwarded options: {String.Join(", ", parsedArgs)}");
VSTestTrace.SafeWriteTrace(() => $"MSBuild args from forwarded options: {string.Join(", ", parsedArgs)}");
msbuildArgs.AddRange(parsedArgs);

if (settings.Any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static IEnumerable<string> GetUserFacingMessages(Exception ex, PackageId
{
userFacingMessages = new[]
{
String.Format(
string.Format(
CommonLocalizableStrings.FailedToUninstallToolPackage,
packageId,
ex.Message),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ private void RemoveWorkloadPacks(List<WorkloadPackRecord> packsToRemove, Directo
{
Log?.LogMessage($"ProductCode mismatch! Cached package: {msi.ProductCode}, pack record: {record.ProductCode}.");
string logFile = GetMsiLogName(record, InstallAction.Uninstall);
uint error = ExecuteWithProgress(String.Format(LocalizableStrings.MsiProgressUninstall, id), () => UninstallMsi(record.ProductCode, logFile));
uint error = ExecuteWithProgress(string.Format(LocalizableStrings.MsiProgressUninstall, id), () => UninstallMsi(record.ProductCode, logFile));
ExitOnError(error, $"Failed to uninstall {msi.MsiPath}.");
}
else
Expand Down Expand Up @@ -586,7 +586,7 @@ public async Task ExtractManifestAsync(string nupkgPath, string targetPath)
string packageDataPath = Path.Combine(extractionPath, "data");
if (!Cache.TryGetMsiPathFromPackageData(packageDataPath, out string msiPath, out _))
{
throw new FileNotFoundException(String.Format(LocalizableStrings.ManifestMsiNotFoundInNuGetPackage, extractionPath));
throw new FileNotFoundException(string.Format(LocalizableStrings.ManifestMsiNotFoundInNuGetPackage, extractionPath));
}
string msiExtractionPath = Path.Combine(extractionPath, "msi");

Expand All @@ -604,7 +604,7 @@ public async Task ExtractManifestAsync(string nupkgPath, string targetPath)
if (result != Error.SUCCESS)
{
Log?.LogMessage($"ExtractManifestAsync: Admin install failed: {result}");
throw new GracefulException(String.Format(LocalizableStrings.FailedToExtractMsi, msiPath));
throw new GracefulException(string.Format(LocalizableStrings.FailedToExtractMsi, msiPath));
}
}

Expand All @@ -619,7 +619,7 @@ public async Task ExtractManifestAsync(string nupkgPath, string targetPath)

if (manifestFolder == null)
{
throw new GracefulException(String.Format(LocalizableStrings.ExpectedSingleManifest, nupkgPath));
throw new GracefulException(string.Format(LocalizableStrings.ExpectedSingleManifest, nupkgPath));
}

FileAccessRetrier.RetryOnMoveAccessFailure(() => DirectoryPath.MoveDirectory(manifestFolder, targetPath));
Expand Down Expand Up @@ -930,17 +930,17 @@ private void ExecutePackage(MsiPayload msi, InstallAction action, string display
case InstallAction.MinorUpdate:
case InstallAction.Install:
case InstallAction.MajorUpgrade:
error = ExecuteWithProgress(String.Format(LocalizableStrings.MsiProgressInstall, name), () => InstallMsi(msi.MsiPath, logFile));
error = ExecuteWithProgress(string.Format(LocalizableStrings.MsiProgressInstall, name), () => InstallMsi(msi.MsiPath, logFile));
ExitOnError(error, $"Failed to install {msi.Payload}.");
break;

case InstallAction.Repair:
error = ExecuteWithProgress(String.Format(LocalizableStrings.MsiProgressRepair, name), () => RepairMsi(msi.ProductCode, logFile));
error = ExecuteWithProgress(string.Format(LocalizableStrings.MsiProgressRepair, name), () => RepairMsi(msi.ProductCode, logFile));
ExitOnError(error, $"Failed to repair {msi.Payload}.");
break;

case InstallAction.Uninstall:
error = ExecuteWithProgress(String.Format(LocalizableStrings.MsiProgressUninstall, name), () => UninstallMsi(msi.ProductCode, logFile));
error = ExecuteWithProgress(string.Format(LocalizableStrings.MsiProgressUninstall, name), () => UninstallMsi(msi.ProductCode, logFile));
ExitOnError(error, $"Failed to remove {msi.Payload}.");
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static NetSdkMsiInstallerServer Create(bool verifySignatures)
if ((ParentProcess == null) || (ParentProcess.StartTime > CurrentProcess.StartTime) ||
!string.Equals(ParentProcess.MainModule.FileName, Environment.ProcessPath, StringComparison.OrdinalIgnoreCase))
{
throw new SecurityException(String.Format(LocalizableStrings.NoTrustWithParentPID, ParentProcess?.Id));
throw new SecurityException(string.Format(LocalizableStrings.NoTrustWithParentPID, ParentProcess?.Id));
}

// Configure pipe DACLs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ private bool BackgroundUpdatesAreDisabled() =>

private static string GetAdvertisingWorkloadsFilePath(string userProfileDir, SdkFeatureBand featureBand) => Path.Combine(userProfileDir, $".workloadAdvertisingUpdates{featureBand}");

private async Task<String> GetOnlinePackagePath(SdkFeatureBand sdkFeatureBand, ManifestId manifestId, bool includePreviews)
private async Task<string> GetOnlinePackagePath(SdkFeatureBand sdkFeatureBand, ManifestId manifestId, bool includePreviews)
{
string packagePath = await _nugetPackageDownloader.DownloadPackageAsync(
_workloadManifestInstaller.GetManifestPackageId(manifestId, sdkFeatureBand),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ namespace Microsoft.NET.Build.Containers;
public sealed class BaseImageNotFoundException : Exception
{
internal BaseImageNotFoundException(string specifiedRuntimeIdentifier, string repositoryName, string reference, IEnumerable<string> supportedRuntimeIdentifiers)
: base($"The RuntimeIdentifier '{specifiedRuntimeIdentifier}' is not supported by {repositoryName}:{reference}. The supported RuntimeIdentifiers are {String.Join(",", supportedRuntimeIdentifiers)}") { }
: base($"The RuntimeIdentifier '{specifiedRuntimeIdentifier}' is not supported by {repositoryName}:{reference}. The supported RuntimeIdentifiers are {string.Join(",", supportedRuntimeIdentifiers)}") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static bool TryParsePort(string? portNumber, string? portType, [NotNullWh
{
var portNo = 0;
error = null;
if (String.IsNullOrEmpty(portNumber))
if (string.IsNullOrEmpty(portNumber))
{
error = ParsePortError.MissingPortNumber;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ internal async Task<bool> ExecuteAsync(CancellationToken cancellationToken)
return !Log.HasLoggedErrors;
}

SafeLog(Strings.ContainerBuilder_StartBuildingImage, Repository, String.Join(",", ImageTags), sourceImageReference);
SafeLog(Strings.ContainerBuilder_StartBuildingImage, Repository, string.Join(",", ImageTags), sourceImageReference);

Layer newLayer = Layer.FromDirectory(PublishDirectory, WorkingDirectory, imageBuilder.IsWindows);
imageBuilder.AddLayer(newLayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ public ParseContainerProperties()
public override bool Execute()
{
string[] validTags;
if (!String.IsNullOrEmpty(ContainerImageTag) && ContainerImageTags.Length >= 1)
if (!string.IsNullOrEmpty(ContainerImageTag) && ContainerImageTags.Length >= 1)
{
Log.LogErrorWithCodeFromResources(nameof(Strings.AmbiguousTags), nameof(ContainerImageTag), nameof(ContainerImageTags));
return !Log.HasLoggedErrors;
}

if (!String.IsNullOrEmpty(ContainerImageTag))
if (!string.IsNullOrEmpty(ContainerImageTag))
{
if (ContainerHelpers.IsValidImageTag(ContainerImageTag))
{
Expand All @@ -105,7 +105,7 @@ public override bool Execute()
validTags = valids;
if (invalids.Any())
{
Log.LogErrorWithCodeFromResources(nameof(Strings.InvalidTags), nameof(ContainerImageTags), String.Join(",", invalids));
Log.LogErrorWithCodeFromResources(nameof(Strings.InvalidTags), nameof(ContainerImageTags), string.Join(",", invalids));
return !Log.HasLoggedErrors;
}
}
Expand All @@ -114,7 +114,7 @@ public override bool Execute()
validTags = Array.Empty<string>();
}

if (!String.IsNullOrEmpty(ContainerRegistry) && !ContainerHelpers.IsValidRegistry(ContainerRegistry))
if (!string.IsNullOrEmpty(ContainerRegistry) && !ContainerHelpers.IsValidRegistry(ContainerRegistry))
{
Log.LogErrorWithCodeFromResources(nameof(Strings.CouldntRecognizeRegistry), ContainerRegistry);
return !Log.HasLoggedErrors;
Expand Down Expand Up @@ -173,7 +173,7 @@ public override bool Execute()
Log.LogMessage(MessageImportance.Low, "Image: {0}", ParsedContainerImage);
Log.LogMessage(MessageImportance.Low, "Tag: {0}", ParsedContainerTag);
Log.LogMessage(MessageImportance.Low, "Image Name: {0}", NewContainerRepository);
Log.LogMessage(MessageImportance.Low, "Image Tags: {0}", String.Join(", ", NewContainerTags));
Log.LogMessage(MessageImportance.Low, "Image Tags: {0}", string.Join(", ", NewContainerTags));
}

return !Log.HasLoggedErrors;
Expand Down
Loading

0 comments on commit 0aa624d

Please sign in to comment.