Skip to content

API Host MemorySource

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

MemorySource

Script source backed by an in-memory string.

Namespace: AuroraScript.Source. Kind: class.

Back to .NET Host API Reference

Overview

MemorySource is the ScriptSource implementation for text a host already holds: generated code, an unsaved editor buffer, or a record loaded from a database. A custom resolver typically returns instances of this type from GetSourceAsync and GetAllSourcesAsync.

Quick Reference

A minimal use of MemorySource.

var source = new MemorySource(
    "mem://app/",
    "main.as",
    "@module(MAIN); export func run() { return 42; }");

Console.WriteLine(source.SourcePath); // main.as

Constructors

MemorySource

MemorySource(string baseDirectory, string fullPath, string text)

Creates a source over an in-memory string.

Parameters

Name Type Required Description
baseDirectory string Yes Resolver root that owns the source.
fullPath string Yes Normalized full path or virtual source identifier.
text string Yes Script text.

Returns

A new MemorySource instance.

var source = new MemorySource("mem://app/", "main.as", "@module(MAIN);");

Properties

BaseDirectory

string BaseDirectory

Resolver root used for module-relative paths and source read routing.

Parameters

None.

Returns

Returns string.

Console.WriteLine(source.BaseDirectory); // mem://app/

SourcePath

string SourcePath

Module-relative path used by the compiler and runtime.

Parameters

None.

Returns

Returns string.

Console.WriteLine(source.SourcePath); // main.as

FullPath

string FullPath

Absolute file path or virtual source identifier.

Parameters

None.

Returns

Returns string.

Console.WriteLine(source.FullPath);

Code

string Code

Script text held by this source.

Parameters

None.

Returns

Returns string.

Console.WriteLine(source.Code);

Methods

ReadSource

string ReadSource()

Returns the script text.

Parameters

None.

Returns

Returns string.

Behavior

The text is already in memory, so the read does not touch the file system.

var code = source.ReadSource();

Clone this wiki locally