Пример #1
0
        private ProjectFileName CreateProjectFileNameFromChangeEntry(PathChangeEntry entry)
        {
            var project = _projectDiscovery.GetProject(entry.BasePath);

            if (project == null)
            {
                return(default(ProjectFileName));
            }
            return(_fileSystemNameFactory.CreateProjectFileNameFromRelativePath(project, entry.RelativePath));
        }
Пример #2
0
        private bool PathIsExcluded(PathChangeEntry change)
        {
            // If path is root itself, it is never excluded.
            if (change.RelativePath.IsEmpty)
            {
                return(false);
            }

            var project = _projectDiscovery.GetProject(change.BasePath);

            if (project == null)
            {
                return(true);
            }

            // Split relative part into list of name components.
            var names = PathHelpers.SplitPath(change.RelativePath.Value).ToList();

            // Check each relative path from root path to full path.
            var pathToItem = new RelativePath();

            foreach (var item in names)
            {
                var relativePathToItem = pathToItem.CreateChild(item);

                bool exclude;
                // For the last component, we don't know if it is a file or directory.
                // Check depending on the change kind.
                if (item == names.Last())
                {
                    // Try to avoid Disk I/O if the path should be excluded
                    var fileShouldBeIgnored      = !project.FileFilter.Include(relativePathToItem);
                    var directoryShouldBeIgnored = !project.DirectoryFilter.Include(relativePathToItem);
                    if (fileShouldBeIgnored && directoryShouldBeIgnored)
                    {
                        exclude = true;
                    }
                    else
                    {
                        if (change.ChangeKind == PathChangeKind.Deleted)
                        {
                            // Note: Not sure why this is the case.
                            exclude = false;
                        }
                        else
                        {
                            var info = _fileSystem.GetFileInfoSnapshot(change.Path);
                            if (info.IsFile)
                            {
                                exclude = fileShouldBeIgnored;
                            }
                            else if (info.IsDirectory)
                            {
                                exclude = directoryShouldBeIgnored;
                            }
                            else
                            {
                                // We don't know... Be conservative.
                                exclude = false;
                            }
                        }
                    }
                }
                else
                {
                    exclude = !project.DirectoryFilter.Include(relativePathToItem);
                }

                if (exclude)
                {
                    return(true);
                }

                pathToItem = relativePathToItem;
            }
            return(false);
        }
Пример #3
0
 private static bool IsProjectFileChange(PathChangeEntry change)
 {
     return
         (SystemPathComparer.Instance.StringComparer.Equals(change.Path.FileName, ConfigurationFileNames.ProjectFileNameObsolete) ||
          SystemPathComparer.Instance.StringComparer.Equals(change.Path.FileName, ConfigurationFileNames.ProjectFileName));
 }
    private bool PathIsExcluded(PathChangeEntry change) {
      var path = change.Path;
      var project = _projectDiscovery.GetProject(path);
      if (project == null)
        return true;

      // If path is root itself, it is never excluded.
      if (path == project.RootPath)
        return false;

      // Split relative part into list of name components.
      var split = PathHelpers.SplitPrefix(path.Value, project.RootPath.Value);
      var relativePath = split.Suffix;
      var names = relativePath.Split(Path.DirectorySeparatorChar);

      // Check each relative path from root path to full path.
      var pathToItem = new RelativePath();
      foreach (var item in names) {
        var relativePathToItem = pathToItem.CreateChild(item);

        bool exclude;
        // For the last component, we might not if it is a file or directory.
        // Check depending on the change kind.
        if (item == names.Last()) {
          if (change.Kind == PathChangeKind.Deleted) {
            exclude = false;
          } else {
            var info = _fileSystem.GetFileInfoSnapshot(path);
            if (info.IsFile) {
              exclude = !project.FileFilter.Include(relativePathToItem);
            } else if (info.IsDirectory) {
              exclude = !project.DirectoryFilter.Include(relativePathToItem);
            } else {
              // We don't know... Be conservative.
              exclude = false;
            }
          }
        } else {
          exclude = !project.DirectoryFilter.Include(relativePathToItem);
        }

        if (exclude)
          return true;

        pathToItem = relativePathToItem;
      }
      return false;
    }
 private static bool IsProjectFileChange(PathChangeEntry change) {
   return 
     SystemPathComparer.Instance.StringComparer.Equals(change.Path.FileName, ConfigurationFileNames.ProjectFileNameObsolete) ||
     SystemPathComparer.Instance.StringComparer.Equals(change.Path.FileName, ConfigurationFileNames.ProjectFileName);
 }