From 56e0769f00df8eb9a36d1bf9d5765e2ab27e32e2 Mon Sep 17 00:00:00 2001 From: filipw Date: Fri, 30 Jul 2021 11:45:45 +0200 Subject: [PATCH] log a warning when external features path has no assemblies --- .../ExternalFeaturesHostServicesProvider.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/OmniSharp.Roslyn.CSharp/Services/ExternalFeaturesHostServicesProvider.cs b/src/OmniSharp.Roslyn.CSharp/Services/ExternalFeaturesHostServicesProvider.cs index 7fc91cf7c9..30054d7985 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/ExternalFeaturesHostServicesProvider.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/ExternalFeaturesHostServicesProvider.cs @@ -2,6 +2,7 @@ using System.Composition; using System.Linq; using System.Reflection; +using Microsoft.Extensions.Logging; using OmniSharp.Options; using OmniSharp.Services; @@ -15,16 +16,25 @@ public class ExternalFeaturesHostServicesProvider : IHostServicesProvider public ImmutableArray 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(); var roslynExtensionsLocations = options.RoslynExtensionsOptions.GetNormalizedLocationPaths(environment); if (roslynExtensionsLocations?.Any() == true) { + var logger = loggerFactory.CreateLogger(); 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."); + } } }