Skip to content

Commit

Permalink
Merge pull request #2202 from OmniSharp/feature/log-external-features…
Browse files Browse the repository at this point in the history
…-warning

log a warning when external features path has no assemblies
  • Loading branch information
filipw authored Jul 31, 2021
2 parents 9c293cb + 56e0769 commit e55adb0
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit e55adb0

Please sign in to comment.