From b98387dc042a653e9d0b9e56ad7cdccc884a44fa Mon Sep 17 00:00:00 2001 From: rameel Date: Fri, 1 Aug 2025 00:46:30 +0500 Subject: [PATCH 1/6] Rename private static field to use 's_' prefix --- .../VirtualFileExtensions.cs | 4 ++-- src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs b/src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs index 10ea1d7..7847427 100644 --- a/src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs +++ b/src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs @@ -8,12 +8,12 @@ namespace Ramstack.FileSystem; /// public static class VirtualFileExtensions { - private static Encoding? _utf8NoBom; + private static Encoding? s_utf8NoBom; /// /// Gets an instance of UTF8 encoding without BOM. /// - private static Encoding Utf8NoBom => _utf8NoBom ??= new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); + private static Encoding Utf8NoBom => s_utf8NoBom ??= new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); /// /// Asynchronously returns a with diff --git a/src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs b/src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs index 2476776..5c31785 100644 --- a/src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs +++ b/src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs @@ -15,7 +15,7 @@ internal sealed class PhysicalDirectory : VirtualDirectory /// including system and hidden files, not recurse through subdirectories, /// and ignore inaccessible files. /// - private static readonly EnumerationOptions DefaultOptions = new() + private static readonly EnumerationOptions s_defaultOptions = new() { AttributesToSkip = 0, RecurseSubdirectories = false, @@ -85,7 +85,7 @@ protected override IAsyncEnumerable GetFileNodesCoreAsync(Cancellat // its existence was checked. var nodes = Directory.Exists(_physicalPath) - ? new FileSystemEnumerable(_physicalPath, FindTransform, DefaultOptions) + ? new FileSystemEnumerable(_physicalPath, FindTransform, s_defaultOptions) : Enumerable.Empty(); return nodes.ToAsyncEnumerable(); @@ -108,7 +108,7 @@ protected override IAsyncEnumerable GetFilesCoreAsync(CancellationT if (Directory.Exists(_physicalPath)) { - nodes = new FileSystemEnumerable(_physicalPath, FindTransform, DefaultOptions) + nodes = new FileSystemEnumerable(_physicalPath, FindTransform, s_defaultOptions) { ShouldIncludePredicate = (ref FileSystemEntry entry) => !entry.IsDirectory }; @@ -134,7 +134,7 @@ protected override IAsyncEnumerable GetDirectoriesCoreAsync(Ca if (Directory.Exists(_physicalPath)) { - nodes = new FileSystemEnumerable(_physicalPath, FindTransform, DefaultOptions) + nodes = new FileSystemEnumerable(_physicalPath, FindTransform, s_defaultOptions) { ShouldIncludePredicate = (ref FileSystemEntry entry) => entry.IsDirectory }; From b8d4360303c05ee833a489a193778d38bb9fe55e Mon Sep 17 00:00:00 2001 From: rameel Date: Fri, 1 Aug 2025 00:47:32 +0500 Subject: [PATCH 2/6] Fix typo --- src/Ramstack.FileSystem.Abstractions/README.md | 2 +- src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs | 2 +- .../VirtualFileSystemExtensions.cs | 2 +- src/Ramstack.FileSystem.Azure/AzureFileSystem.cs | 2 +- src/Ramstack.FileSystem.Physical/PhysicalFile.cs | 4 ++-- src/Ramstack.FileSystem.Prefixed/PrefixedFileSystem.cs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Ramstack.FileSystem.Abstractions/README.md b/src/Ramstack.FileSystem.Abstractions/README.md index 1cd9524..2704042 100644 --- a/src/Ramstack.FileSystem.Abstractions/README.md +++ b/src/Ramstack.FileSystem.Abstractions/README.md @@ -83,7 +83,7 @@ Console.WriteLine(await reader.ReadToEndAsync()); ### VirtualDirectory -The `VirtualDirectory` class provides properties and methods for creating, deleting, and enumerating directories and subdirectories. +The `VirtualDirectory` class provides properties and methods for creating, deleting and enumerating directories and subdirectories. ```csharp public static async Task PrintFilesAsync(VirtualDirectory directory, string padding = "", CancellationToken cancellationToken = default) diff --git a/src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs b/src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs index 7847427..1a3aad4 100644 --- a/src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs +++ b/src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs @@ -279,7 +279,7 @@ public static ValueTask WriteAllTextAsync(this VirtualFile file, string contents WriteAllTextAsync(file, contents.AsMemory(), encoding, cancellationToken); /// - /// Asynchronously writes the specified string to current the file. If the file already exists, it is truncated and overwritten. + /// Asynchronously writes the specified string to the current file. If the file already exists, it is truncated and overwritten. /// /// The file to write to. /// The contents to write to the file. diff --git a/src/Ramstack.FileSystem.Abstractions/VirtualFileSystemExtensions.cs b/src/Ramstack.FileSystem.Abstractions/VirtualFileSystemExtensions.cs index ff7a441..270531a 100644 --- a/src/Ramstack.FileSystem.Abstractions/VirtualFileSystemExtensions.cs +++ b/src/Ramstack.FileSystem.Abstractions/VirtualFileSystemExtensions.cs @@ -189,7 +189,7 @@ public static ValueTask WriteAllTextAsync(this IVirtualFileSystem fs, string pat fs.GetFile(path).WriteAllTextAsync(contents, encoding, cancellationToken); /// - /// Asynchronously writes the specified string to specified the file. If the file already exists, it is truncated and overwritten. + /// Asynchronously writes the specified string to the specified the file. If the file already exists, it is truncated and overwritten. /// /// The file system to use. /// The file to write to. diff --git a/src/Ramstack.FileSystem.Azure/AzureFileSystem.cs b/src/Ramstack.FileSystem.Azure/AzureFileSystem.cs index f34146c..2860e38 100644 --- a/src/Ramstack.FileSystem.Azure/AzureFileSystem.cs +++ b/src/Ramstack.FileSystem.Azure/AzureFileSystem.cs @@ -118,7 +118,7 @@ public ValueTask CreateContainerAsync(CancellationToken cancellationToken = defa /// /// /// : Specifies full public read access for both the container and blob data. - /// Clients can enumerate blobs within the container via anonymous requests, but cannot enumerate containers within the storage account. + /// Clients can enumerate blobs within the container via anonymous requests but cannot enumerate containers within the storage account. /// /// /// diff --git a/src/Ramstack.FileSystem.Physical/PhysicalFile.cs b/src/Ramstack.FileSystem.Physical/PhysicalFile.cs index 99b885e..d648470 100644 --- a/src/Ramstack.FileSystem.Physical/PhysicalFile.cs +++ b/src/Ramstack.FileSystem.Physical/PhysicalFile.cs @@ -65,7 +65,7 @@ protected override ValueTask OpenWriteCoreAsync(CancellationToken cancel var stream = new FileStream(_physicalPath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, DefaultBufferSize, options); - // Since, FileMode.OpenOrCreate doesn't truncate the file, we manually + // Since FileMode.OpenOrCreate doesn't truncate the file, we manually // set the file length to zero to remove any leftover data. stream.SetLength(0); @@ -90,7 +90,7 @@ protected override async ValueTask WriteCoreAsync(Stream stream, bool overwrite, await using var fs = new FileStream(_physicalPath, fileMode, FileAccess.Write, FileShare.None, DefaultBufferSize, options); - // Since, FileMode.OpenOrCreate doesn't truncate the file, we manually + // Since FileMode.OpenOrCreate doesn't truncate the file, we manually // set the file length to zero to remove any leftover data. fs.SetLength(0); diff --git a/src/Ramstack.FileSystem.Prefixed/PrefixedFileSystem.cs b/src/Ramstack.FileSystem.Prefixed/PrefixedFileSystem.cs index 83bb653..6f1a4b2 100644 --- a/src/Ramstack.FileSystem.Prefixed/PrefixedFileSystem.cs +++ b/src/Ramstack.FileSystem.Prefixed/PrefixedFileSystem.cs @@ -29,7 +29,7 @@ public PrefixedFileSystem(string prefix, IVirtualFileSystem fileSystem) prefix = VirtualPath.Normalize(prefix); (_prefix, _fs) = (prefix, fileSystem); - // Create artificial directory list + // Create an artificial directory list _directories = CreateArtificialDirectories(this, prefix); static VirtualDirectory[] CreateArtificialDirectories(PrefixedFileSystem fs, string path) From 3c63759a7fb7cde0be1e22e9ee428074ede5658e Mon Sep 17 00:00:00 2001 From: rameel Date: Fri, 1 Aug 2025 00:49:01 +0500 Subject: [PATCH 3/6] Fix grammar and phrasing --- .../VirtualFileExtensions.cs | 2 +- src/Ramstack.FileSystem.Abstractions/VirtualPath.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs b/src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs index 1a3aad4..ba52bf5 100644 --- a/src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs +++ b/src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs @@ -11,7 +11,7 @@ public static class VirtualFileExtensions private static Encoding? s_utf8NoBom; /// - /// Gets an instance of UTF8 encoding without BOM. + /// Gets an instance of the without BOM. /// private static Encoding Utf8NoBom => s_utf8NoBom ??= new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); diff --git a/src/Ramstack.FileSystem.Abstractions/VirtualPath.cs b/src/Ramstack.FileSystem.Abstractions/VirtualPath.cs index 9535ccb..d2a700e 100644 --- a/src/Ramstack.FileSystem.Abstractions/VirtualPath.cs +++ b/src/Ramstack.FileSystem.Abstractions/VirtualPath.cs @@ -82,7 +82,7 @@ public static ReadOnlySpan GetExtension(ReadOnlySpan path) /// /// Returns the file name and extension for the specified path. /// - /// The path from which to obtain the file name and extension. + /// The path from which to get the file name and extension. /// /// The file name and extension for the . /// @@ -100,7 +100,7 @@ public static string GetFileName(string path) /// /// Returns the file name and extension for the specified path. /// - /// The path from which to obtain the file name and extension. + /// The path from which to get the file name and extension. /// /// The file name and extension for the . /// @@ -118,7 +118,7 @@ public static ReadOnlySpan GetFileName(ReadOnlySpan path) /// /// The path to retrieve the directory portion from. /// - /// Directory portion for , or an empty string if path denotes a root directory. + /// Directory portion for , or an empty string if the path denotes a root directory. /// public static string GetDirectoryName(string path) { From b0ea3cd018155ccf495cd9a7f4a359239d4b709c Mon Sep 17 00:00:00 2001 From: rameel Date: Fri, 1 Aug 2025 00:49:37 +0500 Subject: [PATCH 4/6] Use 'default' for CancellationToken parameter in WriteAsync --- src/Ramstack.FileSystem.Amazon/S3UploadStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ramstack.FileSystem.Amazon/S3UploadStream.cs b/src/Ramstack.FileSystem.Amazon/S3UploadStream.cs index a63939c..6dc5362 100644 --- a/src/Ramstack.FileSystem.Amazon/S3UploadStream.cs +++ b/src/Ramstack.FileSystem.Amazon/S3UploadStream.cs @@ -124,7 +124,7 @@ public override Task WriteAsync(byte[] buffer, int offset, int count, Cancellati WriteAsync(buffer.AsMemory(offset, count), cancellationToken).AsTask(); /// - public override async ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = new CancellationToken()) + public override async ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default) { try { From 99db22ebbdcfd629b7ec188059040f31ad76eabe Mon Sep 17 00:00:00 2001 From: rameel Date: Fri, 1 Aug 2025 00:51:59 +0500 Subject: [PATCH 5/6] Simplify lambda parameter types --- src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs b/src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs index 5c31785..a2e71c8 100644 --- a/src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs +++ b/src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs @@ -110,7 +110,7 @@ protected override IAsyncEnumerable GetFilesCoreAsync(CancellationT { nodes = new FileSystemEnumerable(_physicalPath, FindTransform, s_defaultOptions) { - ShouldIncludePredicate = (ref FileSystemEntry entry) => !entry.IsDirectory + ShouldIncludePredicate = (ref entry) => !entry.IsDirectory }; } @@ -136,7 +136,7 @@ protected override IAsyncEnumerable GetDirectoriesCoreAsync(Ca { nodes = new FileSystemEnumerable(_physicalPath, FindTransform, s_defaultOptions) { - ShouldIncludePredicate = (ref FileSystemEntry entry) => entry.IsDirectory + ShouldIncludePredicate = (ref entry) => entry.IsDirectory }; } From 243f40c176a813a7c223be025809e7c7ed6da2f2 Mon Sep 17 00:00:00 2001 From: rameel Date: Fri, 1 Aug 2025 00:52:37 +0500 Subject: [PATCH 6/6] Simplify expression in Debug.Assert --- src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs b/src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs index a2e71c8..fe646d8 100644 --- a/src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs +++ b/src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs @@ -118,7 +118,7 @@ protected override IAsyncEnumerable GetFilesCoreAsync(CancellationT VirtualFile FindTransform(ref FileSystemEntry entry) { - Debug.Assert(entry.IsDirectory == false); + Debug.Assert(!entry.IsDirectory); var fullName = VirtualPath.Join(FullName, entry.FileName); var physicalPath = entry.ToFullPath();