Class AppHost<TApp>
A RDCore.SDK application host.
public abstract class AppHost<TApp> : IDisposable where TApp : class, IRDCoreApp
Type Parameters
TAppThe type of IRDCoreApp being hosted.
- Inheritance
-
AppHost<TApp>
- Implements
- Derived
-
RDCoreLanguageClientHost<TApp>RDCorePlatformServerHost<TApp>
- Inherited Members
Remarks
👉 This class is inherited by both RDCorePlatformServerHost<TApp> and RDCoreLanguageClientHost<TApp>
to encapsulate a common interface to simplify implementing any kind of SDK application.
Constructors
AppHost()
A RDCore.SDK application host.
protected AppHost()
Remarks
👉 This class is inherited by both RDCorePlatformServerHost<TApp> and RDCoreLanguageClientHost<TApp>
to encapsulate a common interface to simplify implementing any kind of SDK application.
Fields
ProcessTokenSource
protected readonly CancellationTokenSource ProcessTokenSource
Field Value
Properties
ExitCode
Gets the application's exit code.
public virtual int ExitCode { get; }
Property Value
HostServices
The built host's service provider, or null before BuildAndRunAsync(HostApplicationBuilder, string[]) has built the host.
protected IServiceProvider? HostServices { get; }
Property Value
Info
Gets the AssemblyName of this application.
public static AssemblyName Info { get; }
Property Value
Remarks
👉 This provides the Name and Version values for both
ServerInfo and ClientInfo unless the application overrides this default.
Methods
AfterAppRunAsync(IServiceProvider)
🧩 A method that runs after RunAsync(IServiceProvider, string[]) returns, but before the host is stopped.
Base implementation returns a CompletedTask.
protected virtual Task AfterAppRunAsync(IServiceProvider provider)
Parameters
providerIServiceProviderThe constructed service provider.
Returns
Remarks
👉 A server app blocks inside RunAsync until its LSP server exits, so the base no-op is correct for it.
👉 A standalone LSP client process (e.g. rdc.exe) returns from RunAsync as soon as the
JSON-RPC connection is established; it overrides this method to keep the process alive for the lifetime of that connection.
BeforeAppStartAsync(IServiceProvider)
🧩 A method that runs after configuration but before the application is resolved and actually started.
Base implementation returns a CompletedTask
protected virtual Task BeforeAppStartAsync(IServiceProvider provider)
Parameters
providerIServiceProviderThe constructed service provider.
Returns
BuildAndRunAsync(HostApplicationBuilder, string[])
Builds the host, resolves and runs the TApp application.
protected virtual Task BuildAndRunAsync(HostApplicationBuilder builder, string[] args)
Parameters
builderHostApplicationBuilderargsstring[]
Returns
Remarks
Overrides should invoke the base implementation to run the base protocol.
Configure(IConfigurationBuilder, IServiceCollection, string[])
Override to supply application-specific IConfiguration configuration.
protected abstract void Configure(IConfigurationBuilder configuration, IServiceCollection services, string[] args)
Parameters
configurationIConfigurationBuilderservicesIServiceCollectionargsstring[]Any command-line arguments that were supplied to the application, parsed into SdkAppOptions.
Remarks
🧩 The base implementation binds and configures appsettings.json options, with command-line arguments as overrides.
ConfigureAdditionalExternalServices(IServiceCollection, IConfiguration)
Configures any additional services that must be injected in the application constructor.
🧩 The base implementation does nothing.
protected virtual void ConfigureAdditionalExternalServices(IServiceCollection services, IConfiguration configuration)
Parameters
servicesIServiceCollectionThe service provider of the application host being configured.
configurationIConfigurationThe current application configuration.
Remarks
👉 The purpose of external services is to bootstrap the application and support functionality at the entry point level by registering the services that must be injected in the IRDCoreApp application.
ConfigureExternalLogging(IServiceCollection, ILoggingBuilder, IConfiguration)
Configures the external service provider logging targets for a RDCore.SDK client/server application.
protected virtual void ConfigureExternalLogging(IServiceCollection services, ILoggingBuilder builder, IConfiguration configuration)
Parameters
servicesIServiceCollectionThe service provider of the application host being configured.
builderILoggingBuilderThe ILoggingBuilder to configure logging providers.
configurationIConfigurationThe current application configuration.
Remarks
👉 The external services are not registered with the OmniSharp language server host.
Their purpose is to bootstrap the application and support functionality at the entry point level by
registering the services that must be injected in the IRDCoreApp application.
🧩 The default/base implementation:
- Sets the effective minimum log level as per the supplied TraceLevel.
- Adds a
Debuglogger in debug builds.
ConfigureExternalServices(IServiceCollection, IConfiguration)
Configures only the services needed to resolve the IRDCoreApp instance.
protected virtual void ConfigureExternalServices(IServiceCollection services, IConfiguration configuration)
Parameters
servicesIServiceCollectionThe service provider of the application host being configured.
configurationIConfigurationThe current application configuration.
Remarks
🧩 If you don't intend to overwrite the core service registrations,
you probably want to override ConfigureAdditionalExternalServices(IServiceCollection, IConfiguration) instead.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
The standard .NET Dispose Pattern. Override to cleanly dispose of any instance-level IDisposable references.
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
Remarks
⚠️ Overrides MUST invoke the base.Dispose(bool) base implementation.
LogIfEnabled(LogLevel, string)
public void LogIfEnabled(LogLevel logLevel, string message)
Parameters
ResolveTraceLevel(IConfiguration)
The effective minimum log level — TraceLevel from configuration,
or Information when it is unset or invalid. Pass this to the
AddFile(path, level) overload in a ConfigureExternalLogging(IServiceCollection, ILoggingBuilder, IConfiguration) override; the
bare AddFile(path) pins the file at Information and hides
JSON-RPC protocol tracing.
protected static LogLevel ResolveTraceLevel(IConfiguration configuration)
Parameters
configurationIConfiguration
Returns
RunAsync(string[])
Runs the RDCore.SDK client/server application.
public Task<int> RunAsync(string[] args)
Parameters
argsstring[]
Returns
Remarks
RDCore.SDK plugins should await this method inside a try...catch block in the application's entry point (Program.cs)
to block execution until the internal Omnisharp LSPserver exits.
Exceptions
- OperationCanceledException
Signals a normal exit; host application process should exit with code 0.
- Exception
Any other exception type is unexpected and if it is fatal, the host application process should exit with a non-zero error code.