diff --git a/src/core-sdk-tasks/AzurePublisher.cs b/src/core-sdk-tasks/AzurePublisher.cs index 243fad789..6bfb5efe4 100644 --- a/src/core-sdk-tasks/AzurePublisher.cs +++ b/src/core-sdk-tasks/AzurePublisher.cs @@ -205,15 +205,9 @@ namespace Microsoft.DotNet.Cli.Build } } - private void DeleteBlob(string path) - { - _blobContainer.GetBlockBlobReference(path).DeleteAsync().Wait(); - } + private void DeleteBlob(string path) => _blobContainer.GetBlockBlobReference(path).DeleteAsync().Wait(); - private static string CalculateRelativePathForFile(string file, Product product, string version) - { - return $"{product}/{version}/{Path.GetFileName(file)}"; - } + private static string CalculateRelativePathForFile(string file, Product product, string version) => $"{product}/{version}/{Path.GetFileName(file)}"; } } #endif diff --git a/src/core-sdk-tasks/Chmod.cs b/src/core-sdk-tasks/Chmod.cs index fc136448f..dad9286b0 100644 --- a/src/core-sdk-tasks/Chmod.cs +++ b/src/core-sdk-tasks/Chmod.cs @@ -20,25 +20,13 @@ namespace Microsoft.DotNet.Cli.Build protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High; - protected override string GenerateFullPathToTool() - { - return "chmod"; - } + protected override string GenerateFullPathToTool() => "chmod"; - protected override string GenerateCommandLineCommands() - { - return $"{GetRecursive()} {GetMode()} {GetGlob()}"; - } + protected override string GenerateCommandLineCommands() => $"{GetRecursive()} {GetMode()} {GetGlob()}"; - private string GetGlob() - { - return Glob; - } + private string GetGlob() => Glob; - private string GetMode() - { - return Mode; - } + private string GetMode() => Mode; private string GetRecursive() { diff --git a/src/core-sdk-tasks/Crossgen.cs b/src/core-sdk-tasks/Crossgen.cs index 1fa3ab128..a612bbc8f 100644 --- a/src/core-sdk-tasks/Crossgen.cs +++ b/src/core-sdk-tasks/Crossgen.cs @@ -127,15 +127,9 @@ namespace Microsoft.DotNet.Build.Tasks return "crossgen2"; } - protected override string GenerateCommandLineCommands() - { - return $"{GetInPath()} {GetOutPath()} {GetArchitecture()} {GetPlatformAssemblyPaths()} {GetCreateSymbols()}"; - } + protected override string GenerateCommandLineCommands() => $"{GetInPath()} {GetOutPath()} {GetArchitecture()} {GetPlatformAssemblyPaths()} {GetCreateSymbols()}"; - private string GetArchitecture() - { - return $"--targetarch {Architecture}"; - } + private string GetArchitecture() => $"--targetarch {Architecture}"; private string GetCreateSymbols() { @@ -153,15 +147,9 @@ namespace Microsoft.DotNet.Build.Tasks return null; } - private string GetInPath() - { - return $"\"{SourceAssembly}\""; - } - - private string GetOutPath() - { - return $"-o \"{TempOutputPath}\""; - } + private string GetInPath() => $"\"{SourceAssembly}\""; + + private string GetOutPath() => $"-o \"{TempOutputPath}\""; private string GetPlatformAssemblyPaths() { @@ -177,15 +165,9 @@ namespace Microsoft.DotNet.Build.Tasks return platformAssemblyPaths; } - - private string GetMissingDependenciesOk() - { - return "-MissingDependenciesOK"; - } - protected override void LogToolCommand(string message) - { - base.LogToolCommand($"{base.GetWorkingDirectory()}> {message}"); - } + private string GetMissingDependenciesOk() => "-MissingDependenciesOK"; + + protected override void LogToolCommand(string message) => base.LogToolCommand($"{base.GetWorkingDirectory()}> {message}"); } } diff --git a/src/core-sdk-tasks/DotNetDebTool.cs b/src/core-sdk-tasks/DotNetDebTool.cs index 1b862d59e..17a3bfd48 100644 --- a/src/core-sdk-tasks/DotNetDebTool.cs +++ b/src/core-sdk-tasks/DotNetDebTool.cs @@ -25,25 +25,13 @@ namespace Microsoft.DotNet.Cli.Build protected override string ToolName => "package_tool.sh"; - private string GetInputDir() - { - return $"-i {InputDirectory}"; - } + private string GetInputDir() => $"-i {InputDirectory}"; - private string GetOutputFile() - { - return $"-o {OutputDirectory}"; - } + private string GetOutputFile() => $"-o {OutputDirectory}"; - private string GetPackageName() - { - return $"-n {PackageName}"; - } + private string GetPackageName() => $"-n {PackageName}"; - private string GetPackageVersion() - { - return $"-v {PackageVersion}"; - } + private string GetPackageVersion() => $"-v {PackageVersion}"; protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High; @@ -62,10 +50,7 @@ namespace Microsoft.DotNet.Cli.Build return path; } - protected override string GetWorkingDirectory() - { - return WorkingDirectory ?? base.GetWorkingDirectory(); - } + protected override string GetWorkingDirectory() => WorkingDirectory ?? base.GetWorkingDirectory(); protected override string GenerateCommandLineCommands() { @@ -76,15 +61,9 @@ namespace Microsoft.DotNet.Cli.Build return commandLineCommands; } - protected override void LogToolCommand(string message) - { - base.LogToolCommand($"{GetWorkingDirectory()}> {message}"); - } + protected override void LogToolCommand(string message) => base.LogToolCommand($"{GetWorkingDirectory()}> {message}"); - protected override void LogEventsFromTextOutput(string singleLine, MessageImportance messageImportance) - { - Log.LogMessage(messageImportance, singleLine, null); - } + protected override void LogEventsFromTextOutput(string singleLine, MessageImportance messageImportance) => Log.LogMessage(messageImportance, singleLine, null); protected override ProcessStartInfo GetProcessStartInfo( string pathToTool, diff --git a/src/core-sdk-tasks/DotNetTool.cs b/src/core-sdk-tasks/DotNetTool.cs index b6888fc48..505ef269f 100644 --- a/src/core-sdk-tasks/DotNetTool.cs +++ b/src/core-sdk-tasks/DotNetTool.cs @@ -58,10 +58,7 @@ namespace Microsoft.DotNet.Cli.Build return path; } - protected override string GetWorkingDirectory() - { - return WorkingDirectory ?? base.GetWorkingDirectory(); - } + protected override string GetWorkingDirectory() => WorkingDirectory ?? base.GetWorkingDirectory(); protected override string GenerateCommandLineCommands() { @@ -72,9 +69,6 @@ namespace Microsoft.DotNet.Cli.Build return commandLineCommands; } - protected override void LogToolCommand(string message) - { - base.LogToolCommand($"{GetWorkingDirectory()}> {message}"); - } + protected override void LogToolCommand(string message) => base.LogToolCommand($"{GetWorkingDirectory()}> {message}"); } } diff --git a/src/core-sdk-tasks/ExtractArchiveToDirectory.cs b/src/core-sdk-tasks/ExtractArchiveToDirectory.cs index 53c077fc1..ad31fac3d 100644 --- a/src/core-sdk-tasks/ExtractArchiveToDirectory.cs +++ b/src/core-sdk-tasks/ExtractArchiveToDirectory.cs @@ -193,14 +193,8 @@ namespace Microsoft.DotNet.Build.Tasks protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High; - protected override string GenerateFullPathToTool() - { - return "tar"; - } + protected override string GenerateFullPathToTool() => "tar"; - protected override string GenerateCommandLineCommands() - { - return $"xf {SourceArchive} -C {DestinationDirectory}"; - } + protected override string GenerateCommandLineCommands() => $"xf {SourceArchive} -C {DestinationDirectory}"; } } diff --git a/src/core-sdk-tasks/TarGzFileCreateFromDirectory.cs b/src/core-sdk-tasks/TarGzFileCreateFromDirectory.cs index eb094bdac..f7ed0797b 100644 --- a/src/core-sdk-tasks/TarGzFileCreateFromDirectory.cs +++ b/src/core-sdk-tasks/TarGzFileCreateFromDirectory.cs @@ -88,24 +88,15 @@ namespace Microsoft.DotNet.Build.Tasks return retVal; } - public override bool Execute() - { - return base.Execute(); - } + public override bool Execute() => base.Execute(); protected override string ToolName => "tar"; protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High; - protected override string GenerateFullPathToTool() - { - return "tar"; - } + protected override string GenerateFullPathToTool() => "tar"; - protected override string GenerateCommandLineCommands() - { - return $"{GetDestinationArchive()} {GetSourceSpecification()}"; - } + protected override string GenerateCommandLineCommands() => $"{GetDestinationArchive()} {GetSourceSpecification()}"; private string GetSourceSpecification() { @@ -123,10 +114,7 @@ namespace Microsoft.DotNet.Build.Tasks } } - private string GetDestinationArchive() - { - return $"-czf {DestinationArchive}"; - } + private string GetDestinationArchive() => $"-czf {DestinationArchive}"; private string GetExcludes() { @@ -142,10 +130,7 @@ namespace Microsoft.DotNet.Build.Tasks return excludes; } - - protected override void LogToolCommand(string message) - { - base.LogToolCommand($"{base.GetWorkingDirectory()}> {message}"); - } + + protected override void LogToolCommand(string message) => base.LogToolCommand($"{base.GetWorkingDirectory()}> {message}"); } } diff --git a/test/EndToEnd/GivenDotNetLinuxInstallers.cs b/test/EndToEnd/GivenDotNetLinuxInstallers.cs index 4968f0221..1eba2dc51 100644 --- a/test/EndToEnd/GivenDotNetLinuxInstallers.cs +++ b/test/EndToEnd/GivenDotNetLinuxInstallers.cs @@ -31,8 +31,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd } } - private void DebianPackageHasDependencyOnAspNetCoreStoreAndDotnetRuntime(string installerFile) - { + private void DebianPackageHasDependencyOnAspNetCoreStoreAndDotnetRuntime(string installerFile) => // Example output: // $ dpkg --info dotnet-sdk-2.1.105-ubuntu-x64.deb @@ -58,10 +57,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd .Should().Pass() .And.HaveStdOutMatching(@"Depends:.*\s?dotnet-runtime-\d+(\.\d+){2}") .And.HaveStdOutMatching(@"Depends:.*\s?aspnetcore-store-\d+(\.\d+){2}"); - } - private void RpmPackageHasDependencyOnAspNetCoreStoreAndDotnetRuntime(string installerFile) - { + private void RpmPackageHasDependencyOnAspNetCoreStoreAndDotnetRuntime(string installerFile) => // Example output: // $ rpm -qpR dotnet-sdk-2.1.105-rhel-x64.rpm @@ -78,6 +75,5 @@ namespace Microsoft.DotNet.Tests.EndToEnd .Should().Pass() .And.HaveStdOutMatching(@"dotnet-runtime-\d+(\.\d+){2} >= \d+(\.\d+){2}") .And.HaveStdOutMatching(@"aspnetcore-store-\d+(\.\d+){2} >= \d+(\.\d+){2}"); - } } } diff --git a/test/EndToEnd/GivenDotnetUsesDotnetTools.cs b/test/EndToEnd/GivenDotnetUsesDotnetTools.cs index 3e32c4a45..40cefe4f7 100644 --- a/test/EndToEnd/GivenDotnetUsesDotnetTools.cs +++ b/test/EndToEnd/GivenDotnetUsesDotnetTools.cs @@ -7,11 +7,8 @@ namespace EndToEnd public class GivenDotnetUsesDotnetTools : TestBase { [RequiresAspNetCore] - public void ThenOneDotnetToolsCanBeCalled() - { - new DotnetCommand() + public void ThenOneDotnetToolsCanBeCalled() => new DotnetCommand() .ExecuteWithCapturedOutput("dev-certs --help") .Should().Pass(); - } } } diff --git a/test/EndToEnd/GivenFrameworkDependentApps.cs b/test/EndToEnd/GivenFrameworkDependentApps.cs index 9e0677e6c..1e3d0d806 100644 --- a/test/EndToEnd/GivenFrameworkDependentApps.cs +++ b/test/EndToEnd/GivenFrameworkDependentApps.cs @@ -40,10 +40,7 @@ namespace EndToEnd [Theory] [ClassData(typeof(SupportedAspNetCoreAllVersions))] - public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreAll(string minorVersion) - { - ItDoesNotRollForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAllPackageName, minorVersion); - } + public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreAll(string minorVersion) => ItDoesNotRollForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAllPackageName, minorVersion); internal void ItDoesNotRollForwardToTheLatestVersion(string packageName, string minorVersion) { @@ -87,13 +84,10 @@ namespace EndToEnd #endif } - private static NuGetVersion GetPackageVersion(LockFile lockFile, string packageName) - { - return lockFile?.Targets?.SingleOrDefault(t => t.RuntimeIdentifier == null) + private static NuGetVersion GetPackageVersion(LockFile lockFile, string packageName) => lockFile?.Targets?.SingleOrDefault(t => t.RuntimeIdentifier == null) ?.Libraries?.SingleOrDefault(l => string.Compare(l.Name, packageName, StringComparison.CurrentCultureIgnoreCase) == 0) ?.Version; - } public string GetExpectedVersion(string packageName, string minorVersion) { diff --git a/test/EndToEnd/GivenSelfContainedAppsRollForward.cs b/test/EndToEnd/GivenSelfContainedAppsRollForward.cs index 297dfd1d5..6c8160627 100644 --- a/test/EndToEnd/GivenSelfContainedAppsRollForward.cs +++ b/test/EndToEnd/GivenSelfContainedAppsRollForward.cs @@ -92,13 +92,10 @@ namespace EndToEnd "needs to be updated (see the ImplicitPackageVariable items in MSBuildExtensions.targets in this repo)"); } - private static NuGetVersion GetPackageVersion(LockFile lockFile, string packageName) - { - return lockFile?.Targets?.SingleOrDefault(t => t.RuntimeIdentifier != null) + private static NuGetVersion GetPackageVersion(LockFile lockFile, string packageName) => lockFile?.Targets?.SingleOrDefault(t => t.RuntimeIdentifier != null) ?.Libraries?.SingleOrDefault(l => string.Compare(l.Name, packageName, StringComparison.CurrentCultureIgnoreCase) == 0) ?.Version; - } [Fact] public void WeCoverLatestNetCoreAppRollForward() diff --git a/test/EndToEnd/ProjectBuildTests.cs b/test/EndToEnd/ProjectBuildTests.cs index d27b1ac71..eb8e64ddb 100644 --- a/test/EndToEnd/ProjectBuildTests.cs +++ b/test/EndToEnd/ProjectBuildTests.cs @@ -191,10 +191,7 @@ namespace EndToEnd.Tests [InlineData("nunit")] [InlineData("web")] [InlineData("mvc")] - public void ItCanBuildTemplates(string templateName, string language = "") - { - TestTemplateCreateAndBuild(templateName, language: language); - } + public void ItCanBuildTemplates(string templateName, string language = "") => TestTemplateCreateAndBuild(templateName, language: language); /// /// The test checks if dotnet new shows curated list correctly after the SDK installation and template insertion. @@ -309,25 +306,16 @@ namespace EndToEnd.Tests [WindowsOnlyTheory] [InlineData("wpf")] [InlineData("winforms")] - public void ItCanBuildDesktopTemplates(string templateName) - { - TestTemplateCreateAndBuild(templateName); - } + public void ItCanBuildDesktopTemplates(string templateName) => TestTemplateCreateAndBuild(templateName); [WindowsOnlyTheory] [InlineData("wpf")] - public void ItCanBuildDesktopTemplatesSelfContained(string templateName) - { - TestTemplateCreateAndBuild(templateName, selfContained: true); - } + public void ItCanBuildDesktopTemplatesSelfContained(string templateName) => TestTemplateCreateAndBuild(templateName, selfContained: true); [Theory] [InlineData("web")] [InlineData("console")] - public void ItCanBuildTemplatesSelfContained(string templateName) - { - TestTemplateCreateAndBuild(templateName, selfContained: true); - } + public void ItCanBuildTemplatesSelfContained(string templateName) => TestTemplateCreateAndBuild(templateName, selfContained: true); /// /// The test checks if the template creates the template for correct framework by default. diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultExtensions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultExtensions.cs index ad3bf23c3..4cd8b0cfe 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultExtensions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultExtensions.cs @@ -7,9 +7,6 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { public static class CommandResultExtensions { - public static CommandResultAssertions Should(this CommandResult commandResult) - { - return new CommandResultAssertions(commandResult); - } + public static CommandResultAssertions Should(this CommandResult commandResult) => new CommandResultAssertions(commandResult); } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoExtensions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoExtensions.cs index fedc70850..f4f955296 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoExtensions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoExtensions.cs @@ -11,29 +11,14 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { public static class DirectoryInfoExtensions { - public static DirectoryInfoAssertions Should(this DirectoryInfo dir) - { - return new DirectoryInfoAssertions(dir); - } + public static DirectoryInfoAssertions Should(this DirectoryInfo dir) => new DirectoryInfoAssertions(dir); - public static DirectoryInfo Sub(this DirectoryInfo dir, string name) - { - return new DirectoryInfo(Path.Combine(dir.FullName, name)); - } + public static DirectoryInfo Sub(this DirectoryInfo dir, string name) => new DirectoryInfo(Path.Combine(dir.FullName, name)); - public static bool Contains(this DirectoryInfo subject, FileSystemInfo target) - { - return target.FullName.StartsWith(subject.FullName); - } + public static bool Contains(this DirectoryInfo subject, FileSystemInfo target) => target.FullName.StartsWith(subject.FullName); - public static DirectoryInfo GetDirectory(this DirectoryInfo subject, params string [] directoryNames) - { - return new DirectoryInfo(Path.Combine(subject.FullName, Path.Combine(directoryNames))); - } + public static DirectoryInfo GetDirectory(this DirectoryInfo subject, params string[] directoryNames) => new DirectoryInfo(Path.Combine(subject.FullName, Path.Combine(directoryNames))); - public static FileInfo GetFile(this DirectoryInfo subject, string fileName) - { - return new FileInfo(Path.Combine(subject.FullName, fileName)); - } + public static FileInfo GetFile(this DirectoryInfo subject, string fileName) => new FileInfo(Path.Combine(subject.FullName, fileName)); } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoExtensions.FileInfoLock.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoExtensions.FileInfoLock.cs index 5f2325ef6..d0407c9b2 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoExtensions.FileInfoLock.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoExtensions.FileInfoLock.cs @@ -20,10 +20,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities _fileStream = fileInfo.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None); } - public void Dispose() - { - _fileStream.Dispose(); - } + public void Dispose() => _fileStream.Dispose(); } } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoExtensions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoExtensions.cs index ccf3bf842..448f0865c 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoExtensions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoExtensions.cs @@ -11,24 +11,12 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { public static partial class FileInfoExtensions { - public static FileInfoAssertions Should(this FileInfo file) - { - return new FileInfoAssertions(file); - } + public static FileInfoAssertions Should(this FileInfo file) => new FileInfoAssertions(file); - public static IDisposable Lock(this FileInfo subject) - { - return new FileInfoLock(subject); - } + public static IDisposable Lock(this FileInfo subject) => new FileInfoLock(subject); - public static IDisposable NuGetLock(this FileInfo subject) - { - return new FileInfoNuGetLock(subject); - } + public static IDisposable NuGetLock(this FileInfo subject) => new FileInfoNuGetLock(subject); - public static string ReadAllText(this FileInfo subject) - { - return File.ReadAllText(subject.FullName); - } + public static string ReadAllText(this FileInfo subject) => File.ReadAllText(subject.FullName); } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs index e0483c39a..0f6d890aa 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs @@ -10,10 +10,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { public static class StringAssertionsExtensions { - private static string NormalizeLineEndings(string s) - { - return s.Replace("\r\n", "\n"); - } + private static string NormalizeLineEndings(string s) => s.Replace("\r\n", "\n"); public static AndConstraint BeVisuallyEquivalentTo(this StringAssertions assertions, string expected, string because = "", params object[] becauseArgs) { diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/BufferedReporter.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/BufferedReporter.cs index e657e324c..2461e7f6c 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/BufferedReporter.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/BufferedReporter.cs @@ -12,19 +12,10 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public void WriteLine(string format, params object?[] args) => WriteLine(string.Format(format, args)); - public void WriteLine(string message) - { - Lines.Add(message); - } + public void WriteLine(string message) => Lines.Add(message); - public void WriteLine() - { - Lines.Add(""); - } + public void WriteLine() => Lines.Add(""); - public void Write(string message) - { - throw new NotImplementedException(); - } + public void Write(string message) => throw new NotImplementedException(); } } \ No newline at end of file diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildServerCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildServerCommand.cs index 986587188..463642689 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildServerCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildServerCommand.cs @@ -7,14 +7,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { public sealed class BuildServerCommand : DotnetCommand { - public override CommandResult Execute(string args = "") - { - return base.Execute($"build-server {args}"); - } + public override CommandResult Execute(string args = "") => base.Execute($"build-server {args}"); - public override CommandResult ExecuteWithCapturedOutput(string args = "") - { - return base.ExecuteWithCapturedOutput($"build-server {args}"); - } + public override CommandResult ExecuteWithCapturedOutput(string args = "") => base.ExecuteWithCapturedOutput($"build-server {args}"); } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/HelpCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/HelpCommand.cs index 222d92368..a816d97cd 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/HelpCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/HelpCommand.cs @@ -7,19 +7,10 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { public sealed class HelpCommand : DotnetCommand { - public override CommandResult Execute(string args = "") - { - return base.Execute(AppendHelp(args)); - } + public override CommandResult Execute(string args = "") => base.Execute(AppendHelp(args)); - public override CommandResult ExecuteWithCapturedOutput(string args = "") - { - return base.ExecuteWithCapturedOutput(AppendHelp(args)); - } + public override CommandResult ExecuteWithCapturedOutput(string args = "") => base.ExecuteWithCapturedOutput(AppendHelp(args)); - private string AppendHelp(string args) - { - return args = $"help {args}"; - } + private string AppendHelp(string args) => args = $"help {args}"; } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PackCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PackCommand.cs index 4f5242e72..4c50b7ae8 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PackCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PackCommand.cs @@ -76,9 +76,6 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return base.ExecuteWithCapturedOutput(args); } - private string BuildArgs() - { - return $"{_projectPath} {OutputOption} {BuildBasePathOption} {TempOutputOption} {ConfigurationOption} {VersionSuffixOption} {ServiceableOption}"; - } + private string BuildArgs() => $"{_projectPath} {OutputOption} {BuildBasePathOption} {TempOutputOption} {ConfigurationOption} {VersionSuffixOption} {ServiceableOption}"; } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PublishCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PublishCommand.cs index ada6a80be..fd39bb6bf 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PublishCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PublishCommand.cs @@ -21,10 +21,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return this; } - public PublishCommand WithFramework(NuGetFramework framework) - { - return WithFramework(framework.GetShortFolderName()); - } + public PublishCommand WithFramework(NuGetFramework framework) => WithFramework(framework.GetShortFolderName()); public PublishCommand WithOutput(string output) { @@ -62,15 +59,12 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return base.ExecuteWithCapturedOutput(args); } - private string BuildArgs() - { - return string.Join(" ", + private string BuildArgs() => string.Join(" ", FrameworkOption, OutputOption, TargetOption, RuntimeOption, SelfContainedOption); - } private string FrameworkOption => string.IsNullOrEmpty(_framework) ? "" : $"-f {_framework}"; diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/StoreCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/StoreCommand.cs index a933a043b..65e528761 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/StoreCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/StoreCommand.cs @@ -28,10 +28,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return this; } - public StoreCommand WithFramework(NuGetFramework framework) - { - return WithFramework(framework.GetShortFolderName()); - } + public StoreCommand WithFramework(NuGetFramework framework) => WithFramework(framework.GetShortFolderName()); public StoreCommand WithOutput(string output) { @@ -69,16 +66,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return base.ExecuteWithCapturedOutput(args); } - private string BuildArgs() - { - return string.Join(" ", + private string BuildArgs() => string.Join(" ", ProfileProjectOption, FrameworkOption, OutputOption, IntermediateWorkingDirectoryOption, RuntimeOption, FrameworkVersionOption); - } private string ProfileProjectOption => string.Join(" ", _profileProject) ; diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs index 0ac0ce5cf..d6c80efc0 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs @@ -48,10 +48,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities CurrentProcess.KillTree(); } - public virtual CommandResult Execute(string args = "") - { - return Task.Run(async () => await ExecuteAsync(args)).Result; - } + public virtual CommandResult Execute(string args = "") => Task.Run(async () => await ExecuteAsync(args)).Result; public async virtual Task ExecuteAsync(string args = "") { @@ -194,14 +191,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities } } - private string GetBaseDirectory() - { + private string GetBaseDirectory() => #if NET451 return AppDomain.CurrentDomain.BaseDirectory; #else - return AppContext.BaseDirectory; + AppContext.BaseDirectory; #endif - } + private void ResolveCommand(ref string executable, ref string args) { diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/ToolCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/ToolCommand.cs index 3a3589f73..d9099cd32 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/ToolCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/ToolCommand.cs @@ -7,14 +7,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { public sealed class ToolCommand : DotnetCommand { - public override CommandResult Execute(string args = "") - { - return base.Execute($"tool {args}"); - } + public override CommandResult Execute(string args = "") => base.Execute($"tool {args}"); - public override CommandResult ExecuteWithCapturedOutput(string args = "") - { - return base.ExecuteWithCapturedOutput($"tool {args}"); - } + public override CommandResult ExecuteWithCapturedOutput(string args = "") => base.ExecuteWithCapturedOutput($"tool {args}"); } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Extensions/DirectoryInfoExtensions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Extensions/DirectoryInfoExtensions.cs index edcb9071f..7366a4153 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Extensions/DirectoryInfoExtensions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Extensions/DirectoryInfoExtensions.cs @@ -7,20 +7,11 @@ namespace Microsoft.DotNet.TestFramework { internal static class DirectoryInfoExtensions { - public static bool Contains(this DirectoryInfo subject, FileSystemInfo target) - { - return target.FullName.StartsWith(subject.FullName); - } + public static bool Contains(this DirectoryInfo subject, FileSystemInfo target) => target.FullName.StartsWith(subject.FullName); - public static DirectoryInfo GetDirectory(this DirectoryInfo subject, params string [] directoryNames) - { - return new DirectoryInfo(Path.Combine(subject.FullName, Path.Combine(directoryNames))); - } + public static DirectoryInfo GetDirectory(this DirectoryInfo subject, params string[] directoryNames) => new DirectoryInfo(Path.Combine(subject.FullName, Path.Combine(directoryNames))); - public static FileInfo GetFile(this DirectoryInfo subject, string fileName) - { - return new FileInfo(Path.Combine(subject.FullName, fileName)); - } + public static FileInfo GetFile(this DirectoryInfo subject, string fileName) => new FileInfo(Path.Combine(subject.FullName, fileName)); public static void EnsureExistsAndEmpty(this DirectoryInfo subject) { diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Extensions/ProcessExtensions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Extensions/ProcessExtensions.cs index 565cac435..26287171a 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Extensions/ProcessExtensions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Extensions/ProcessExtensions.cs @@ -19,10 +19,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities #endif private static readonly TimeSpan _defaultTimeout = TimeSpan.FromSeconds(30); - public static void KillTree(this Process process) - { - process.KillTree(_defaultTimeout); - } + public static void KillTree(this Process process) => process.KillTree(_defaultTimeout); public static void KillTree(this Process process, TimeSpan timeout) { diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/FileNameUtilities.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/FileNameUtilities.cs index e2e63d4a6..5623cb98c 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/FileNameUtilities.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/FileNameUtilities.cs @@ -25,10 +25,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities /// /// True if is a simple file name, false if it is null or includes a directory specification. /// - internal static bool IsFileName(string path) - { - return IndexOfFileName(path) == 0; - } + internal static bool IsFileName(string path) => IndexOfFileName(path) == 0; /// /// Returns the offset in where the dot that starts an extension is, or -1 if the path doesn't have an extension. diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/PathUtilities.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/PathUtilities.cs index 9bf35d851..e27f30c8e 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/PathUtilities.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/PathUtilities.cs @@ -21,10 +21,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities private static bool IsUnixLikePlatform => Path.DirectorySeparatorChar == '/'; - internal static bool IsDirectorySeparator(char c) - { - return c == DirectorySeparatorChar || c == AltDirectorySeparatorChar; - } + internal static bool IsDirectorySeparator(char c) => c == DirectorySeparatorChar || c == AltDirectorySeparatorChar; internal static string TrimTrailingSeparators(string s) { @@ -42,25 +39,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return s; } - internal static string GetExtension(string path) - { - return FileNameUtilities.GetExtension(path); - } + internal static string GetExtension(string path) => FileNameUtilities.GetExtension(path); - internal static string ChangeExtension(string path, string extension) - { - return FileNameUtilities.ChangeExtension(path, extension); - } + internal static string ChangeExtension(string path, string extension) => FileNameUtilities.ChangeExtension(path, extension); - internal static string RemoveExtension(string path) - { - return FileNameUtilities.ChangeExtension(path, extension: null); - } + internal static string RemoveExtension(string path) => FileNameUtilities.ChangeExtension(path, extension: null); - internal static string GetFileName(string path) - { - return FileNameUtilities.GetFileName(path); - } + internal static string GetFileName(string path) => FileNameUtilities.GetFileName(path); /// /// Get directory name from path. diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempDirectory.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempDirectory.cs index f98150ada..46c048163 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempDirectory.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempDirectory.cs @@ -105,14 +105,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return new TempDirectory(dirPath, _root); } - public void SetCurrentDirectory() - { - Directory.SetCurrentDirectory(_path); - } - - public override string ToString() - { - return _path; - } + public void SetCurrentDirectory() => Directory.SetCurrentDirectory(_path); + + public override string ToString() => _path; } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempFile.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempFile.cs index 001e23bc4..6b328e7d4 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempFile.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempFile.cs @@ -50,11 +50,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities } } } - - public FileStream Open(FileAccess access = FileAccess.ReadWrite) - { - return new FileStream(_path, FileMode.Open, access); - } + + public FileStream Open(FileAccess access = FileAccess.ReadWrite) => new FileStream(_path, FileMode.Open, access); public string Path => _path; @@ -79,12 +76,9 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return this; } - - public Task WriteAllTextAsync(string content) - { - return WriteAllTextAsync(content, Encoding.UTF8); - } - + + public Task WriteAllTextAsync(string content) => WriteAllTextAsync(content, Encoding.UTF8); + public TempFile WriteAllBytes(byte[] content) { File.WriteAllBytes(_path, content); @@ -96,20 +90,11 @@ namespace Microsoft.DotNet.Tools.Test.Utilities content.WriteToFile(_path); return this; } - - public string ReadAllText() - { - return File.ReadAllText(_path); - } - - public TempFile CopyContentFrom(string path) - { - return WriteAllBytes(File.ReadAllBytes(path)); - } - - public override string ToString() - { - return _path; - } + + public string ReadAllText() => File.ReadAllText(_path); + + public TempFile CopyContentFrom(string path) => WriteAllBytes(File.ReadAllBytes(path)); + + public override string ToString() => _path; } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempRoot.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempRoot.cs index 58e426b47..f74611188 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempRoot.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempRoot.cs @@ -61,12 +61,9 @@ namespace Microsoft.DotNet.Tools.Test.Utilities _temps.Add(dir); return dir; } - - public TempFile CreateFile(string prefix = null, string extension = null, string directory = null, [CallerFilePath]string callerSourcePath = null, [CallerLineNumber]int callerLineNumber = 0) - { - return AddFile(new DisposableFile(prefix, extension, directory, callerSourcePath, callerLineNumber)); - } - + + public TempFile CreateFile(string prefix = null, string extension = null, string directory = null, [CallerFilePath] string callerSourcePath = null, [CallerLineNumber] int callerLineNumber = 0) => AddFile(new DisposableFile(prefix, extension, directory, callerSourcePath, callerLineNumber)); + public DisposableFile AddFile(DisposableFile file) { _temps.Add(file); diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssetInfo.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssetInfo.cs index 15693244c..6de2d1442 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssetInfo.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssetInfo.cs @@ -68,10 +68,7 @@ namespace Microsoft.DotNet.TestFramework .Where(f => !FilesToExclude.Contains(f.Name)); } - private DirectoryInfo GetTestDestinationDirectory(string callingMethod, string identifier) - { - return _testAssets.CreateTestDirectory(AssetName, callingMethod, identifier); - } + private DirectoryInfo GetTestDestinationDirectory(string callingMethod, string identifier) => _testAssets.CreateTestDirectory(AssetName, callingMethod, identifier); private void ThrowIfTestAssetDoesNotExist() { diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssetInstance.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssetInstance.cs index 0912ae58b..128fed416 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssetInstance.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssetInstance.cs @@ -129,10 +129,7 @@ namespace Microsoft.DotNet.TestFramework return this; } - public TestAssetInstance WithProjectChanges(Action xmlAction) - { - return WithProjectChanges((path, project) => xmlAction(project)); - } + public TestAssetInstance WithProjectChanges(Action xmlAction) => WithProjectChanges((path, project) => xmlAction(project)); public TestAssetInstance WithProjectChanges(Action xmlAction) { @@ -211,10 +208,7 @@ namespace Microsoft.DotNet.TestFramework } } - private IEnumerable GetProjectFiles() - { - return Root.GetFiles(TestAssetInfo.ProjectFilePattern, SearchOption.AllDirectories); - } + private IEnumerable GetProjectFiles() => Root.GetFiles(TestAssetInfo.ProjectFilePattern, SearchOption.AllDirectories); private void Restore(FileInfo projectFile) { diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssets.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssets.cs index 8b66b6ac5..a8601dd15 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssets.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssets.cs @@ -49,10 +49,7 @@ namespace Microsoft.DotNet.TestFramework _testWorkingFolder = testWorkingFolder; } - public TestAssetInfo Get(string name) - { - return Get(TestAssetKinds.TestProjects, name); - } + public TestAssetInfo Get(string name) => Get(TestAssetKinds.TestProjects, name); public TestAssetInfo Get(string kind, string name) { diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/TestBase.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/TestBase.cs index fe949be59..d58541884 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/TestBase.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/TestBase.cs @@ -58,10 +58,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { } - public static string GetUniqueName() - { - return Guid.NewGuid().ToString("D"); - } + public static string GetUniqueName() => Guid.NewGuid().ToString("D"); public TempRoot Temp { @@ -126,15 +123,9 @@ namespace Microsoft.DotNet.Tools.Test.Utilities string outputDir, string executableName, string expectedOutput, - bool native = false) - { - TestExecutable(GetCompilationOutputPath(outputDir, native), executableName, expectedOutput); - } + bool native = false) => TestExecutable(GetCompilationOutputPath(outputDir, native), executableName, expectedOutput); - protected void TestNativeOutputExecutable(string outputDir, string executableName, string expectedOutput) - { - TestOutputExecutable(outputDir, executableName, expectedOutput, true); - } + protected void TestNativeOutputExecutable(string outputDir, string executableName, string expectedOutput) => TestOutputExecutable(outputDir, executableName, expectedOutput, true); protected string GetCompilationOutputPath(string outputDir, bool native) {