Jeninnet.FileQuery.DependencyInjection
1.2.0
See the version list below for details.
Requires NuGet 6.0.0 or higher.
dotnet add package Jeninnet.FileQuery.DependencyInjection --version 1.2.0
NuGet\Install-Package Jeninnet.FileQuery.DependencyInjection -Version 1.2.0
<PackageReference Include="Jeninnet.FileQuery.DependencyInjection" Version="1.2.0" />
<PackageVersion Include="Jeninnet.FileQuery.DependencyInjection" Version="1.2.0" />
<PackageReference Include="Jeninnet.FileQuery.DependencyInjection" />
paket add Jeninnet.FileQuery.DependencyInjection --version 1.2.0
#r "nuget: Jeninnet.FileQuery.DependencyInjection, 1.2.0"
#:package Jeninnet.FileQuery.DependencyInjection@1.2.0
#addin nuget:?package=Jeninnet.FileQuery.DependencyInjection&version=1.2.0
#tool nuget:?package=Jeninnet.FileQuery.DependencyInjection&version=1.2.0
Jeninnet.FileQuery.DependencyInjection
Dependency Injection bindings for Jeninnet.FileQuery.
✨ Repo Stats
This package integrates the Jeninnet.FileQuery engine into applications using Microsoft.Extensions.DependencyInjection. It registers internal parsing, compilation, and execution services.
Registered engines support the Phase 2 observability surface: async progress snapshots, opt-in match diagnostics, cancellation propagation, and configurable IO recovery strategies.
🚀 Installation
Install the Dependency Injection integration package via NuGet:
dotnet add package Jeninnet.FileQuery.DependencyInjection
🛠️ Usage Example
1. Service Registration
Register the subsystem on startup using ServiceCollectionExtensions.AddFileQuery:
using Microsoft.Extensions.Hosting;
using Jeninnet.FileQuery.DependencyInjection.Extensions;
var builder = Host.CreateApplicationBuilder(args);
// Registers the FileQuery engine and traversal services
builder.Services.AddFileQuery();
using var host = builder.Build();
await host.RunAsync();
2. Service Consumption
Inject IFileQueryEngine into your services:
using Jeninnet.FileQuery;
public sealed class ProjectScanner
{
private readonly IFileQueryEngine _engine;
public ProjectScanner(IFileQueryEngine engine)
{
_engine = engine;
}
public List<string> ScanRepository(string rootDirectory)
{
// Construct the query parameters
var query = FileQuery.From(rootDirectory)
.Where("**", "!src/**/*.cs") // Ignore all except C# in src/
.Build();
// Execute queries using the injected engine
return _engine.Execute(query).ToList();
}
}
3. Progress and Diagnostics with DI
var progress = new Progress<FileQueryProgress>(snapshot =>
{
Console.WriteLine($"{snapshot.EntriesScanned} entries scanned");
});
var diagnostics = new Progress<FileQueryDiagnostic>(entry =>
{
Console.WriteLine($"{entry.RelativePath}: {entry.Outcome}");
});
var query = FileQuery.From(rootDirectory)
.Where("**", "!src/**/*.cs")
.WithDiagnostics(diagnostics)
.WithErrorRecovery(FileQueryErrorRecoveryOptions.Retry(2))
.Build();
await foreach (var file in _engine.ExecuteAsync(query, progress, cancellationToken))
{
Console.WriteLine(file);
}
⚙️ Service Registrations & Lifetimes
Calling AddFileQuery() registers the following components in the container:
| Registered Interface | Concrete Type | Lifetime | Purpose |
|---|---|---|---|
| IFileQueryEngine | FileQueryEngine |
Singleton |
Primary engine executing queries. |
IFileSystem |
FileSystem |
Singleton |
Decoupled platform IO actions. |
ITraversalPlanBuilder |
TraversalPlanBuilder |
Singleton |
Prepares traversal steps. |
ITraversalExecutor |
TraversalExecutor |
Singleton |
Drives physical/virtual path discovery. |
IPatternCompilerRegistry |
PatternCompilerRegistry |
Singleton |
Manages compilers for different dialects. |
PatternInvariantRegistry |
PatternInvariantRegistry |
Singleton |
Regulates dialect checks (e.g., wildcards, ranges). |
PatternPipeline |
PatternPipeline |
Singleton |
Compiles raw inputs to matcher instructions. |
🚫 Limitations
- Singleton Lifetime: Registers matching components as Singletons. If your application requires transient mock filesystems or custom per-request traversal behaviors, register them manually instead of using
AddFileQuery().
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Jeninnet.FileQuery (>= 1.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
See CHANGELOG.md at https://github.com/TarekNajem04/Jeninnet.FileQuery