Skip to content

feat(io): add StorageResourceProvider and AssemblyResourceProvider - #163

Merged
isrcalebe merged 4 commits into
developfrom
feat/157-storage-assembly-resource-providers
Nov 25, 2026
Merged

isrcalebe merged 4 commits into
developfrom
feat/157-storage-assembly-resource-providers

Conversation

@isrcalebe

Copy link
Copy Markdown
Contributor

Summary

Implements StorageResourceProvider and AssemblyResourceProvider in kajarlabs.Framework.IO.Resources per #153:

  • Internal ResourceStreamHelper: Pre-allocates exact-sized buffers with ReadExactly / ReadExactlyAsync for seekable streams (FileStream, UnmanagedMemoryStream, MemoryStream) to avoid intermediate MemoryStream copies, with a clean fallback for non-seekable streams.
  • StorageResourceProvider: Read-only adapter over Storage inheriting its path containment rules, mapping missing files and TOCTOU deletion races (FileNotFoundException / DirectoryNotFoundException) cleanly to null/false, implementing iterative stack-based recursive GetAvailableResources(), and guarding post-disposal calls with ObjectDisposedException.
  • AssemblyResourceProvider: NativeAOT-safe embedded resource provider requiring an explicit Assembly and optional prefix (null defaults to AssemblyName.Name, "" disables prefix stripping) with zero runtime assembly scanning, O(1) immutable lookup index supporting / -> . resolution without breaking multi-dot filenames, custom <LogicalName> / support, StringComparer.OrdinalIgnoreCase default with exact-case collision precedence, and guaranteed GetAvailableResources() round-trip resolution.
  • xUnit v3 tests: Covers disk assets via temporary FileSystemStorage, non-seekable streams and TOCTOU races, embedded test assembly fixtures (multi-dot names, custom / logical names, exact-case collisions, built-in framework shaders), cancellation, concurrency, disposal, and disk-over-embedded override precedence in CompositeResourceProvider.

Closes #157

Checklist

  • Labeled with one primary type label (feature, fix, docs, ci, chore, dependencies), plus breaking-change if applicable
  • Labeled with relevant area:* labels
  • Linked to an issue (Closes #157)
  • Public API changes are intentional (none, or listed below)
  • Tests added or updated
  • No new reflection or runtime code generation on the main path (NativeAOT-safe)

Public API changes

Added in namespace kajarlabs.Framework.IO.Resources:

  • public sealed class StorageResourceProvider : IResourceProvider
    • StorageResourceProvider(Storage storage)
  • public sealed class AssemblyResourceProvider : IResourceProvider
    • AssemblyResourceProvider(Assembly assembly, string? prefix = null, StringComparer? comparer = null)
    • string Prefix { get; }

@isrcalebe isrcalebe added feature New functionality area:io Storage and resource stores labels Nov 25, 2026
@isrcalebe
isrcalebe merged commit 9fa4bcc into develop Nov 25, 2026
4 of 5 checks passed
@isrcalebe
isrcalebe deleted the feat/157-storage-assembly-resource-providers branch November 25, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:io Storage and resource stores feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IO: StorageResourceProvider and AssemblyResourceProvider (embedded & disk resources)

1 participant