Applied expression bodies for methods to solution.
This commit is contained in:
parent
c9ab438e6c
commit
67cbc0dd65
36 changed files with 106 additions and 378 deletions
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
||||
/// <summary>
|
||||
/// 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);
|
||||
|
||||
/// <summary>
|
||||
/// The test checks if the template creates the template for correct framework by default.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<StringAssertions> BeVisuallyEquivalentTo(this StringAssertions assertions, string expected, string because = "", params object[] becauseArgs)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}";
|
||||
|
||||
|
|
|
@ -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) ;
|
||||
|
||||
|
|
|
@ -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<CommandResult> 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)
|
||||
{
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -25,10 +25,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
/// <returns>
|
||||
/// True if <paramref name="path"/> is a simple file name, false if it is null or includes a directory specification.
|
||||
/// </returns>
|
||||
internal static bool IsFileName(string path)
|
||||
{
|
||||
return IndexOfFileName(path) == 0;
|
||||
}
|
||||
internal static bool IsFileName(string path) => IndexOfFileName(path) == 0;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the offset in <paramref name="path"/> where the dot that starts an extension is, or -1 if the path doesn't have an extension.
|
||||
|
|
|
@ -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);
|
||||
|
||||
/// <summary>
|
||||
/// Get directory name from path.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<TempFile> WriteAllTextAsync(string content)
|
||||
{
|
||||
return WriteAllTextAsync(content, Encoding.UTF8);
|
||||
}
|
||||
|
||||
|
||||
public Task<TempFile> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -129,10 +129,7 @@ namespace Microsoft.DotNet.TestFramework
|
|||
return this;
|
||||
}
|
||||
|
||||
public TestAssetInstance WithProjectChanges(Action<XDocument> xmlAction)
|
||||
{
|
||||
return WithProjectChanges((path, project) => xmlAction(project));
|
||||
}
|
||||
public TestAssetInstance WithProjectChanges(Action<XDocument> xmlAction) => WithProjectChanges((path, project) => xmlAction(project));
|
||||
|
||||
public TestAssetInstance WithProjectChanges(Action<string, XDocument> xmlAction)
|
||||
{
|
||||
|
@ -211,10 +208,7 @@ namespace Microsoft.DotNet.TestFramework
|
|||
}
|
||||
}
|
||||
|
||||
private IEnumerable<FileInfo> GetProjectFiles()
|
||||
{
|
||||
return Root.GetFiles(TestAssetInfo.ProjectFilePattern, SearchOption.AllDirectories);
|
||||
}
|
||||
private IEnumerable<FileInfo> GetProjectFiles() => Root.GetFiles(TestAssetInfo.ProjectFilePattern, SearchOption.AllDirectories);
|
||||
|
||||
private void Restore(FileInfo projectFile)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue