コード例 #1
0
        private static ImmutableArray <MissingAnalyzerDependency> FindMissingDependencies(
            List <AnalyzerInfo> analyzerInfos,
            List <IIgnorableAssemblyList> ignorableAssemblyLists,
            IBindingRedirectionService bindingRedirectionService,
            CancellationToken cancellationToken
            )
        {
            var builder = ImmutableArray.CreateBuilder <MissingAnalyzerDependency>();

            foreach (var analyzerInfo in analyzerInfos)
            {
                foreach (var reference in analyzerInfo.References)
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    var redirectedReference =
                        bindingRedirectionService != null
                            ? bindingRedirectionService.ApplyBindingRedirects(reference)
                            : reference;

                    if (
                        !ignorableAssemblyLists.Any(
                            ignorableAssemblyList =>
                            ignorableAssemblyList.Includes(redirectedReference)
                            )
                        )
                    {
                        builder.Add(new MissingAnalyzerDependency(analyzerInfo.Path, reference));
                    }
                }
            }

            return(builder.ToImmutable());
        }
コード例 #2
0
        public AnalyzerDependencyChecker(IEnumerable<string> analyzerFilePaths, IEnumerable<IIgnorableAssemblyList> ignorableAssemblyLists, IBindingRedirectionService bindingRedirectionService = null)
        {
            Debug.Assert(analyzerFilePaths != null);
            Debug.Assert(ignorableAssemblyLists != null);

            _analyzerFilePaths = new HashSet<string>(analyzerFilePaths, StringComparer.OrdinalIgnoreCase);
            _ignorableAssemblyLists = ignorableAssemblyLists.ToList();
            _bindingRedirectionService = bindingRedirectionService;
        }
コード例 #3
0
        public AnalyzerDependencyChecker(IEnumerable <string> analyzerFilePaths, IEnumerable <IIgnorableAssemblyList> ignorableAssemblyLists, IBindingRedirectionService bindingRedirectionService = null)
        {
            Debug.Assert(analyzerFilePaths != null);
            Debug.Assert(ignorableAssemblyLists != null);

            _analyzerFilePaths         = new HashSet <string>(analyzerFilePaths, StringComparer.OrdinalIgnoreCase);
            _ignorableAssemblyLists    = ignorableAssemblyLists.ToList();
            _bindingRedirectionService = bindingRedirectionService;
        }
コード例 #4
0
        public static AnalyzerDependencyResults ComputeDependencyConflicts(
            IEnumerable <string> analyzerFilePaths,
            IEnumerable <IIgnorableAssemblyList> ignorableAssemblyLists,
            IBindingRedirectionService bindingRedirectionService = null,
            CancellationToken cancellationToken = default
            )
        {
            var analyzerInfos = new List <AnalyzerInfo>();

            foreach (var analyzerFilePath in analyzerFilePaths)
            {
                cancellationToken.ThrowIfCancellationRequested();

                var info = TryReadAnalyzerInfo(analyzerFilePath);

                if (info != null)
                {
                    analyzerInfos.Add(info);
                }
            }

            var allIgnorableAssemblyLists = new List <IIgnorableAssemblyList>(
                ignorableAssemblyLists
                );

            allIgnorableAssemblyLists.Add(
                new IgnorableAssemblyIdentityList(analyzerInfos.Select(info => info.Identity))
                );

            // First check for analyzers with the same identity but different
            // contents (that is, different MVIDs).

            var conflicts = FindConflictingAnalyzers(analyzerInfos, cancellationToken);

            // Then check for missing references.

            var missingDependencies = FindMissingDependencies(
                analyzerInfos,
                allIgnorableAssemblyLists,
                bindingRedirectionService,
                cancellationToken
                );

            return(new AnalyzerDependencyResults(conflicts, missingDependencies));
        }