-
Notifications
You must be signed in to change notification settings - Fork 0
API Host FileSystemScriptSourceResolver
Default file-system source resolver rooted at a directory.
Namespace: AuroraScript.Source. Kind: class.
Back to .NET Host API Reference
FileSystemScriptSourceResolver reads scripts from disk. Entry paths resolve from Root; import and include dependencies resolve from the directory of the importing file. Create one directly or through ScriptSources.FileSystem(root).
Note
- Dependency resolution follows
importer.FullPathand may resolve outsideRootif the relative path points there and the file exists. - References returned by this resolver still use this resolver
RootasBaseDirectory, soGetSourceAsyncroutes back here.
A minimal use of FileSystemScriptSourceResolver.
var resolver = ScriptSources.FileSystem("./scripts");
var options = EngineOptions.Default.WithCompiler(builder =>
builder.SourceResolver = resolver);FileSystemScriptSourceResolver(string root = null, Encoding encoding = null)Creates a resolver rooted at a directory.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
root |
string |
No | Script root directory. |
encoding |
Encoding |
No | Text encoding used to read source files. |
Returns
A new FileSystemScriptSourceResolver instance.
var resolver = new FileSystemScriptSourceResolver("./scripts");string RootNormalized root directory of this resolver.
Parameters
None.
Returns
Returns string.
Console.WriteLine(resolver.Root);ValueTask<ScriptSourceReference?> ResolveAsync(ScriptSourceReference? importer, string requestedPath, ScriptResolveContext context, CancellationToken cancellationToken = default)Resolves an entry from Root or a dependency from the importing file path.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
importer |
ScriptSourceReference? |
Yes | Importing source, or null for an entry path. |
requestedPath |
string |
Yes | Raw path written in the script. |
context |
ScriptResolveContext |
Yes | Resolution context carrying extension and encoding. |
cancellationToken |
CancellationToken |
No | Token that cancels the operation. |
Returns
A ScriptSourceReference when the file exists; otherwise null.
var reference = await resolver.ResolveAsync(
null,
"main.as",
new ScriptResolveContext(".as"));ValueTask<ScriptSource> GetSourceAsync(ScriptSourceReference reference, CancellationToken cancellationToken = default)Returns source text for a resolved reference.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
reference |
ScriptSourceReference |
Yes | Reference previously produced for this resolver root. |
cancellationToken |
CancellationToken |
No | Token that cancels the operation. |
Returns
Returns ScriptSource.
if (reference is not null)
{
var source = await resolver.GetSourceAsync(reference.Value);
Console.WriteLine(source.SourcePath);
}IAsyncEnumerable<ScriptSource> GetAllSourcesAsync(ScriptSourceQuery query, CancellationToken cancellationToken = default)Enumerates script files under Root for BuildAsync().
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
query |
ScriptSourceQuery |
Yes | Query carrying the script extension and encoding. |
cancellationToken |
CancellationToken |
No | Token that cancels enumeration. |
Returns
Returns IAsyncEnumerable<ScriptSource>.
Behavior
The file-system resolver does not apply language-server workspace directory filters such as bin, obj, or node_modules.
await foreach (var source in resolver.GetAllSourcesAsync(new ScriptSourceQuery(".as")))
{
Console.WriteLine(source.FullPath);
}AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License