/// <summary> /// Create a project instance corresponding to the vschromium project file /// on disk at <paramref name="rootPath"/>. /// Return <code>null</code> if there is no project file. /// </summary> private Project CreateProject(FullPath rootPath) { var projectFilePath = rootPath.Combine(new RelativePath(ConfigurationFileNames.ProjectFileName)); var sectionName = ConfigurationSectionNames.SourceExplorerIgnore; if (!_fileSystem.FileExists(projectFilePath)) { projectFilePath = rootPath.Combine(new RelativePath(ConfigurationFileNames.ProjectFileNameObsolete)); sectionName = ConfigurationSectionNames.SourceExplorerIgnoreObsolete; if (!_fileSystem.FileExists(projectFilePath)) { return(null); } } var fileWithSections = new FileWithSections(_fileSystem, projectFilePath); var configurationProvider = new FileWithSectionConfigurationProvider(fileWithSections); var s1 = ConfigurationSectionContents.Create(configurationProvider, sectionName); var s2 = ConfigurationSectionContents.Create(configurationProvider, ConfigurationSectionNames.SearchableFilesIgnore); var s3 = ConfigurationSectionContents.Create(configurationProvider, ConfigurationSectionNames.SearchableFilesInclude); var fileFilter = new FileFilter(s1); var directoryFilter = new DirectoryFilter(s1); var searchableFilesFilter = new SearchableFilesFilter(s2, s3); return(new Project(rootPath, fileFilter, directoryFilter, searchableFilesFilter, fileWithSections.Hash)); }
public void CombinePath() { var actual = FullPath.FromPath("test") / "a" / ".." / "a" / "." / "b"; var expected = FullPath.Combine("test", "a", "b"); Assert.Equal(expected, actual); }
public void MakeRelativeTo(string childPath, string expected) { var rootPath = FullPath.FromPath("test"); var path1 = FullPath.Combine("test", childPath); Assert.Equal(expected, path1.MakePathRelativeTo(rootPath)); }
public void IsChildOf_True(string root, string path) { var rootPath = FullPath.FromPath(root); var childPath = FullPath.Combine(root, path); Assert.True(childPath.IsChildOf(rootPath)); }
private FullPath GetArgumentPrinterPath() { var fileName = "ArgumentsPrinter.dll"; var testedPaths = new List <FullPath>(); var configurations = new[] { "Debug", "Release" }; foreach (var configuration in configurations) { var path = FullPath.Combine(Environment.CurrentDirectory, "..", "..", "..", "..", "ArgumentsPrinter", "bin", configuration, "net6.0", fileName); if (File.Exists(path)) { _testOutputHelper.WriteLine($"Use ArgumentsPrinter located at '{path}'"); return(path); } testedPaths.Add(path); } var existingFiles = new List <string>(); foreach (var testedPath in testedPaths) { var path = testedPath.Parent; if (Directory.Exists(path)) { existingFiles.AddRange(Directory.GetFiles(path, "*", SearchOption.AllDirectories)); } } existingFiles.Sort(StringComparer.Ordinal); throw new XunitException($"File not found:\n{string.Join("\n", testedPaths)}\n. List of existing files:\n{string.Join("\n", existingFiles)}\nHave you built the ArgumentsPrinter project?"); }
private void CreateEntries(DirectoryEntry searchResults) { if (!_enabled) return; using (new TimeElapsedLogger("Creating document tracking entries for search results")) { _searchResults.Clear(); foreach (DirectoryEntry projectRoot in searchResults.Entries) { var rootPath = new FullPath(projectRoot.Name); foreach (FileEntry fileEntry in projectRoot.Entries) { var path = rootPath.Combine(new RelativePath(fileEntry.Name)); var spans = fileEntry.Data as FilePositionsData; if (spans != null) { _searchResults[path] = spans; // If the document is open, create the tracking spans now. var document = _textDocumentTable.GetOpenDocument(path); if (document != null) { var entry = new DocumentChangeTrackingEntry(spans); _trackingEntries[path] = entry; entry.CreateTrackingSpans(document.TextBuffer); } } } } } }
private void CreateEntries(DirectoryEntry searchResults) { if (!_enabled) { return; } using (new TimeElapsedLogger("Creating document tracking entries for search results", InfoLogger.Instance)) { _searchResults.Clear(); foreach (DirectoryEntry projectRoot in searchResults.Entries) { var rootPath = new FullPath(projectRoot.Name); foreach (FileEntry fileEntry in projectRoot.Entries) { var path = rootPath.Combine(new RelativePath(fileEntry.Name)); var spans = fileEntry.Data as FilePositionsData; if (spans != null) { _searchResults[path] = spans; // If the document is open, create the tracking spans now. var document = _textDocumentTable.GetOpenDocument(path); if (document != null) { var entry = new DocumentChangeTrackingEntry(spans); _trackingEntries[path] = entry; entry.CreateTrackingSpans(document.TextBuffer); } } } } } }
private IEnumerable <FullPath> GetCandidateProcessPaths() { var folder = new FullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); yield return(folder.Combine(new RelativePath(ProxyServerName))); var serverFolder = folder.Parent.Parent; yield return(serverFolder.Combine(new RelativePath("bin\\Debug")).Combine(new RelativePath(ServerName))); yield return(serverFolder.Combine(new RelativePath("bin\\Release")).Combine(new RelativePath(ServerName))); }
/// <summary> /// Create a project instance corresponding to the vschromium project file /// on disk at <paramref name="rootPath"/>. /// Return <code>null</code> if there is no project file. /// </summary> private Project CreateProject(FullPath rootPath, FullPath searchPath) { var projectFilePath = rootPath.Combine(new RelativePath(ConfigurationFileNames.ProjectFileName)); var ignorePathsSectionName = ConfigurationSectionNames.SourceExplorerIgnore; if (!_fileSystem.FileExists(projectFilePath)) { projectFilePath = rootPath.Combine(new RelativePath(ConfigurationFileNames.ProjectFileNameObsolete)); ignorePathsSectionName = ConfigurationSectionNames.SourceExplorerIgnoreObsolete; if (!_fileSystem.FileExists(projectFilePath)) { return(null); } } var fileWithSections = new FileWithSections(_fileSystem, projectFilePath); var configurationProvider = new FileWithSectionConfigurationProvider(fileWithSections); var propertiesSection = ConfigurationSectionContents.Create(configurationProvider, ConfigurationSectionNames.Properties); var ignorePathsSection = ConfigurationSectionContents.Create(configurationProvider, ignorePathsSectionName); var ignoreSearchableFilesSection = ConfigurationSectionContents.Create(configurationProvider, ConfigurationSectionNames.SearchableFilesIgnore); var includeSearchableFilesSection = ConfigurationSectionContents.Create(configurationProvider, ConfigurationSectionNames.SearchableFilesInclude); var propertyCollection = new PropertyCollection(propertiesSection); var fileFilter = new FileFilter(ignorePathsSection); var directoryFilter = new DirectoryFilter(ignorePathsSection); var searchableFilesFilter = new SearchableFilesFilter(ignoreSearchableFilesSection, includeSearchableFilesSection); int rootDepth = 0; FullPath modifiedRootPath = rootPath; if (propertyCollection.TryGetInt("RootDepth", out rootDepth) && rootDepth > 0) { int rootPathDepth = rootPath.ToString().Split(Path.DirectorySeparatorChar).Count(); IEnumerable <string> pathComponents = searchPath.ToString().Split(Path.DirectorySeparatorChar); modifiedRootPath = new FullPath(string.Join(Path.DirectorySeparatorChar.ToString(), pathComponents.Take(rootPathDepth + rootDepth))); } return(new Project(modifiedRootPath, ignorePathsSection, ignoreSearchableFilesSection, includeSearchableFilesSection, fileFilter, directoryFilter, searchableFilesFilter, fileWithSections.Hash)); }
private string LoadConfigFile(string name) { var localFileSystem = new FileSystem(); var path = new FullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)) .Combine(new RelativePath(ConfigurationDirectoryNames.LocalInstallConfigurationDirectoryName)); var filePath = path.Combine(new RelativePath(name)); if (localFileSystem.FileExists(filePath)) { return(localFileSystem.ReadText(filePath)); } throw Invariants.Fail("File not found"); }
public void WindowsCmdArgument_Test(string value, string expected) { var args = CommandLineBuilder.WindowsCmdArgument(value); var batPath = FullPath.Combine(Path.GetTempPath(), Guid.NewGuid() + ".cmd"); var path = GetArgumentPrinterPath(); var fileContent = "dotnet \"" + path + "\" " + args; File.WriteAllText(batPath, fileContent); var cmdArguments = "/Q /C \"" + batPath + "\""; _testOutputHelper.WriteLine($"Executing 'cmd.exe' '{cmdArguments}' with batch content:\n{fileContent}"); ValidateArguments("cmd.exe", cmdArguments, new[] { expected }); }
private FullPath GetArgumentPrinterPath() { var fileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "ArgumentsPrinter.exe" : "ArgumentsPrinter"; var testedPaths = new List <FullPath>(); var configurations = new[] { "Debug", "Release" }; foreach (var configuration in configurations) { var path = FullPath.Combine(Environment.CurrentDirectory, "..", "..", "..", "..", "ArgumentsPrinter", "bin", configuration, "net5.0", fileName); if (File.Exists(path)) { _testOutputHelper.WriteLine($"Use ArgumentsPrinter located at '{path}'"); return(path); } testedPaths.Add(path); } throw new XunitException($"File not found:\n- {string.Join("- ", testedPaths)}\nHave you built the ArgumentsPrinter project?"); }
/// <summary> /// Create a project instance corresponding to the vschromium project file /// on disk at <paramref name="rootPath"/>. /// Return <code>null</code> if there is no project file. /// </summary> private Project CreateProject(FullPath rootPath) { var projectFilePath = rootPath.Combine(new RelativePath(ConfigurationFileNames.ProjectFileName)); var sectionName = ConfigurationSectionNames.SourceExplorerIgnore; if (!_fileSystem.FileExists(projectFilePath)) { projectFilePath = rootPath.Combine(new RelativePath(ConfigurationFileNames.ProjectFileNameObsolete)); sectionName = ConfigurationSectionNames.SourceExplorerIgnoreObsolete; if (!_fileSystem.FileExists(projectFilePath)) { return null; } } var fileWithSections = new FileWithSections(_fileSystem, projectFilePath); var configurationProvider = new FileWithSectionConfigurationProvider(fileWithSections); var s1 = ConfigurationSectionContents.Create(configurationProvider, sectionName); var s2 = ConfigurationSectionContents.Create(configurationProvider, ConfigurationSectionNames.SearchableFilesIgnore); var s3 = ConfigurationSectionContents.Create(configurationProvider, ConfigurationSectionNames.SearchableFilesInclude); var fileFilter = new FileFilter(s1); var directoryFilter = new DirectoryFilter(s1); var searchableFilesFilter = new SearchableFilesFilter(s2, s3); return new Project(rootPath, fileFilter, directoryFilter, searchableFilesFilter, fileWithSections.Hash); }
private IEnumerable<FullPath> GetCandidateProcessPaths() { var folder = new FullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); yield return folder.Combine(new RelativePath(ProxyServerName)); var serverFolder = folder.Parent.Parent; yield return serverFolder.Combine(new RelativePath("bin\\Debug")).Combine(new RelativePath(ServerName)); yield return serverFolder.Combine(new RelativePath("bin\\Release")).Combine(new RelativePath(ServerName)); }
static async Task Main(string[] args) { var outputDirectory = FullPath.FromPath(args[0]); var githubToken = args.Length > 1 ? args[1] : null; var client = githubToken != null ? new GitHubClient(new ProductHeaderValue("issue-to-rss"), new InMemoryCredentialStore(new Credentials(githubToken))) : new GitHubClient(new ProductHeaderValue("issue-to-rss")); var feeds = new List <FeedData>(); await Configuration.Repositories.ParallelForEachAsync(degreeOfParallelism : 16, async repository => { Console.WriteLine("Generating feed for " + repository); // Get issues var issuesItems = new List <SyndicationItem>(200); var prItems = new List <SyndicationItem>(200); var parts = repository.Split('/'); var repositoryOwner = parts[0]; var repositoryName = parts[1]; foreach (var issue in await GetIssuesForRepository(client, repositoryOwner, repositoryName)) { if (Configuration.ExcludedUsers.Contains(issue.User.Login)) { continue; } if (issue.Labels.Any(label => Configuration.ExcludedLabels.Contains(label.Name))) { continue; } var isPullRequest = issue.PullRequest != null; var title = (isPullRequest ? "PR: " : "Issue: ") + issue.Title + " - @" + issue.User.Login; var item = new SyndicationItem { Id = issue.HtmlUrl, Title = new TextSyndicationContent(SanitizeString(title)), Content = new TextSyndicationContent(SanitizeString(Markdig.Markdown.ToHtml(issue.Body ?? ""))), Links = { SyndicationLink.CreateAlternateLink(new Uri(issue.HtmlUrl)), }, PublishDate = issue.CreatedAt, LastUpdatedTime = issue.CreatedAt, Authors = { new SyndicationPerson(issue.User.Email, issue.User.Login, issue.User.HtmlUrl), } }; if (isPullRequest) { prItems.Add(item); } else { issuesItems.Add(item); } } // Generate feeds { var issuesFeed = new SyndicationFeed { Title = new TextSyndicationContent(repository + " Issues"), Description = new TextSyndicationContent($"Issues from https://github.com/{repository}, generated by {Configuration.GitHubRepositoryUrl}"), Items = issuesItems, TimeToLive = TimeSpan.FromHours(1), Authors = { new SyndicationPerson("*****@*****.**", "Gérald Barré", "https://www.meziantou.net/") }, }; lock (feeds) { feeds.Add(new FeedData { Feed = issuesFeed, OutputRelativePath = $"{repository}.issues.rss" }); } } { var prFeed = new SyndicationFeed { Title = new TextSyndicationContent(repository + " Pull Requests"), Description = new TextSyndicationContent($"Pull Requests from https://github.com/{repository}, generated by {Configuration.GitHubRepositoryUrl}", TextSyndicationContentKind.Html), Items = prItems, TimeToLive = TimeSpan.FromHours(1), Authors = { new SyndicationPerson("*****@*****.**", "Gérald Barré", "https://www.meziantou.net/") }, }; lock (feeds) { feeds.Add(new FeedData { Feed = prFeed, OutputRelativePath = $"{repository}.pr.rss" }); } } }); feeds.Sort((a, b) => a.OutputRelativePath.CompareTo(b.OutputRelativePath)); // Write feeds foreach (var feedData in feeds) { Console.WriteLine($"Writing feed '{feedData.OutputRelativePath}'"); var feedPath = FullPath.Combine(outputDirectory, feedData.OutputRelativePath); Directory.CreateDirectory(feedPath.Parent); using var stream = File.OpenWrite(feedPath); using var xmlWriter = XmlWriter.Create(stream, new XmlWriterSettings() { Indent = true }); var rssFormatter = new Rss20FeedFormatter(feedData.Feed, serializeExtensionsAsAtom: false); rssFormatter.WriteTo(xmlWriter); } // index.opml { Console.WriteLine("Generating opml"); var indexPath = FullPath.Combine(outputDirectory, "feeds.opml"); Directory.CreateDirectory(indexPath.Parent); var document = new XDocument( new XElement("opml", new XAttribute("version", "1.0"), new XElement("head", new XElement("title", "GitHub issues feeds")), new XElement("body", feeds.Select(GetOutline).ToArray()))); using var stream = File.OpenWrite(indexPath); using var xmlWriter = XmlWriter.Create(stream, new XmlWriterSettings() { Indent = true }); document.WriteTo(xmlWriter);
private Project CreateProject(FullPath rootPath) { var fileWithSections = new FileWithSections(_fileSystem, rootPath.Combine(new RelativePath(ConfigurationFilenames.ProjectFileNameDetection))); var configurationProvider = new FileWithSectionConfigurationProvider(fileWithSections); return new Project(configurationProvider, rootPath); }
public bool ContainsProjectFile(FullPath path) { return _fileSystem.FileExists(path.Combine(new RelativePath(ConfigurationFilenames.ProjectFileNameDetection))); }