public ITargetedDependenciesSnapshot?GetSnapshot(IDependency dependency) { IDependenciesSnapshot?snapshot = GetSnapshot(dependency.FullPath); if (snapshot == null) { return(null); } ITargetFramework?targetFramework = _targetFrameworkProvider.GetNearestFramework( dependency.TargetFramework, snapshot.Targets.Keys); if (targetFramework == null) { return(null); } return(snapshot.Targets[targetFramework]); }
public override bool MatchSearchResults( string projectPath, IDependency topLevelDependency, Dictionary <string, HashSet <IDependency> > searchResultsPerContext, out HashSet <IDependency> topLevelDependencyMatches) { topLevelDependencyMatches = new HashSet <IDependency>(); if (!topLevelDependency.Flags.Contains(DependencyTreeFlags.ProjectNodeFlags)) { return(false); } if (!topLevelDependency.Visible) { return(true); } string projectFullPath = topLevelDependency.FullPath; if (!searchResultsPerContext.TryGetValue(projectFullPath, out HashSet <IDependency> contextResults) || contextResults.Count == 0) { return(true); } ITargetFramework nearestTargetFramework = _targetFrameworkProvider.GetNearestFramework( topLevelDependency.TargetFramework, contextResults.Select(x => x.TargetFramework)); if (nearestTargetFramework == null) { return(true); } IEnumerable <IDependency> targetedResultsFromContext = contextResults.Where(x => nearestTargetFramework.Equals(x.TargetFramework)); topLevelDependencyMatches.AddRange(targetedResultsFromContext); return(true); }