diff --git a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/FileSystemAbstractionBenchmarks.cs b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/FileSystemAbstractionBenchmarks.cs
index e5babe4dd..17b002e48 100644
--- a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/FileSystemAbstractionBenchmarks.cs
+++ b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/FileSystemAbstractionBenchmarks.cs
@@ -1,6 +1,4 @@
-using System;
-using System.IO;
-using System.IO.Abstractions.Benchmarks.Support;
+using System.IO.Abstractions.Benchmarks.Support;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Order;
@@ -13,36 +11,34 @@ namespace System.IO.Abstractions.Benchmarks;
[RankColumn]
public class FileSystemAbstractionBenchmarks
{
- #region Members
///
/// FileSupport type to avoid counting object initialisation on the benchmark
///
- private FileSupport _fileSupport;
- private DirectorySupport _directorySupport;
- #endregion
+ private readonly FileSupport _fileSupport;
+ private readonly DirectorySupport _directorySupport;
+
+ private readonly string _path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
- #region CTOR's
public FileSystemAbstractionBenchmarks()
{
// Initialize file support
_fileSupport = new FileSupport();
_directorySupport = new DirectorySupport();
}
- #endregion
#region File IsFile
[Benchmark]
- public void FileExists_DotNet() => FileSupportStatic.IsFile(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
+ public void FileExists_DotNet() => FileSupportStatic.IsFile(_path);
[Benchmark]
- public void FileExists_Abstraction() => _fileSupport.IsFile(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
+ public void FileExists_Abstraction() => _fileSupport.IsFile(_path);
#endregion
#region Directory Exists
[Benchmark]
- public void DirectoryExists_DotNet() => DirectorySupportStatic.Exists(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
+ public void DirectoryExists_DotNet() => DirectorySupportStatic.Exists(_path);
[Benchmark]
- public void DirectoryExists_Abstraction() => _directorySupport.Exists(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
+ public void DirectoryExists_Abstraction() => _directorySupport.Exists(_path);
#endregion
}
\ No newline at end of file
diff --git a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/MockFileSystemBenchmarks.cs b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/MockFileSystemBenchmarks.cs
index 8dce631fe..df2a85038 100644
--- a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/MockFileSystemBenchmarks.cs
+++ b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/MockFileSystemBenchmarks.cs
@@ -22,5 +22,5 @@ private static Dictionary CreateTestData()
}
[Benchmark]
- public MockFileSystem MockFileSystem_Constructor() => new MockFileSystem(testData);
+ public MockFileSystem MockFileSystem_Constructor() => new(testData);
}
\ No newline at end of file
diff --git a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Program.cs b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Program.cs
index bb1b65c50..028896dc1 100644
--- a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Program.cs
+++ b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Program.cs
@@ -1,9 +1,8 @@
namespace System.IO.Abstractions.Benchmarks;
using BenchmarkDotNet.Running;
-using System.Reflection;
-class Program
+static class Program
{
public static void Main(string[] args)
{
diff --git a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/DirectorySupport.cs b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/DirectorySupport.cs
index 02ca8d8ec..53ef219f8 100644
--- a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/DirectorySupport.cs
+++ b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/DirectorySupport.cs
@@ -1,16 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace System.IO.Abstractions.Benchmarks.Support;
+namespace System.IO.Abstractions.Benchmarks.Support;
public class DirectorySupport
{
- #region Members
- private IFileSystem _fileSystem;
- #endregion
+ private readonly IFileSystem _fileSystem;
- #region CTOR's
public DirectorySupport(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
@@ -20,22 +13,20 @@ public DirectorySupport() : this(new FileSystem())
{
// Default implementation for FileSystem
}
- #endregion
- #region Methods
public bool IsDirectory(string path)
{
return _fileSystem.Directory.Exists(path);
}
- private string GetRandomTempDirectory()
+ private static string GetRandomTempDirectory()
{
return Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
}
public string CreateRandomDirectory()
{
- var randomPath = this.GetRandomTempDirectory();
+ var randomPath = GetRandomTempDirectory();
_fileSystem.Directory.CreateDirectory(randomPath);
return randomPath;
}
@@ -89,5 +80,4 @@ public bool Exists(string directory)
{
return _fileSystem.Directory.Exists(directory);
}
- #endregion
}
\ No newline at end of file
diff --git a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/DirectorySupportStatic.cs b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/DirectorySupportStatic.cs
index a0c1fcdfe..bb610f014 100644
--- a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/DirectorySupportStatic.cs
+++ b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/DirectorySupportStatic.cs
@@ -2,7 +2,6 @@
public static class DirectorySupportStatic
{
- #region Methods
public static bool IsDirectory(string path)
{
return Directory.Exists(path);
@@ -67,5 +66,4 @@ public static void CreateIfNotExists(string directory)
}
public static bool Exists(string directory) => Directory.Exists(directory);
- #endregion
}
\ No newline at end of file
diff --git a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/FileSupport.cs b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/FileSupport.cs
index 1bece8d0b..b075f61e1 100644
--- a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/FileSupport.cs
+++ b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/FileSupport.cs
@@ -1,16 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace System.IO.Abstractions.Benchmarks.Support;
+namespace System.IO.Abstractions.Benchmarks.Support;
public class FileSupport
{
- #region Members
- private IFileSystem _fileSystem;
- #endregion
+ private readonly IFileSystem _fileSystem;
- #region CTOR's
public FileSupport(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
@@ -20,10 +13,8 @@ public FileSupport() : this(new FileSystem())
{
// Default implementation for FileSystem
}
- #endregion
- #region Methods
- public string GetRandomTempFile()
+ private static string GetRandomTempFile()
{
return Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
}
@@ -44,5 +35,4 @@ public void DeleteIfExists(string filePath)
_fileSystem.File.Delete(filePath);
}
}
- #endregion
}
\ No newline at end of file
diff --git a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/FileSupportStatic.cs b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/FileSupportStatic.cs
index 83b44c4d2..b8eae68e9 100644
--- a/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/FileSupportStatic.cs
+++ b/benchmarks/TestableIO.System.IO.Abstractions.Benchmarks/Support/FileSupportStatic.cs
@@ -1,6 +1,4 @@
-using System.IO;
-
-namespace System.IO.Abstractions.Benchmarks.Support;
+namespace System.IO.Abstractions.Benchmarks.Support;
public static class FileSupportStatic
{