diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs index ed75164421..04abe47c7b 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs @@ -61,26 +61,29 @@ private ImmutableArray LoadFrom(Project project) var codeFixes = project.AnalyzerReferences .OfType() .SelectMany(analyzerFileReference => analyzerFileReference.GetAssembly().DefinedTypes) - .Where(x => x.IsSubclassOf(typeof(CodeFixProvider))) + .Where(x => !x.IsAbstract && x.IsSubclassOf(typeof(CodeFixProvider))) .Select(x => { try { var attribute = x.GetCustomAttribute(); - - if (attribute?.Languages != null && attribute.Languages.Contains(project.Language)) + if (attribute == null) { - return x.AsType().CreateInstance(); + _logger.LogTrace($"Skipping code fix provider '{x.AsType()}' because it is missing the ExportCodeFixProviderAttribute."); + return null; } - _logger.LogInformation($"Skipping code fix provider '{x.AsType()}' because its language doesn't match '{project.Language}'."); + if (attribute.Languages == null || !attribute.Languages.Contains(project.Language)) + { + _logger.LogInformation($"Skipping code fix provider '{x.AsType()}' because its language '{attribute.Languages?.FirstOrDefault()}' doesn't match '{project.Language}'."); + return null; + } - return null; + return x.AsType().CreateInstance(); } catch (Exception ex) { _logger.LogError($"Creating instance of code fix provider '{x.AsType()}' failed, error: {ex}"); - return null; } })