Table of Contents

Class ProjectFileLoader

Namespace
RDCore.SDK.Workspace
Assembly
RDCore.SDK.dll

Loads a workspace's .rdproj ProjectFile from disk, read-only. Every platform component that needs the project structure — the language server's workspace services and the environment host's session composition — resolves the project through this service so there is a single deserialization path.

public sealed class ProjectFileLoader : IProjectFileLoader
Inheritance
ProjectFileLoader
Implements
Inherited Members

Constructors

ProjectFileLoader(IFileSystem)

Loads a workspace's .rdproj ProjectFile from disk, read-only. Every platform component that needs the project structure — the language server's workspace services and the environment host's session composition — resolves the project through this service so there is a single deserialization path.

public ProjectFileLoader(IFileSystem fileSystem)

Parameters

fileSystem IFileSystem

Methods

LoadAsync(string, CancellationToken)

Loads and deserializes the .rdproj under workspaceRoot, stamping its Uri with the workspace root everything else is relative to.

public Task<ProjectFile> LoadAsync(string workspaceRoot, CancellationToken token = default)

Parameters

workspaceRoot string

The absolute path of the workspace root directory.

token CancellationToken

A token that cancels the read.

Returns

Task<ProjectFile>

Exceptions

FileNotFoundException

No .rdproj exists under the workspace root.

InvalidDataException

The .rdproj is not JSON; the message says where it stops being JSON.

InvalidOperationException

The .rdproj could not be deserialized.

LoadOrSynthesizeAsync(string, SupportedLanguage, CancellationToken)

Loads the .rdproj under workspaceRoot as LoadAsync(string, CancellationToken) does, or, when the folder has none, makes up the project the folder holds (IsSynthesized): every source file of language under it is a module, and nothing is written.

public Task<ProjectFile> LoadOrSynthesizeAsync(string workspaceRoot, SupportedLanguage language, CancellationToken token = default)

Parameters

workspaceRoot string

The absolute path of the workspace root directory.

language SupportedLanguage

The language the workspace is written in, whose FileTypes are its source files.

token CancellationToken

A token that cancels the read.

Returns

Task<ProjectFile>

Remarks

A client that opens a folder - rather than a project - is given the project the folder is. The folder is searched to every depth, except the folders whose name starts with a dot (.git, .vscode) and links to other folders. Each folder that holds a module, at any depth, is a folder of the project. Paths are relative to the workspace root, separated by /, and in ordinal order, so the language server and the environment host, which each synthesize the project, make up the same one.

A module name is unique in a project (RD-VBAL §2.2.3.3): of two files that declare the same VB_Name, the first in that order is the module, and the other is not in the project. The project is named after the folder when its name is an identifier, and VBAProject otherwise, as the VBE names a new one.

Exceptions

InvalidDataException

The .rdproj is not JSON; the message says where it stops being JSON.

InvalidOperationException

The .rdproj could not be deserialized.

TryLocate(string, out string)

Resolves the path a .rdproj would occupy under workspaceRoot and reports whether a file exists there.

public bool TryLocate(string workspaceRoot, out string projectFilePath)

Parameters

workspaceRoot string

The absolute path of the workspace root directory.

projectFilePath string

The resolved .rdproj path, whether or not it exists.

Returns

bool

true if a file exists at projectFilePath.