Skip to content

Commit

Permalink
Use PluginAssemblies to for plugins from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgonch committed Nov 20, 2019
1 parent c178ac5 commit 39e025f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/OmniSharp.Http.Driver/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using OmniSharp.Plugins;
using OmniSharp.Services;

namespace OmniSharp.Http.Driver
Expand All @@ -14,8 +15,9 @@ static int Main(string[] args) => HostHelpers.Start(() =>
Configuration.ZeroBasedIndices = application.ZeroBasedIndices;
var writer = new SharedTextWriter(Console.Out);
var commandLinePlugins = new PluginAssemblies(application.Plugin);
var host = new Host(environment, writer, application.Plugin, application.Port, application.Interface);
var host = new Host(environment, writer, commandLinePlugins, application.Port, application.Interface);
host.Start();
return 0;
Expand Down
5 changes: 2 additions & 3 deletions src/OmniSharp.Http/Host.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
Expand All @@ -15,14 +14,14 @@ internal class Host
{
private readonly IOmniSharpEnvironment _environment;
private readonly ISharedTextWriter _sharedTextWriter;
private readonly IEnumerable<string> _commandLinePlugins;
private readonly PluginAssemblies _commandLinePlugins;
private readonly int _serverPort;
private readonly string _serverInterface;

public Host(
IOmniSharpEnvironment environment,
ISharedTextWriter sharedTextWriter,
IEnumerable<string> commandLinePlugins,
PluginAssemblies commandLinePlugins,
int serverPort,
string serverInterface)
{
Expand Down
9 changes: 4 additions & 5 deletions src/OmniSharp.Http/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Composition.Hosting;
using System.Linq;
using Microsoft.AspNetCore.Builder;
Expand All @@ -22,9 +21,9 @@ internal class Startup
private readonly IOmniSharpEnvironment _environment;
private readonly IEventEmitter _eventEmitter;
private CompositionHost _compositionHost;
private IEnumerable<string> _commandLinePlugins;
private PluginAssemblies _commandLinePlugins;

public Startup(IOmniSharpEnvironment environment, IEventEmitter eventEmitter, IEnumerable<string> commandLinePlugins)
public Startup(IOmniSharpEnvironment environment, IEventEmitter eventEmitter, PluginAssemblies commandLinePlugins)
{
_environment = environment;
_eventEmitter = eventEmitter;
Expand Down Expand Up @@ -53,14 +52,14 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
});

var options = serviceProvider.GetRequiredService<IOptionsMonitor<OmniSharpOptions>>();
var plugins = new PluginAssemblies(_commandLinePlugins.Concat(options.CurrentValue.Plugins.GetNormalizedLocationPaths(_environment)));
var plugins = _commandLinePlugins.AssemblyNames.Concat(options.CurrentValue.Plugins.GetNormalizedLocationPaths(_environment));

var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
var logger = loggerFactory.CreateLogger<Startup>();
var assemblyLoader = serviceProvider.GetRequiredService<IAssemblyLoader>();
_compositionHost = new CompositionHostBuilder(serviceProvider)
.WithOmniSharpAssemblies()
.WithAssemblies(assemblyLoader.LoadByAssemblyNameOrPath(logger, plugins.AssemblyNames).ToArray())
.WithAssemblies(assemblyLoader.LoadByAssemblyNameOrPath(logger, plugins).ToArray())
.Build();

return serviceProvider;
Expand Down

0 comments on commit 39e025f

Please sign in to comment.