private async Task IndexProjectAsync( SearchCode repoInfo, ConcurrentDictionary <PackageReference, HashSet <RepoInfo> > graph, IScanProgress scanProgress) { var projectContent = await _client.Repository.Content.GetAllContents(repoInfo.Repository.Id, repoInfo.Path); var repo = RepoInfo.Parse(repoInfo.Repository.Name, repoInfo.HtmlUrl); var nugetRefs = _projectFileParser.Parse(projectContent[0].Content); Console.WriteLine($"Repo name {repoInfo.Repository.Name} file name {repoInfo.Name}"); foreach (var nugetRef in nugetRefs) { if (!graph.TryGetValue(nugetRef, out var repoInfos)) { repoInfos = new HashSet <RepoInfo>(); } repoInfos.Add(repo); graph[nugetRef] = repoInfos; } scanProgress.UpdateProjectProgress(); }
private void IndexProject( SrcFileInfo searchFile, ConcurrentDictionary <PackageReference, HashSet <RepoInfo> > graph, IScanProgress scanProgress) { var fileName = Path.GetFileName(searchFile.path); if (!fileName.EndsWith(".csproj")) { return; } var repoSlug = ExtractSlugFromUrl(searchFile.links.self.href); if (_skipRepos.Contains(repoSlug)) { Console.WriteLine($"Skipped {repoSlug}"); return; } var repoResource = _client.RepositoriesEndPoint().RepositoryResource(_bbAccount, repoSlug); if (!_reposCache.TryGetValue(repoSlug, out var repo)) { var repoInfo = repoResource.GetRepository(); var fileLink = $"{repoInfo.links.html.href}/src/master/{searchFile.path}"; repo = RepoInfo.Parse(repoInfo.slug, fileLink); _reposCache.Add(repoSlug, repo); scanProgress.UpdateRepoProgress(); } var projectContent = repoResource.SrcResource().GetFileContent(searchFile.path); var nugetRefs = ProjectFileParser.Parse(projectContent); foreach (var nugetRef in nugetRefs) { if (!graph.TryGetValue(nugetRef, out var repoInfos)) { repoInfos = new HashSet <RepoInfo>(); } repoInfos.Add(repo); graph[nugetRef] = repoInfos; } scanProgress.UpdateProjectProgress(); Console.WriteLine($"Processed {fileName} from {repo.Name}"); }