From d4eb9be3fe7f9db14519b653755d446ccee933c9 Mon Sep 17 00:00:00 2001 From: rameel Date: Thu, 2 Apr 2026 04:20:11 +0500 Subject: [PATCH 1/2] Refine README files --- README.md | 36 +++++++++---------- .../README.md | 6 ++-- .../README.md | 2 +- src/Ramstack.FileProviders.Globbing/README.md | 4 +-- src/Ramstack.FileProviders/README.md | 16 ++++----- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 1b06bbe..b93c21c 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,11 @@ building upon `Microsoft.Extensions.FileProviders`. ## Projects -This repository contains projects: +This repository contains the following projects: ### Ramstack.FileProviders.Extensions -Offers useful and convenient extensions for `IFileProviders`, bringing its capabilities and experience -closer to what's provided by the `DirectoryInfo` and `FileInfo` standard classes. +Offers useful and convenient extensions for `IFileProvider`, bringing its capabilities and experience +closer to what's provided by the `DirectoryInfo` and `FileInfo` classes. To install the `Ramstack.FileProviders.Extensions` [NuGet package](https://www.nuget.org/packages/Ramstack.FileProviders.Extensions) in your project, run the following command: @@ -87,12 +87,12 @@ This is useful when you need to organize files in a virtual hierarchy. Example: ```csharp -IFileProvider provider = new PrefixedFileProvider(innerProvider, "/project/app"); +IFileProvider provider = new PrefixedFileProvider("/project/app", innerProvider); IFileInfo file = provider.GetFileInfo("/project/app/docs/README"); Console.WriteLine(file.Exists); ``` -This is how you can add virtual directories to your project that are external to the project root: +This is how you can add virtual directories to your project that are outside the project root: ```csharp string packagesPath = Path.Combine(environment.ContentRootPath, "../Packages"); string themesPath = Path.Combine(environment.ContentRootPath, "../Themes"); @@ -129,11 +129,11 @@ as if they were originally defined within your project. ├── Models ├── Views ├── Packages <-- (virtual) -│ ├── package1 -│ └── package2 +│ ├── package-1 +│ └── package-2 ├── Themes <-- (virtual) -│ ├── theme1 -│ └── theme2 +│ ├── theme-1 +│ └── theme-2 └── wwwroot ``` @@ -143,29 +143,29 @@ as if they were originally defined within your project. Example: ```csharp -IFileProvider provider = new SubFileProvider(innerProvider, "/docs"); +IFileProvider provider = new SubFileProvider("/docs", innerProvider); IFileInfo file = provider.GetFileInfo("/README"); Console.WriteLine(file.Exists); ``` ### Ramstack.FileProviders.Globbing -`GlobbingFileProvider` class filters files using include and/or exclude glob patterns. Include patterns make only matching files visible, +The `GlobbingFileProvider` class filters files using include and/or exclude glob patterns. Include patterns make only matching files visible, while exclude patterns hide specific files. Both include and exclude patterns can be combined for flexible file visibility control. It relies on the [Ramstack.Globbing](https://www.nuget.org/packages/Ramstack.Globbing) package for its globbing capabilities. Example: ```csharp -IFileProvider provider = new GlobbingFileProvider(innerProvider, patterns: ["**/*.txt", "docs/*.md" ], excludes: ["**/README.md"]); +IFileProvider provider = new GlobbingFileProvider(innerProvider, patterns: ["**/*.txt", "docs/*.md"], excludes: ["**/README.md"]); foreach (IFileInfo file in provider.GetDirectoryContents("/")) Console.WriteLine(file.Name); ``` ### Ramstack.FileProviders.Extensions -Provides useful extensions for `IFileProvider`, bringing its capabilities and experience closer to what's being -provided by `DirectoryInfo` and `FileInfo` classes. +Provides useful extensions for `IFileProvider`, bringing its capabilities and experience closer to what's +provided by the `DirectoryInfo` and `FileInfo` classes. Simply stated, a `FileNode` knows which directory it is located in, and a directory represented by the `DirectoryNode` class can access its parent directory and list all files within it, recursively. @@ -242,15 +242,15 @@ builder.Environment.ContentRootFileProvider = FileProviderComposer.FlattenProvid #### Composing Providers The `ComposeProviders` method combines a list of `IFileProvider` instances into a single `IFileProvider`. -During this process, all encountered `CompositeFileProvider` instances recursively flattened and merged into a single level. -This eliminates unnecessary indirectness and streamline the file provider hierarchy. +During this process, all encountered `CompositeFileProvider` instances are recursively flattened and merged into a single level. +This eliminates unnecessary indirectness and streamlines the file provider hierarchy. ```csharp string packagesPath = Path.Combine(environment.ContentRootPath, "../Packages"); string themesPath = Path.Combine(environment.ContentRootPath, "../Themes"); environment.ContentRootFileProvider = FileProviderComposer.ComposeProviders( - // Inject external Modules directory + // Inject external Packages directory new PrefixedFileProvider("/Packages", new PhysicalFileProvider(packagesPath)), // Inject external Themes directory @@ -261,7 +261,7 @@ environment.ContentRootFileProvider = FileProviderComposer.ComposeProviders( ``` In this example, the `ComposeProviders` method handles any unnecessary nesting that might occur, including when the current -`environment.ContentRootFileProvider` is a `CompositeFileProvider`. This ensures that all file providers merged into a single +`environment.ContentRootFileProvider` is a `CompositeFileProvider`. This ensures that all file providers are merged into a single flat structure, avoiding unnecessary indirectness. #### Flattening Change Tokens diff --git a/src/Ramstack.FileProviders.Composition/README.md b/src/Ramstack.FileProviders.Composition/README.md index 542469b..c080ae5 100644 --- a/src/Ramstack.FileProviders.Composition/README.md +++ b/src/Ramstack.FileProviders.Composition/README.md @@ -31,15 +31,15 @@ builder.Environment.ContentRootFileProvider = FileProviderComposer.FlattenProvid ## Composing Providers The `ComposeProviders` method combines a list of `IFileProvider` instances into a single `IFileProvider`. -During this process, all encountered `CompositeFileProvider` instances recursively flattened and merged into a single level. -This eliminates unnecessary indirectness and streamline the file provider hierarchy. +During this process, all encountered `CompositeFileProvider` instances are recursively flattened and merged into a single level. +This eliminates unnecessary indirectness and streamlines the file provider hierarchy. ```csharp string packagesPath = Path.Combine(environment.ContentRootPath, "../Packages"); string themesPath = Path.Combine(environment.ContentRootPath, "../Themes"); environment.ContentRootFileProvider = FileProviderComposer.ComposeProviders( - // Inject external Modules directory + // Inject external Packages directory new PrefixedFileProvider("/Packages", new PhysicalFileProvider(packagesPath)), // Inject external Themes directory diff --git a/src/Ramstack.FileProviders.Extensions/README.md b/src/Ramstack.FileProviders.Extensions/README.md index 37a2f27..b3eb069 100644 --- a/src/Ramstack.FileProviders.Extensions/README.md +++ b/src/Ramstack.FileProviders.Extensions/README.md @@ -16,7 +16,7 @@ dotnet add package Ramstack.FileProviders.Extensions ## Overview The library provides useful extensions for `IFileProvider`, bringing its capabilities and experience -closer to what's being provided by `DirectoryInfo` and `FileInfo` classes. +closer to what's provided by the `DirectoryInfo` and `FileInfo` classes. Simply stated, a `FileNode` knows which directory it is located in, and a directory represented by the `DirectoryNode` class can access its parent directory and list all files within it, recursively. diff --git a/src/Ramstack.FileProviders.Globbing/README.md b/src/Ramstack.FileProviders.Globbing/README.md index 4e4896b..f0c91f5 100644 --- a/src/Ramstack.FileProviders.Globbing/README.md +++ b/src/Ramstack.FileProviders.Globbing/README.md @@ -14,14 +14,14 @@ dotnet add package Ramstack.FileProviders.Globbing ``` ## GlobbingFileProvider -`GlobbingFileProvider` class filters files using include and/or exclude glob patterns. Include patterns make only matching files visible, +The `GlobbingFileProvider` class filters files using include and/or exclude glob patterns. Include patterns make only matching files visible, while exclude patterns hide specific files. Both include and exclude patterns can be combined for flexible file visibility control. It relies on the [Ramstack.Globbing](https://www.nuget.org/packages/Ramstack.Globbing) package for its globbing capabilities. Example: ```csharp -IFileProvider provider = new GlobbingFileProvider(innerProvider, patterns: ["**/*.txt", "docs/*.md" ], excludes: ["**/README.md"]); +IFileProvider provider = new GlobbingFileProvider(innerProvider, patterns: ["**/*.txt", "docs/*.md"], excludes: ["**/README.md"]); foreach (IFileInfo file in provider.GetDirectoryContents("/")) Console.WriteLine(file.Name); ``` diff --git a/src/Ramstack.FileProviders/README.md b/src/Ramstack.FileProviders/README.md index 5118256..f80248d 100644 --- a/src/Ramstack.FileProviders/README.md +++ b/src/Ramstack.FileProviders/README.md @@ -2,7 +2,7 @@ [![NuGet](https://img.shields.io/nuget/v/Ramstack.FileProviders.svg)](https://nuget.org/packages/Ramstack.FileProviders) [![MIT](https://img.shields.io/github/license/rameel/ramstack.fileproviders)](https://github.com/rameel/ramstack.fileproviders/blob/main/LICENSE) -Represents a .NET library that provides additional implementations for `Microsoft.Extensions.FileProviders` including: +Represents a .NET library that provides additional implementations of `IFileProvider` including: - `PrefixedFileProvider` - `SubFileProvider` @@ -22,12 +22,12 @@ This is useful when you need to organize files in a virtual hierarchy. Example: ```csharp -IFileProvider provider = new PrefixedFileProvider(innerProvider, "/project/app"); +IFileProvider provider = new PrefixedFileProvider("/project/app", innerProvider); IFileInfo file = provider.GetFileInfo("/project/app/docs/README"); Console.WriteLine(file.Exists); ``` -This is how you can add virtual directories to your project that are external to the project root: +This is how you can add virtual directories to your project that are outside the project root: ```csharp string packagesPath = Path.Combine(environment.ContentRootPath, "../Packages"); string themesPath = Path.Combine(environment.ContentRootPath, "../Themes"); @@ -64,11 +64,11 @@ as if they were originally defined within your project. ├── Models ├── Views ├── Packages <-- (virtual) -│ ├── package1 -│ └── package2 +│ ├── package-1 +│ └── package-2 ├── Themes <-- (virtual) -│ ├── theme1 -│ └── theme2 +│ ├── theme-1 +│ └── theme-2 └── wwwroot ``` @@ -77,7 +77,7 @@ as if they were originally defined within your project. Example: ```csharp -IFileProvider provider = new SubFileProvider(innerProvider, "/docs"); +IFileProvider provider = new SubFileProvider("/docs", innerProvider); IFileInfo file = provider.GetFileInfo("/README"); Console.WriteLine(file.Exists); ``` From ec1577ea26917de90cfd214e85b2d164685eef57 Mon Sep 17 00:00:00 2001 From: rameel Date: Thu, 2 Apr 2026 04:30:44 +0500 Subject: [PATCH 2/2] Update PrefixedFileProvider comment to reflect '**' logic --- src/Ramstack.FileProviders/PrefixedFileProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ramstack.FileProviders/PrefixedFileProvider.cs b/src/Ramstack.FileProviders/PrefixedFileProvider.cs index f90dbfe..ebbb926 100644 --- a/src/Ramstack.FileProviders/PrefixedFileProvider.cs +++ b/src/Ramstack.FileProviders/PrefixedFileProvider.cs @@ -194,7 +194,7 @@ public void Dispose() => // Strategy: // - Preserve '**' to allow arbitrary depth // - Drop ambiguous intermediate segments - // - Keep only the final segment if it is a file pattern (e.g. '*.js') + // - Keep only the final segment after '**', if any (e.g. '*.js') // // This guarantees: // - No false negatives caused by prefix misalignment