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
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue