public IEnumerable <string> GetIgnorePatterns() { var raw = IgnorePatterns.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); foreach (string pattern in raw) { yield return(pattern.Trim()); } }
public void ReportFileSystemChanged(string path) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } var monitorPath = !IgnorePatterns.ShouldIgnore(path); // Ignore certain files var tempIgnorePaths = _tempIgnoredPaths.Keys.ToList(); // If the parent of an ignored path has a change event, ignore that too if (tempIgnorePaths.Any(i => { if (_fileSystem.AreEqual(i, path)) { _logger.LogDebug("Ignoring change to {Path}", path); return(true); } if (_fileSystem.ContainsSubPath(i, path)) { _logger.LogDebug("Ignoring change to {Path}", path); return(true); } // Go up a level var parent = Path.GetDirectoryName(i); if (!string.IsNullOrEmpty(parent) && _fileSystem.AreEqual(parent, path)) { _logger.LogDebug("Ignoring change to {Path}", path); return(true); } return(false); })) { monitorPath = false; } if (monitorPath) { // Avoid implicitly captured closure CreateRefresher(path); } }
public XElement ToXml() => new XElement( nameof(UsageData), CreatedByRid == null ? null : new XElement( nameof(CreatedByRid), CreatedByRid), ProjectDirectories?.Any() != true ? null : new XElement( nameof(ProjectDirectories), ProjectDirectories .Select(dir => new XElement("Dir", dir))), NeverRestoredTarballPrebuilts?.Any() != true ? null : new XElement( nameof(NeverRestoredTarballPrebuilts), NeverRestoredTarballPrebuilts .OrderBy(id => id) .Select(id => id.ToXElement())), IgnorePatterns?.Any() != true ? null : new XElement( nameof(IgnorePatterns), IgnorePatterns .Select(p => p.ToXml())), Usages?.Any() != true ? null : new XElement( nameof(Usages), Usages .OrderBy(u => u.PackageIdentity) .ThenByOrdinal(u => u.AssetsFile) .Select(u => u.ToXml())));
// This test is pending an upstream fix: https://github.com/dazinator/DotNet.Glob/issues/78 // [InlineData("/media/music/Foo B.A.R.", false)] public void PathIgnored(string path, bool expected) { Assert.Equal(expected, IgnorePatterns.ShouldIgnore(path)); }