本文整理汇总了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);
}
}
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
}
}
示例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();
}
示例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();
}
示例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;
}
}