Skip to content

Commit

Permalink
allow plugins to be specified by a dll file path
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsequitur committed Dec 19, 2017
1 parent 541be2e commit ed648a2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/OmniSharp.LanguageServerProtocol/LanguageServerHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void CreateCompositionHost(InitializeParams initializeParams)
var compositionHostBuilder = new CompositionHostBuilder(_serviceProvider, _environment, eventEmitter)
.WithOmniSharpAssemblies()
.WithAssemblies(typeof(LanguageServerHost).Assembly)
.WithAssemblies(plugins.AssemblyNames.Select(Assembly.Load).ToArray());
.WithAssemblies(plugins.LoadAssemblies().ToArray());

_compositionHost = compositionHostBuilder.Build();

Expand Down
22 changes: 21 additions & 1 deletion src/OmniSharp.Plugins/PluginAssemblies.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;

namespace OmniSharp.Plugins
{
Expand All @@ -8,9 +12,25 @@ public class PluginAssemblies

public PluginAssemblies(IEnumerable<string> assemblyNames)
{
_assemblyNames = assemblyNames;
_assemblyNames = assemblyNames ??
throw new ArgumentNullException(nameof(assemblyNames));
}

public IEnumerable<string> AssemblyNames { get { return _assemblyNames; } }

public IEnumerable<Assembly> LoadAssemblies()
{
foreach (var assemblyName in _assemblyNames)
{
if (File.Exists(assemblyName))
{
yield return Assembly.LoadFile(assemblyName);
}
else
{
yield return Assembly.Load(assemblyName);
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/OmniSharp.Stdio/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static int Main(string[] args) => HostHelpers.Start(() =>
var writer = new SharedTextWriter(output);
var compositionHostBuilder = new CompositionHostBuilder(serviceProvider, environment, new StdioEventEmitter(writer))
.WithOmniSharpAssemblies()
.WithAssemblies(plugins.AssemblyNames.Select(Assembly.Load).ToArray());
.WithAssemblies(plugins.LoadAssemblies().ToArray());
using (var host = new Host(input, writer, environment, configuration, serviceProvider, compositionHostBuilder, loggerFactory, cancellation))
{
host.Start();
Expand Down

0 comments on commit ed648a2

Please sign in to comment.