Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log a warning when external features path has no assemblies #2202

Merged
merged 1 commit into from
Jul 31, 2021
Merged
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 @@ -2,6 +2,7 @@
using System.Composition;
using System.Linq;
using System.Reflection;
using Microsoft.Extensions.Logging;
using OmniSharp.Options;
using OmniSharp.Services;

Expand All @@ -15,16 +16,25 @@ public class ExternalFeaturesHostServicesProvider : IHostServicesProvider
public ImmutableArray<Assembly> Assemblies { get; }

[ImportingConstructor]
public ExternalFeaturesHostServicesProvider(IAssemblyLoader loader, OmniSharpOptions options, IOmniSharpEnvironment environment)
public ExternalFeaturesHostServicesProvider(IAssemblyLoader loader, OmniSharpOptions options, IOmniSharpEnvironment environment, ILoggerFactory loggerFactory)
{
var builder = ImmutableArray.CreateBuilder<Assembly>();

var roslynExtensionsLocations = options.RoslynExtensionsOptions.GetNormalizedLocationPaths(environment);
if (roslynExtensionsLocations?.Any() == true)
{
var logger = loggerFactory.CreateLogger<ExternalFeaturesHostServicesProvider>();
foreach (var roslynExtensionsLocation in roslynExtensionsLocations)
{
builder.AddRange(loader.LoadAllFrom(roslynExtensionsLocation));
var loadedAssemblies = loader.LoadAllFrom(roslynExtensionsLocation);
if (loadedAssemblies.Any())
{
builder.AddRange(loadedAssemblies);
}
else
{
logger.LogWarning($"The path '{roslynExtensionsLocation}' is configured in the RoslynExtensionsOptions as the external features source but no assemblies were found at this path.");
}
}
}

Expand Down