当前位置: 首页>>代码示例>>C#>>正文


C# Solution.GetProjectDependencyGraph方法代码示例

本文整理汇总了C#中Solution.GetProjectDependencyGraph方法的典型用法代码示例。如果您正苦于以下问题:C# Solution.GetProjectDependencyGraph方法的具体用法?C# Solution.GetProjectDependencyGraph怎么用?C# Solution.GetProjectDependencyGraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Solution的用法示例。


在下文中一共展示了Solution.GetProjectDependencyGraph方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDocumentsAffectedByRename

 internal static IEnumerable<Document> GetDocumentsAffectedByRename(ISymbol symbol, Solution solution, IEnumerable<RenameLocation> renameLocations)
 {
     if (IsSymbolDefinedInsideMethod(symbol))
     {
         // if the symbol was declared inside of a method, don't check for conflicts in non-renamed documents.
         return renameLocations.Select(l => solution.GetDocument(l.DocumentId));
     }
     else
     {
         var documentIdOfRenameSymbolDeclaration = solution.GetDocument(symbol.Locations.First(l => l.IsInSource).SourceTree);
         if (symbol.DeclaredAccessibility == Accessibility.Private)
         {
             // private members or classes cannot be used outside of the project, so we should only scan documents of this project.
             Contract.ThrowIfFalse(renameLocations.Select(l => l.DocumentId.ProjectId).Distinct().Count() == 1);
             return documentIdOfRenameSymbolDeclaration.Project.Documents;
         }
         else
         {
             // We are trying to figure out the projects that directly depend on the project that contains the declaration for 
             // the rename symbol.  Other projects should not be affected by the rename.
             var symbolProjectId = documentIdOfRenameSymbolDeclaration.Project.Id;
             var relevantProjects = SpecializedCollections.SingletonEnumerable(symbolProjectId).Concat(
                 solution.GetProjectDependencyGraph().GetProjectsThatDirectlyDependOnThisProject(symbolProjectId));
             return relevantProjects.SelectMany(p => solution.GetProject(p).Documents);
         }
     }
 }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:27,代码来源:RenameUtilities.cs

示例2: FindReferencesSearchEngine

 public FindReferencesSearchEngine(
     Solution solution,
     IImmutableSet<Document> documents,
     ImmutableArray<IReferenceFinder> finders,
     IFindReferencesProgress progress,
     CancellationToken cancellationToken)
 {
     _documents = documents;
     _solution = solution;
     _finders = finders;
     _progress = progress;
     _cancellationToken = cancellationToken;
     _dependencyGraph = solution.GetProjectDependencyGraph();
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:14,代码来源:FindReferencesSearchEngine.cs

示例3: FindReferencesSearchEngine

 public FindReferencesSearchEngine(
     Solution solution,
     IImmutableSet<Document> documents,
     ImmutableList<IReferenceFinder> finders,
     IFindReferencesProgress progress,
     CancellationToken cancellationToken)
 {
     this.documents = documents;
     this.solution = solution;
     this.finders = finders;
     this.progress = progress;
     this.cancellationToken = cancellationToken;
     this.dependencyGraph = solution.GetProjectDependencyGraph();
 }
开发者ID:riversky,项目名称:roslyn,代码行数:14,代码来源:FindReferencesSearchEngine.cs

示例4: FindReferencesSearchEngine

        public FindReferencesSearchEngine(
            Solution solution,
            IImmutableSet<Document> documents,
            ImmutableArray<IReferenceFinder> finders,
            IStreamingFindReferencesProgress progress,
            CancellationToken cancellationToken)
        {
            _documents = documents;
            _solution = solution;
            _finders = finders;
            _progress = progress;
            _cancellationToken = cancellationToken;
            _dependencyGraph = solution.GetProjectDependencyGraph();

            _progressTracker = new StreamingProgressTracker(progress.ReportProgressAsync);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:16,代码来源:FindReferencesSearchEngine.cs

示例5: GetDocumentsAffectedByRename

        internal static IEnumerable<Document> GetDocumentsAffectedByRename(ISymbol symbol, Solution solution, IEnumerable<RenameLocation> renameLocations)
        {
            if (IsSymbolDefinedInsideMethod(symbol))
            {
                // if the symbol was declared inside of a method, don't check for conflicts in non-renamed documents.
                return renameLocations.Select(l => solution.GetDocument(l.DocumentId));
            }
            else
            {
                var documentsOfRenameSymbolDeclaration = symbol.Locations.Where(l => l.IsInSource).Select(l => solution.GetDocument(l.SourceTree));
                var projectIdsOfRenameSymbolDeclaration =
                    documentsOfRenameSymbolDeclaration.SelectMany(d => d.GetLinkedDocumentIds())
                    .Concat(documentsOfRenameSymbolDeclaration.First().Id)
                    .Select(d => d.ProjectId).Distinct();

                if (ShouldRenameOnlyAffectDeclaringProject(symbol))
                {
                    var isSubset = renameLocations.Select(l => l.DocumentId.ProjectId).Distinct().Except(projectIdsOfRenameSymbolDeclaration).IsEmpty();
                    Contract.ThrowIfFalse(isSubset);
                    return projectIdsOfRenameSymbolDeclaration.SelectMany(p => solution.GetProject(p).Documents);
                }
                else
                {
                    // We are trying to figure out the projects that directly depend on the project that contains the declaration for 
                    // the rename symbol.  Other projects should not be affected by the rename.
                    var relevantProjects = projectIdsOfRenameSymbolDeclaration.Concat(projectIdsOfRenameSymbolDeclaration.SelectMany(p =>
                       solution.GetProjectDependencyGraph().GetProjectsThatDirectlyDependOnThisProject(p))).Distinct();
                    return relevantProjects.SelectMany(p => solution.GetProject(p).Documents);
                }
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:31,代码来源:RenameUtilities.cs

示例6: GetProjectsToExamineWorker

        private static IEnumerable<Project> GetProjectsToExamineWorker(
            Solution solution,
            IImmutableSet<Project> projects,
            IEnumerable<ProjectId> projectsThatCouldReferenceType)
        {
            var dependencyGraph = solution.GetProjectDependencyGraph();

            // Take the projects that were passed in, and find all the projects that 
            // they depend on (including themselves).  i.e. if we have a solution that
            // looks like:
            //      A <- B <- C <- D
            //          /
            //         └
            //        E
            // and we're passed in 'B, C, E' as hte project to search, then this set 
            // will be A, B, C, E.
            var allProjectsThatTheseProjectsDependOn = projects
                .SelectMany(p => dependencyGraph.GetProjectsThatThisProjectTransitivelyDependsOn(p.Id))
                .Concat(projects.Select(p => p.Id)).ToSet();

            // We then intersect this set with the actual set of projects that could reference
            // the type.  Say this list is B, C, D.  The intersection of this list and the above
            // one will then be 'B' and 'C'.  
            //
            // In other words, there is no point searching A and E (because they can't even 
            // reference the type).  And there's no point searching 'D' because it can't contribute
            // any information that would affect the result in the projects we are asked to search
            // within.

            return projectsThatCouldReferenceType.Intersect(allProjectsThatTheseProjectsDependOn)
                                                 .Select(solution.GetProject)
                                                 .ToList();
        }
开发者ID:natidea,项目名称:roslyn,代码行数:33,代码来源:DependentTypeFinder.cs

示例7: OrderTopologically

        private static List<Project> OrderTopologically(
            Solution solution, IEnumerable<Project> projectsToExamine)
        {
            var order = new Dictionary<ProjectId, int>(capacity: solution.ProjectIds.Count);

            int index = 0;

            var dependencyGraph = solution.GetProjectDependencyGraph();
            foreach (var projectId in dependencyGraph.GetTopologicallySortedProjects())
            {
                order.Add(projectId, index);
                index++;
            }

            return projectsToExamine.OrderBy((p1, p2) => order[p1.Id] - order[p2.Id]).ToList();
        }
开发者ID:natidea,项目名称:roslyn,代码行数:16,代码来源:DependentTypeFinder.cs

示例8: GetProjectsThatCouldReferenceTypeAsync

        private static async Task<ISet<ProjectId>> GetProjectsThatCouldReferenceTypeAsync(
            INamedTypeSymbol type, 
            Solution solution, 
            bool searchInMetadata,
            CancellationToken cancellationToken)
        {
            var dependencyGraph = solution.GetProjectDependencyGraph();

            if (searchInMetadata)
            {
                // For a metadata type, find all projects that refer to the metadata assembly that
                // the type is defined in.  Note: we pass 'null' for projects intentionally.  We
                // Need to find all the possible projects that contain this metadata.
                var projectsThatReferenceMetadataAssembly =
                    await DependentProjectsFinder.GetDependentProjectsAsync(
                        type, solution, projects: null, cancellationToken: cancellationToken).ConfigureAwait(false);

                // Now collect all the dependent projects as well.
                var projectsThatCouldReferenceType =
                    projectsThatReferenceMetadataAssembly.SelectMany(
                        p => GetProjectsThatCouldReferenceType(dependencyGraph, p)).ToSet();

                return projectsThatCouldReferenceType;
            }
            else
            {
                // For a source project, find the project that that type was defined in.
                var sourceProject = solution.GetProject(type.ContainingAssembly);
                if (sourceProject == null)
                {
                    return SpecializedCollections.EmptySet<ProjectId>();
                }

                // Now find all the dependent of those projects.
                var projectsThatCouldReferenceType = GetProjectsThatCouldReferenceType(
                    dependencyGraph, sourceProject).ToSet();

                return projectsThatCouldReferenceType;
            }
        }
开发者ID:natidea,项目名称:roslyn,代码行数:40,代码来源:DependentTypeFinder.cs


注:本文中的Solution.GetProjectDependencyGraph方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。