Skip to content

API Host CompositeScriptSourceResolver

Liu.Yandong.Hanks edited this page Aug 21, 2026 · 3 revisions

CompositeScriptSourceResolver

Ordered resolver composition. Earlier resolvers have higher priority.

Namespace: AuroraScript.Source. Kind: class.

Back to .NET Host API Reference

Overview

CompositeScriptSourceResolver chains several IScriptSourceResolver instances into one. Order is the priority rule: a memory overlay placed before a file-system resolver can shadow disk files whose resolved target falls under the memory root. Create one with ScriptSources.Composite(...) or by calling Add repeatedly.

Note

  • ResolveAsync tries resolvers in order with the original importer and requested path. The first non-null reference wins.
  • GetSourceAsync routes by exact normalized ScriptSourceReference.BaseDirectory, not by scanning target paths.
  • GetAllSourcesAsync de-duplicates by normalized ScriptSource.FullPath so earlier sources hide later sources with the same identity.
  • No ProviderId is required; resolver order and BaseDirectory identify the selected provider.

Quick Reference

A minimal use of CompositeScriptSourceResolver.

var resolver = ScriptSources.Composite(
    ScriptSources.Memory("mem://app/")
        .Add("main.as", "@module(MAIN); export func run() { return 42; }"),
    ScriptSources.FileSystem("./scripts"));

Properties

Root

string Root

Normalized root reported by the composition.

Parameters

None.

Returns

Returns string.

Console.WriteLine(resolver.Root);

Methods

Add

CompositeScriptSourceResolver Add(IScriptSourceResolver resolver)

Adds a resolver and caches its normalized root for later routing.

Parameters

Name Type Required Description
resolver IScriptSourceResolver Yes Resolver to append. Later entries have lower priority.

Returns

Returns the same CompositeScriptSourceResolver, so calls can be chained.

Behavior

Roots are normalized when the resolver is added, not on every comparison, so add resolvers during host setup rather than during compilation.

var resolver = new CompositeScriptSourceResolver()
    .Add(ScriptSources.Memory("mem://app/"))
    .Add(ScriptSources.FileSystem("./scripts"));

Clone this wiki locally