Table of Contents

Class RDCorePlatformClient

Namespace
RDCore.SDK.Client
Assembly
RDCore.SDK.Protocol.dll

The client's side of the RDCore platform protocol, over any IRDCorePlatformChannel: the handshake, the rdcore/session/* requests a client sends, and the requests the language server sends a client, which it answers.

public sealed class RDCorePlatformClient
Inheritance
RDCorePlatformClient
Inherited Members

Remarks

A client connects to the language server, initializes it over LSP, then performs the platform handshake (InitializeAsync(CoreServerComponent, CorePlatformClientCapabilities, CancellationToken)), which says what it expects of the platform beyond LSP. The language server relays a session/* request to the component that serves it - the environment host, for the runtime session - and answers it once that component did.

The requests the language server sends a client are answered only by a client that registered for them (OnMessageBox(Func<SessionMessageBoxParams, CancellationToken, Task<MessageBoxResult>>), OnInputBox(Func<SessionInputBoxParams, CancellationToken, Task<InputBoxResult>>), OnRubberduckIndenterSettings(Func<RubberduckIndenterSettingsParams, CancellationToken, Task<RubberduckIndenterSettingsResult>>), OnRubberduckIndenterSettingsApply(Func<RubberduckIndenterSettingsApplyParams, CancellationToken, Task<RubberduckIndenterSettingsApplyResult>>), OnListSettingValue(Func<ListSettingValueParams, CancellationToken, Task<ListSettingValueResult>>)), and should be registered before the handshake says the client expects them: the language server may send one as soon as it is told. The same goes for the stops it tells a client of (OnDebugStopped(Func<SessionDebugStoppedParams, CancellationToken, Task>)).

Constructors

RDCorePlatformClient(IRDCorePlatformChannel)

The client's side of the RDCore platform protocol, over any IRDCorePlatformChannel: the handshake, the rdcore/session/* requests a client sends, and the requests the language server sends a client, which it answers.

public RDCorePlatformClient(IRDCorePlatformChannel channel)

Parameters

channel IRDCorePlatformChannel

The connection to the language server.

Remarks

A client connects to the language server, initializes it over LSP, then performs the platform handshake (InitializeAsync(CoreServerComponent, CorePlatformClientCapabilities, CancellationToken)), which says what it expects of the platform beyond LSP. The language server relays a session/* request to the component that serves it - the environment host, for the runtime session - and answers it once that component did.

The requests the language server sends a client are answered only by a client that registered for them (OnMessageBox(Func<SessionMessageBoxParams, CancellationToken, Task<MessageBoxResult>>), OnInputBox(Func<SessionInputBoxParams, CancellationToken, Task<InputBoxResult>>), OnRubberduckIndenterSettings(Func<RubberduckIndenterSettingsParams, CancellationToken, Task<RubberduckIndenterSettingsResult>>), OnRubberduckIndenterSettingsApply(Func<RubberduckIndenterSettingsApplyParams, CancellationToken, Task<RubberduckIndenterSettingsApplyResult>>), OnListSettingValue(Func<ListSettingValueParams, CancellationToken, Task<ListSettingValueResult>>)), and should be registered before the handshake says the client expects them: the language server may send one as soon as it is told. The same goes for the stops it tells a client of (OnDebugStopped(Func<SessionDebugStoppedParams, CancellationToken, Task>)).

Properties

Channel

The connection this client speaks through.

public IRDCorePlatformChannel Channel { get; }

Property Value

IRDCorePlatformChannel

Methods

CallToolAsync(ToolCallParams, CancellationToken)

Calls a tool the language server serves an assistant (ToolsCall).

public Task<ToolCallResult> CallToolAsync(ToolCallParams request, CancellationToken token)

Parameters

request ToolCallParams

The tool, and its arguments.

token CancellationToken

Cancels the call.

Returns

Task<ToolCallResult>

What the tool answers; a refusal is a result whose IsError is true.

DebugBreakpointsAsync(SessionDebugBreakpointsParams, CancellationToken)

Sets the breakpoints of a module (SessionDebugBreakpoints).

public Task<DebugBreakpointsResult> DebugBreakpointsAsync(SessionDebugBreakpointsParams request, CancellationToken token)

Parameters

request SessionDebugBreakpointsParams

The module and its breakpoints: all of them, which replace the ones it had.

token CancellationToken

Cancels the request.

Returns

Task<DebugBreakpointsResult>

Each breakpoint as it was set: verified on a line that runs, or not.

DebugEditStatusAsync(SessionDebugEditStatusParams, CancellationToken)

Asks what the edits made while the program is suspended do to it (SessionDebugEditStatus).

public Task<DebugEditStatusResult> DebugEditStatusAsync(SessionDebugEditStatusParams request, CancellationToken token)

Parameters

request SessionDebugEditStatusParams

The request.

token CancellationToken

Cancels the request.

Returns

Task<DebugEditStatusResult>

Each edit, and what it takes to apply it.

DebugErrorBreakAsync(SessionDebugErrorBreakParams, CancellationToken)

Sets which run-time errors a program under a debugger waits at (SessionDebugErrorBreak).

public Task<DebugAck> DebugErrorBreakAsync(SessionDebugErrorBreakParams request, CancellationToken token)

Parameters

request SessionDebugErrorBreakParams

The errors to wait at, for this run and every later one.

token CancellationToken

Cancels the request.

Returns

Task<DebugAck>

The acknowledgement, once the runtime session has the mode.

DebugEvaluateAsync(SessionDebugEvaluateParams, CancellationToken)

Evaluates an expression in a frame of the suspended program (SessionDebugEvaluate).

public Task<DebugEvaluateResult> DebugEvaluateAsync(SessionDebugEvaluateParams request, CancellationToken token)

Parameters

request SessionDebugEvaluateParams

The frame and the expression.

token CancellationToken

Cancels the request.

Returns

Task<DebugEvaluateResult>

The value, or the error the expression raised.

DebugExecuteAsync(SessionDebugExecuteParams, CancellationToken)

Runs a statement in a frame of the suspended program, as the Immediate window does (SessionDebugExecute).

public Task<DebugEvaluateResult> DebugExecuteAsync(SessionDebugExecuteParams request, CancellationToken token)

Parameters

request SessionDebugExecuteParams

The frame and the statement.

token CancellationToken

Cancels the request.

Returns

Task<DebugEvaluateResult>

Whether the statement ran, what it printed, or the error it raised.

DebugGotoAsync(SessionDebugGotoParams, CancellationToken)

Moves the next statement of the suspended program (SessionDebugGoto).

public Task<DebugGotoResult> DebugGotoAsync(SessionDebugGotoParams request, CancellationToken token)

Parameters

request SessionDebugGotoParams

Where to.

token CancellationToken

Cancels the request.

Returns

Task<DebugGotoResult>

Whether the next statement moved, where to, or why it did not.

DebugPauseAsync(SessionDebugPauseParams, CancellationToken)

Suspends the running program (SessionDebugPause).

public Task<DebugAck> DebugPauseAsync(SessionDebugPauseParams request, CancellationToken token)

Parameters

request SessionDebugPauseParams

The request.

token CancellationToken

Cancels the request.

Returns

Task<DebugAck>

Whether there was a program to suspend.

DebugResumeAsync(SessionDebugResumeParams, CancellationToken)

Resumes, or steps, the suspended program (SessionDebugResume).

public Task<ExecuteResult> DebugResumeAsync(SessionDebugResumeParams request, CancellationToken token)

Parameters

request SessionDebugResumeParams

How far to run.

token CancellationToken

Cancels the request.

Returns

Task<ExecuteResult>

How the program ran: suspended again, ended, or failed.

DebugStackAsync(SessionDebugStackParams, CancellationToken)

Asks for the call stack of the suspended program (SessionDebugStack).

public Task<DebugStackResult> DebugStackAsync(SessionDebugStackParams request, CancellationToken token)

Parameters

request SessionDebugStackParams

The request.

token CancellationToken

Cancels the request.

Returns

Task<DebugStackResult>

The frames, innermost first.

DebugTerminateAsync(SessionDebugTerminateParams, CancellationToken)

Ends the suspended program (SessionDebugTerminate).

public Task<DebugAck> DebugTerminateAsync(SessionDebugTerminateParams request, CancellationToken token)

Parameters

request SessionDebugTerminateParams

Whether to wipe the session's state as well.

token CancellationToken

Cancels the request.

Returns

Task<DebugAck>

Whether there was a program to end.

DebugVariablesAsync(SessionDebugVariablesParams, CancellationToken)

Asks for the variables of a frame of the suspended program, or of an object (SessionDebugVariables).

public Task<DebugVariablesResult> DebugVariablesAsync(SessionDebugVariablesParams request, CancellationToken token)

Parameters

request SessionDebugVariablesParams

The frame, the scope, and the object.

token CancellationToken

Cancels the request.

Returns

Task<DebugVariablesResult>

The variables, with their values and types.

DiscardAsync(SessionDiscardParams, CancellationToken)

Discards a module of the runtime session (SessionDiscard).

public Task<DiscardResult> DiscardAsync(SessionDiscardParams request, CancellationToken token)

Parameters

request SessionDiscardParams

The module.

token CancellationToken

Cancels the request.

Returns

Task<DiscardResult>

How much was discarded.

ExecuteAsync(SessionExecuteParams, CancellationToken)

Runs code in the runtime session (SessionExecute).

public Task<ExecuteResult> ExecuteAsync(SessionExecuteParams request, CancellationToken token)

Parameters

request SessionExecuteParams

The code to run, and how.

token CancellationToken

Cancels the request.

Returns

Task<ExecuteResult>

How the code ran: completed, suspended, or failed, with what it printed.

InitializeAsync(CoreServerComponent, CorePlatformClientCapabilities, CancellationToken)

Performs the platform handshake (PlatformInitialize): says what the client expects of the component it connected to, and learns what that component provides.

public Task<PlatformInitializeResult> InitializeAsync(CoreServerComponent expectedComponent, CorePlatformClientCapabilities expected, CancellationToken token)

Parameters

expectedComponent CoreServerComponent

The component the client expects to be connected to: LanguageServer, for a client of the platform.

expected CorePlatformClientCapabilities

The capabilities the client expects of it; a group left null is expected of no component.

token CancellationToken

Cancels the request.

Returns

Task<PlatformInitializeResult>

The component the client is connected to, and the capabilities it provides.

ListToolsAsync(CancellationToken)

Lists the tools the language server serves an assistant (ToolsList), in the language of the client's user interface.

public Task<ToolsListResult> ListToolsAsync(CancellationToken token)

Parameters

token CancellationToken

Cancels the request.

Returns

Task<ToolsListResult>

Each tool.

OnDebugStopped(Func<SessionDebugStoppedParams, CancellationToken, Task>)

Takes the stops of the handlers of events that run while no program runs (SessionDebugStopped), for a client that expects SessionStops. The handler waits until the client resumes or ends it over rdcore/session/debug/*.

public IDisposable OnDebugStopped(Func<SessionDebugStoppedParams, CancellationToken, Task> handler)

Parameters

handler Func<SessionDebugStoppedParams, CancellationToken, Task>

Shows where the handler stopped. It returns once it has: what the client does with the stop is a request of its own.

Returns

IDisposable

The registration; disposing it stops taking them.

OnInputBox(Func<SessionInputBoxParams, CancellationToken, Task<InputBoxResult>>)

Shows the program's InputBox calls (SessionInputBox), for a client that expects SessionInteraction.

public IDisposable OnInputBox(Func<SessionInputBoxParams, CancellationToken, Task<InputBoxResult>> handler)

Parameters

handler Func<SessionInputBoxParams, CancellationToken, Task<InputBoxResult>>

Shows an input box and answers what the user typed, or that they cancelled; NotHandled when it showed none.

Returns

IDisposable

The registration; disposing it stops answering.

OnListSettingValue(Func<ListSettingValueParams, CancellationToken, Task<ListSettingValueResult>>)

Adds an item to the list of a setting, or removes one from it, as a change of the client's own (ListSettingValue), for a client that expects ListSettingValue.

public IDisposable OnListSettingValue(Func<ListSettingValueParams, CancellationToken, Task<ListSettingValueResult>> handler)

Parameters

handler Func<ListSettingValueParams, CancellationToken, Task<ListSettingValueResult>>

Changes the list where Scope says it is kept, and says whether it did.

Returns

IDisposable

The registration; disposing it stops answering.

OnMessageBox(Func<SessionMessageBoxParams, CancellationToken, Task<MessageBoxResult>>)

Shows the program's MsgBox calls (SessionMessageBox), for a client that expects SessionInteraction.

public IDisposable OnMessageBox(Func<SessionMessageBoxParams, CancellationToken, Task<MessageBoxResult>> handler)

Parameters

handler Func<SessionMessageBoxParams, CancellationToken, Task<MessageBoxResult>>

Shows a message box and answers the button the user chose; NotHandled when it showed none.

Returns

IDisposable

The registration; disposing it stops answering.

OnRubberduckIndenterSettings(Func<RubberduckIndenterSettingsParams, CancellationToken, Task<RubberduckIndenterSettingsResult>>)

Answers what the client finds of the user's Rubberduck indenter settings (RubberduckIndenterSettings), for a client that expects RubberduckIndenterSettings.

public IDisposable OnRubberduckIndenterSettings(Func<RubberduckIndenterSettingsParams, CancellationToken, Task<RubberduckIndenterSettingsResult>> handler)

Parameters

handler Func<RubberduckIndenterSettingsParams, CancellationToken, Task<RubberduckIndenterSettingsResult>>

Reads the settings, as they are; Nothing when there are none.

Returns

IDisposable

The registration; disposing it stops answering.

OnRubberduckIndenterSettingsApply(Func<RubberduckIndenterSettingsApplyParams, CancellationToken, Task<RubberduckIndenterSettingsApplyResult>>)

Takes the Formatting settings the language server mapped from them as the client's own (RubberduckIndenterSettingsApply), for a client that expects RubberduckIndenterSettings.

public IDisposable OnRubberduckIndenterSettingsApply(Func<RubberduckIndenterSettingsApplyParams, CancellationToken, Task<RubberduckIndenterSettingsApplyResult>> handler)

Parameters

handler Func<RubberduckIndenterSettingsApplyParams, CancellationToken, Task<RubberduckIndenterSettingsApplyResult>>

Sets the settings, and says how many it set and which it did not.

Returns

IDisposable

The registration; disposing it stops answering.

PeekAsync(SessionPeekParams, CancellationToken)

Reads a byte of the runtime session's memory (SessionPeek).

public Task<PeekResult> PeekAsync(SessionPeekParams request, CancellationToken token)

Parameters

request SessionPeekParams

The address.

token CancellationToken

Cancels the request.

Returns

Task<PeekResult>

The byte, and whether the address is allocated.

PokeAsync(SessionPokeParams, CancellationToken)

Writes a byte of the runtime session's memory (SessionPoke).

public Task<PokeResult> PokeAsync(SessionPokeParams request, CancellationToken token)

Parameters

request SessionPokeParams

The address and the value.

token CancellationToken

Cancels the request.

Returns

Task<PokeResult>

Whether the byte was written.

RefactorApplyAsync(RefactorApplyParams, CancellationToken)

Asks for the edit a refactoring makes with its user's answers (RefactorApply), which the client applies. A refactoring that is refused, or whose answers it refuses, fails the request, its message saying why in the language of the user interface.

public Task<RefactorWorkspaceEdit> RefactorApplyAsync(RefactorApplyParams request, CancellationToken token)

Parameters

request RefactorApplyParams

The refactoring, the document and range it is of, the user's answers, and the changes the user accepts.

token CancellationToken

Cancels the request.

Returns

Task<RefactorWorkspaceEdit>

The edit of the workspace, which the language server does not apply.

RefactorCheckIdentifierAsync(RefactorIdentifierCheckParams, CancellationToken)

Asks about an identifier the user is typing for a refactoring, before it is applied (RefactorCheckIdentifier): whether it can be declared where the refactoring declares it, and what it would hide, which a dialog shows beside it as its user types it.

public Task<RefactorIdentifierCheckResult> RefactorCheckIdentifierAsync(RefactorIdentifierCheckParams request, CancellationToken token)

Parameters

request RefactorIdentifierCheckParams

The refactoring, the document and range it is of, and the user's answers, whose Name choices hold the identifiers.

token CancellationToken

Cancels the request.

Returns

Task<RefactorIdentifierCheckResult>

The notices the identifiers raise, each with the choice it answers: an identifier the refactoring refuses, or what the user should know of one it takes.

RefactorPrepareAsync(RefactorPrepareParams, CancellationToken)

Asks what a refactoring of a document's range asks its user, and what it refuses or would change (RefactorPrepare), for a client that expects Refactoring: what its dialog shows.

public Task<RefactorPrepareResult> RefactorPrepareAsync(RefactorPrepareParams request, CancellationToken token)

Parameters

request RefactorPrepareParams

The refactoring, by its kind, and the document and range it is of.

token CancellationToken

Cancels the request.

Returns

Task<RefactorPrepareResult>

The choices, each with its default, and the notices: the refusals, the changes the user accepts, and what the user should know.

StatusAsync(SessionStatusParams, CancellationToken)

Asks for the state of the runtime session (SessionStatus).

public Task<SessionStatusResult> StatusAsync(SessionStatusParams request, CancellationToken token)

Parameters

request SessionStatusParams

The request.

token CancellationToken

Cancels the request.

Returns

Task<SessionStatusResult>

Whether the session is composed, its project, and its memory.