Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ protected override void EndProcessing()
// Create the configuration from parameters
EditorServicesConfig editorServicesConfig = CreateConfigObject();

using EditorServicesLoader psesLoader = EditorServicesLoader.Create(_logger, editorServicesConfig, SessionDetailsPath, _loggerUnsubscribers);
EditorServicesLoader psesLoader = EditorServicesLoader.Create(_logger, editorServicesConfig, SessionDetailsPath, _loggerUnsubscribers);
_logger.Log(PsesLogLevel.Debug, "Loading EditorServices");
// Synchronously start editor services and wait here until it shuts down.
psesLoader.LoadAndRunEditorServicesAsync().GetAwaiter().GetResult();
Expand Down
18 changes: 3 additions & 15 deletions src/PowerShellEditorServices.Hosting/EditorServicesLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Microsoft.PowerShell.EditorServices.Hosting
/// In particular, this class wraps the point where Editor Services is safely loaded
/// in a way that separates its dependencies from the calling context.
/// </summary>
public sealed class EditorServicesLoader : IDisposable
public sealed class EditorServicesLoader
{
#if !CoreCLR
// TODO: Well, we're saying we need 4.8 here but we're building for 4.6.2...
Expand Down Expand Up @@ -172,8 +172,6 @@ public static EditorServicesLoader Create(

private readonly Version _powerShellVersion;

private EditorServicesRunner _editorServicesRunner;

private EditorServicesLoader(
HostLogger logger,
EditorServicesConfig hostConfig,
Expand Down Expand Up @@ -217,20 +215,10 @@ public Task LoadAndRunEditorServicesAsync()

_logger.Log(PsesLogLevel.Information, "Starting PowerShell Editor Services");

_editorServicesRunner = new EditorServicesRunner(_logger, _hostConfig, _sessionFileWriter, _loggersToUnsubscribe);
EditorServicesRunner editorServicesRunner = new(_logger, _hostConfig, _sessionFileWriter, _loggersToUnsubscribe);

// The trigger method for Editor Services
return Task.Run(_editorServicesRunner.RunUntilShutdown);
}

public void Dispose()
{
_logger.Log(PsesLogLevel.Trace, "Loader disposed");
_editorServicesRunner?.Dispose();

// TODO:
// Remove assembly resolve events
// This is not high priority, since the PSES process shouldn't be reused
return Task.Run(editorServicesRunner.RunUntilShutdown);
}

private static void LoadEditorServices() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Microsoft.PowerShell.EditorServices.Hosting
/// cref="Microsoft.Extensions.Logging"/> and <see
/// cref="Microsoft.Extensions.DependencyInjection"/>.
/// </remarks>
internal class EditorServicesRunner : IDisposable
internal class EditorServicesRunner
{
private readonly HostLogger _logger;

Expand Down Expand Up @@ -68,15 +68,6 @@ public Task RunUntilShutdown()
return runAndAwaitShutdown;
}

/// <summary>
/// TODO: This class probably should not be <see cref="IDisposable"/> as the primary
/// intention of that interface is to provide cleanup of unmanaged resources, which the
/// logger certainly is not. Nor is this class used with a <see langword="using"/>. It is
/// only because of the use of <see cref="_serverFactory"/> that this class is also
/// disposable, and instead that class should be fixed.
/// </summary>
public void Dispose() => _serverFactory.Dispose();

/// <summary>
/// This is the servers' entry point, e.g. <c>main</c>, as it instantiates, runs and waits
/// for the LSP and debug servers at the heart of Editor Services. Uses <see
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Microsoft.PowerShell.EditorServices.Hosting
/// <summary>
/// Factory for creating the LSP server and debug server instances.
/// </summary>
internal sealed class EditorServicesServerFactory : IDisposable
internal sealed class EditorServicesServerFactory
{
private readonly HostLogger _hostLogger;

Expand Down Expand Up @@ -125,8 +125,5 @@ public PsesDebugServer CreateDebugServerForTempSession(
serviceProvider,
isTemp: true);
}

// TODO: Clean up host logger? Shouldn't matter since we start a new process after shutdown.
public void Dispose() { }
}
}