public static ProjectConfigurationDetails CreateProjectConfigurationDetails(ProjectRootSnapshot project) { return(new ProjectConfigurationDetails { IgnorePathsSection = CreateSectionDetails(project.Project.IgnorePathsConfiguration), IgnoreSearchableFilesSection = CreateSectionDetails(project.Project.IgnoreSearchableFilesConfiguration), IncludeSearchableFilesSection = CreateSectionDetails(project.Project.IncludeSearchableFilesConfiguration) }); }
private static OptionalDirectoryEntry MapDirectoryEntry(ProjectRootSnapshot project, string relativePath) { var directoryEntry = GetDirectoryEntriesRequestHandler.CreateDirectoryEntry(project, relativePath); return(directoryEntry == null ? new OptionalDirectoryEntry { HasValue = false } : new OptionalDirectoryEntry { HasValue = true, Value = directoryEntry }); }
public static DirectoryEntry CreateDirectoryEntry(ProjectRootSnapshot project, string relativePath) { var directorySnapshot = FindDirectorySnapshot(project, relativePath); if (directorySnapshot == null) { return(null); } return(new DirectoryEntry { Name = directorySnapshot.DirectoryName.RelativePath.Value, Entries = BuildEntries(directorySnapshot), }); }
private DirectorySnapshot FindDirectorySnapshot(FullPath directoryPath, ProjectRootSnapshot projectSnapshot) { var splitPath = PathHelpers.SplitPrefix(directoryPath.Value, projectSnapshot.Project.RootPath.Value); var current = projectSnapshot.Directory; foreach (var name in PathHelpers.SplitPath(splitPath.Suffix)) { current = current.ChildDirectories .FirstOrDefault(x => SystemPathComparer.EqualsNames(name, x.DirectoryName.Name)); if (current == null) { return(null); } } return(current); }
private static DirectorySnapshot FindDirectorySnapshot(ProjectRootSnapshot project, string relativePath) { if (project == null) { return(null); } var entry = project.Directory; foreach (var name in PathHelpers.SplitPath(relativePath)) { var child = entry.ChildDirectories.FirstOrDefault(x => SystemPathComparer.EqualsNames(x.DirectoryName.Name, name)); if (child == null) { entry = null; break; } entry = child; } return(entry); }
public static ProjectDetails CreateProjectDetails(IFileDatabaseSnapshot database, ProjectRootSnapshot project, int maxFilesByExtensionDetailsCount, int maxLargeFilesDetailsCount) { return(new ProjectDetails { RootPath = project.Project.RootPath.Value, DirectoryDetails = GetDirectoryDetailsRequestHandler.CreateDirectoryDetails(database, project, project.Directory, maxFilesByExtensionDetailsCount, maxLargeFilesDetailsCount), ConfigurationDetails = CreateProjectConfigurationDetails(project) }); }
public static DirectoryDetails CreateDirectoryDetails(IFileDatabaseSnapshot database, ProjectRootSnapshot projectSnapshot, DirectorySnapshot baseDirectory, int maxFilesByExtensionDetailsCount, int maxLargeFilesDetailsCount) { var directoryPath = baseDirectory.DirectoryName.FullPath; var fileDatabse = (FileDatabaseSnapshot)database; var directoryFileNames = fileDatabse.FileNames .Where(x => directoryPath.ContainsPath(x.FullPath)) .ToHashSet(); var directoryFiles = fileDatabse.Files.Values .Where(x => directoryFileNames.Contains(x.FileName)) .ToList(); var searchableFiles = directoryFiles .Where(x => x.HasContents()) .ToList(); var binaryFiles = directoryFiles .Where(x => (x.Contents is BinaryFileContents) && (((BinaryFileContents)x.Contents).BinaryFileSize > 0)) .ToList(); return(new DirectoryDetails { Path = directoryPath.Value, DirectoryCount = FileSystemSnapshotManager.CountDirectoryEntries(baseDirectory), FileCount = FileSystemSnapshotManager.CountFileEntries(baseDirectory), SearchableFilesCount = searchableFiles.Count, SearchableFilesByteLength = searchableFiles.Aggregate(0L, (acc, x) => acc + x.Contents.ByteLength), BinaryFilesCount = binaryFiles.Count, BinaryFilesByteLength = binaryFiles.Aggregate(0L, (acc, x) => acc + ((BinaryFileContents)x.Contents).BinaryFileSize), SearchableFilesByExtensionDetails = searchableFiles .GroupBy(x => GetFileExtension(x.FileName)) .Select(g => new FileByExtensionDetails { FileExtension = g.Key, FileCount = g.Count(), FilesByteLength = g.Aggregate(0L, (acc, x) => acc + x.Contents.ByteLength) }) .OrderByDescendingThenTake(maxFilesByExtensionDetailsCount, x => x.FilesByteLength) .ToList(), LargeSearchableFilesDetails = searchableFiles .OrderByDescendingThenTake(maxLargeFilesDetailsCount, x => x.Contents.ByteLength) .Select(x => new LargeFileDetails { RelativePath = GetRelativePath(directoryPath, x.FileName.FullPath), ByteLength = x.Contents.ByteLength }) .ToList(), BinaryFilesByExtensionDetails = binaryFiles .GroupBy(x => GetFileExtension(x.FileName)) .Select(g => new FileByExtensionDetails { FileExtension = g.Key, FileCount = g.Count(), FilesByteLength = g.Aggregate(0L, (acc, x) => acc + ((BinaryFileContents)x.Contents).BinaryFileSize) }) .OrderByDescendingThenTake(maxFilesByExtensionDetailsCount, x => x.FilesByteLength) .ToList(), LargeBinaryFilesDetails = binaryFiles .OrderByDescendingThenTake(maxLargeFilesDetailsCount, x => ((BinaryFileContents)x.Contents).BinaryFileSize) .Select(x => new LargeFileDetails { RelativePath = GetRelativePath(directoryPath, x.FileName.FullPath), ByteLength = ((BinaryFileContents)x.Contents).BinaryFileSize }) .ToList() }); }