This document describes how FScript is split into assemblies and how they are used together in applications.
Role:
- Command-line tool (
fscript) to execute.fssfiles.
Responsibilities:
- Parse CLI arguments.
- Resolve execution mode (file, stdin,
version, REPL), sandbox root, and script arguments after--. - Build runtime context and extern registry.
- Inject CLI environment value (
let Env) into script execution (with stdlibEnvironmenttype). - Execute parse -> type inference -> evaluation pipeline.
- Print final result and report parse/type/eval errors.
Use this when:
- You want to run scripts directly from terminal/CI.
- You want a ready-to-use executable without writing host integration code.
Role:
- Embeddable language engine.
Responsibilities:
- Core language model and AST.
- Lexer and parser.
- Type system and Hindley-Milner inference.
- Evaluator and value model.
- Pretty-printing of evaluation results.
Use this when:
- You want to embed the language in another .NET application.
- You need language processing independently from default runtime extern catalog.
NuGet:
MagnusOpera.FScript.Language
Role:
- Runtime integration layer and extern catalog.
Responsibilities:
- Host context model (
RootDirectoryand related host constraints). - Built-in external function modules (filesystem, JSON/XML, regex, hash, GUID).
- Extern registry composition.
- Host-oriented decoding helpers and sandbox-aware path checks.
Use this when:
- You want the built-in extern ecosystem ready to use.
- You want a baseline runtime integration layer to extend with custom externs.
NuGet:
MagnusOpera.FScript.Runtime
Role:
- C#-friendly integration facade over language + runtime services.
Responsibilities:
- Resolve runtime extern catalog from source path/root context.
- Parse with include/import expansion through a stable interop entry point.
- Run inference APIs through a single host-facing surface.
- Expose stdlib virtual source loading for editor integrations.
Use this when:
- You integrate FScript from C# and want to avoid direct F# compiler/runtime internals.
- You build tooling services (for example LSP hosts) with a stable boundary.
Role:
- C# host executable for the Language Server process.
Responsibilities:
- Provide the production C# process host for LSP startup/dispatch.
- Execute the full LSP method surface used by the VS Code extension.
- Keep protocol behavior aligned with existing language/runtime analysis services.
Use this when:
- You want C# ownership of the server host process while reusing existing language services.
Role:
- F# compile-time type provider for exported FScript functions.
Responsibilities:
- Parse and type-check
.fssscripts during F# compilation. - Project
[<export>]functions as strongly-typed static members. - Resolve compile-time/runtime extern providers.
- Enforce runtime signature compatibility using compile-time fingerprints.
Use this when:
- You want F# compile-time validation of script contracts.
- You want strongly-typed invocation of exported script functions without hand-written wrappers.
FScriptreads CLI args, splits script arguments after--, and picks mode: file path, piped stdin,version, or interactive REPL.- For execution modes,
FScriptbuildsHostContextroot and resolves externs:HostContextincludesRootDirectoryand root-relativeDeniedPathGlobs- default runtime externs from
Registry.all(unless--no-default-externs) - optional user extern assemblies via
--extern-assembly - duplicate extern names are rejected as fatal CLI errors
FScriptinjectsEnvironment/Envmetadata:- file mode:
ScriptName = Some <file name>,Arguments = [..] - stdin mode:
ScriptName = None,Arguments = [..] - REPL mode:
ScriptName = None,Arguments = []
- file mode:
FScriptinvokesFScript.Languageparse/infer/eval pipeline.FScriptprints result (or version inversionmode).
- Host app references
FScript.Languageand (optionally)FScript.Runtime. - Host builds
HostContextand extern list. - Host runs parse/infer/eval programmatically.
- Host decides output, logging, and error handling behavior.
FScript.Languagehas no dependency onFScript.Runtime.FScript.Runtimedepends onFScript.Languagetypes.FScript.CSharpInteropdepends on bothFScript.LanguageandFScript.Runtime.FScript.LanguageServerdepends onFScript.CSharpInterop.FScript.TypeProviderdepends onFScript.LanguageandFScript.Runtime.FScriptdepends on bothFScript.LanguageandFScript.Runtime.
This keeps the language engine reusable while runtime capabilities remain host-configurable.