Problem
ArchiveCommandHandler currently constructs LocalFileEnumerator with _logger as ILogger<LocalFileEnumerator> in src/Arius.Core/Features/ArchiveCommand/ArchiveCommandHandler.cs.
That cast can return null, which suppresses warnings emitted by LocalFileEnumerator when pointer files are unreadable or contain invalid hashes.
More broadly, this is a pattern we should treat as suspicious across the repository: casting one typed ILogger<TCategory> to another typed logger can silently produce null and drop diagnostics.
Why this matters
Archive enumeration is supposed to tolerate invalid pointer files, but those diagnostics are only useful if they are actually logged. When the cast fails, the handler silently drops those warnings.
The same risk applies anywhere else in the codebase where ILogger<T> is cast to a different logger category instead of being created through DI or ILoggerFactory.
Proposed fix
Update ArchiveCommandHandler to receive a correctly-typed logger dependency for LocalFileEnumerator via constructor injection.
Preferred options:
- inject
ILoggerFactory and create the logger with loggerFactory.CreateLogger<LocalFileEnumerator>()
- or inject
ILogger<LocalFileEnumerator> directly
Then replace the cast when constructing LocalFileEnumerator.
Repo-wide follow-up
Scan the repository for similar ILogger<T> casts that can result in null and fix them the same way:
- prefer injecting the correct typed logger directly
- or use
ILoggerFactory.CreateLogger<T>() at the call site
- avoid category-changing casts like
someLogger as ILogger<OtherType>
Scope
Expected files to update:
src/Arius.Core/Features/ArchiveCommand/ArchiveCommandHandler.cs
src/Arius.Core/ServiceCollectionExtensions.cs
- test/manual-construction call sites for
ArchiveCommandHandler
- any additional files found during the repo-wide logger-cast scan
Acceptance criteria
ArchiveCommandHandler no longer uses _logger as ILogger<LocalFileEnumerator>
LocalFileEnumerator receives a non-null correctly typed logger through DI or factory creation
- the repository has been scanned for similar unsafe
ILogger<T> casts
- any still-valid matches are fixed or explicitly triaged
- existing tests covering archive handler construction and enumeration still pass
Problem
ArchiveCommandHandlercurrently constructsLocalFileEnumeratorwith_logger as ILogger<LocalFileEnumerator>insrc/Arius.Core/Features/ArchiveCommand/ArchiveCommandHandler.cs.That cast can return
null, which suppresses warnings emitted byLocalFileEnumeratorwhen pointer files are unreadable or contain invalid hashes.More broadly, this is a pattern we should treat as suspicious across the repository: casting one typed
ILogger<TCategory>to another typed logger can silently producenulland drop diagnostics.Why this matters
Archive enumeration is supposed to tolerate invalid pointer files, but those diagnostics are only useful if they are actually logged. When the cast fails, the handler silently drops those warnings.
The same risk applies anywhere else in the codebase where
ILogger<T>is cast to a different logger category instead of being created through DI orILoggerFactory.Proposed fix
Update
ArchiveCommandHandlerto receive a correctly-typed logger dependency forLocalFileEnumeratorvia constructor injection.Preferred options:
ILoggerFactoryand create the logger withloggerFactory.CreateLogger<LocalFileEnumerator>()ILogger<LocalFileEnumerator>directlyThen replace the cast when constructing
LocalFileEnumerator.Repo-wide follow-up
Scan the repository for similar
ILogger<T>casts that can result innulland fix them the same way:ILoggerFactory.CreateLogger<T>()at the call sitesomeLogger as ILogger<OtherType>Scope
Expected files to update:
src/Arius.Core/Features/ArchiveCommand/ArchiveCommandHandler.cssrc/Arius.Core/ServiceCollectionExtensions.csArchiveCommandHandlerAcceptance criteria
ArchiveCommandHandlerno longer uses_logger as ILogger<LocalFileEnumerator>LocalFileEnumeratorreceives a non-null correctly typed logger through DI or factory creationILogger<T>casts