Example #1
0
        // get the FolderComposite object representing the the project's folder 'targetFolder'. Build the needed FolderComposite(s) for a complete path
        private FsharpFolderComposite GetOrBuildFolderComposite(IDictionary <string, FsharpFolderComposite> cache, string targetFolder, string projectUnderTestDir,
                                                                string projectRoot, FsharpFolderComposite inputFiles)
        {
            if (cache.ContainsKey(targetFolder))
            {
                return(cache[targetFolder]);
            }

            var folder = targetFolder;
            FsharpFolderComposite subDir = null;

            while (!string.IsNullOrEmpty(folder))
            {
                if (!cache.ContainsKey(folder))
                {
                    // we have not scanned this folder yet
                    var sub          = Path.GetFileName(folder);
                    var fullPath     = FileSystem.Path.Combine(projectUnderTestDir, sub);
                    var newComposite = new FsharpFolderComposite
                    {
                        FullPath     = fullPath,
                        RelativePath = Path.GetRelativePath(projectRoot, fullPath),
                    };
                    if (subDir != null)
                    {
                        newComposite.Add(subDir);
                    }

                    cache.Add(folder, newComposite);
                    subDir = newComposite;
                    folder = Path.GetDirectoryName(folder);
                    if (string.IsNullOrEmpty(folder))
                    {
                        // we are at root
                        inputFiles.Add(subDir);
                    }
                }
                else
                {
                    (cache[folder]).Add(subDir);
                    break;
                }
            }

            return(cache[targetFolder]);
        }
Example #2
0
        private FsharpFolderComposite FindProjectFilesScanningProjectFolders(IAnalyzerResult analyzerResult)
        {
            var inputFiles          = new FsharpFolderComposite();
            var projectUnderTestDir = Path.GetDirectoryName(analyzerResult.ProjectFilePath);

            foreach (var dir in ExtractProjectFolders(analyzerResult))
            {
                var folder = FileSystem.Path.Combine(Path.GetDirectoryName(projectUnderTestDir), dir);

                _logger.LogDebug($"Scanning {folder}");
                if (!FileSystem.Directory.Exists(folder))
                {
                    throw new DirectoryNotFoundException($"Can't find {folder}");
                }

                inputFiles.Add(FindInputFiles(projectUnderTestDir, analyzerResult));
            }

            return(inputFiles);
        }