private AnalyzersAndFixers GetAnalyzersAndFixers(Project project)
        {
            var analyzerAssemblies = project.AnalyzerReferences
                                     .Select(reference => TryLoadAssemblyFrom(reference.FullPath, new AnalyzerLoadContext()))
                                     .OfType <Assembly>()
                                     .ToImmutableArray();

            return(AnalyzerFinderHelpers.LoadAnalyzersAndFixers(analyzerAssemblies));
        }
예제 #2
0
        public (ImmutableArray <DiagnosticAnalyzer> Analyzers, ImmutableArray <CodeFixProvider> Fixers) GetAnalyzersAndFixers(
            Solution solution,
            FormatOptions formatOptions,
            ILogger logger)
        {
            if (!formatOptions.FixAnalyzers)
            {
                return(ImmutableArray <DiagnosticAnalyzer> .Empty, ImmutableArray <CodeFixProvider> .Empty);
            }

            var assemblies = solution.Projects
                             .SelectMany(project => project.AnalyzerReferences.Select(reference => reference.FullPath))
                             .Distinct()
                             .Select(path => Assembly.LoadFrom(path));

            return(AnalyzerFinderHelpers.LoadAnalyzersAndFixers(assemblies));
        }
예제 #3
0
        public ImmutableDictionary <ProjectId, AnalyzersAndFixers> GetAnalyzersAndFixers(
            Solution solution,
            FormatOptions formatOptions,
            ILogger logger)
        {
            var assemblies = new[]
            {
                _featuresPath,
                _featuresCSharpPath,
                _featuresVisualBasicPath
            }.Select(path => Assembly.LoadFrom(path));

            var analyzersAndFixers = AnalyzerFinderHelpers.LoadAnalyzersAndFixers(assemblies);

            return(solution.Projects
                   .ToImmutableDictionary(project => project.Id, project => analyzersAndFixers));
        }
예제 #4
0
        public (ImmutableArray <DiagnosticAnalyzer> Analyzers, ImmutableArray <CodeFixProvider> Fixers) GetAnalyzersAndFixers(
            Solution solution,
            FormatOptions options,
            ILogger logger)
        {
            if (!options.FixCodeStyle)
            {
                return(ImmutableArray <DiagnosticAnalyzer> .Empty, ImmutableArray <CodeFixProvider> .Empty);
            }

            var assemblies = new[]
            {
                _featuresPath,
                _featuresCSharpPath,
                _featuresVisualBasicPath
            }.Select(path => Assembly.LoadFrom(path));

            return(AnalyzerFinderHelpers.LoadAnalyzersAndFixers(assemblies));
        }