public RProjectLoadHooks(UnconfiguredProject unconfiguredProject , [ImportMany("Microsoft.VisualStudio.ProjectSystem.Microsoft.VisualStudio.Shell.Interop.IVsProject")] IEnumerable <Lazy <IVsProject> > cpsIVsProjects , IProjectLockService projectLockService , IRInteractiveWorkflowProvider workflowProvider , IInteractiveWindowComponentContainerFactory componentContainerFactory , IRToolsSettings toolsSettings , IThreadHandling threadHandling , ISurveyNewsService surveyNews , [Import(AllowDefault = true)] IProjectItemDependencyProvider dependencyProvider , ICoreShell coreShell) { _unconfiguredProject = unconfiguredProject; _cpsIVsProjects = cpsIVsProjects; _projectLockService = projectLockService; _workflowProvider = workflowProvider; _toolsSettings = toolsSettings; _threadHandling = threadHandling; _surveyNews = surveyNews; _dependencyProvider = dependencyProvider; _coreShell = coreShell; _projectDirectory = unconfiguredProject.GetProjectDirectory(); unconfiguredProject.ProjectRenamedOnWriter += ProjectRenamedOnWriter; unconfiguredProject.ProjectUnloading += ProjectUnloading; _fileWatcher = new MsBuildFileSystemWatcher(_projectDirectory, "*", 25, 1000, _coreShell.Services.FileSystem, new RMsBuildFileSystemFilter(), coreShell.Services.Log); _fileWatcher.Error += FileWatcherError; Project = new FileSystemMirroringProject(unconfiguredProject, projectLockService, _fileWatcher, _dependencyProvider, coreShell.Services.Log); }
public RProjectLoadHooks(UnconfiguredProject unconfiguredProject , [ImportMany("Microsoft.VisualStudio.ProjectSystem.Microsoft.VisualStudio.Shell.Interop.IVsProject")] IEnumerable <Lazy <IVsProject> > cpsIVsProjects , IProjectLockService projectLockService , IRInteractiveWorkflowProvider workflowProvider , IInteractiveWindowComponentContainerFactory componentContainerFactory , IRToolsSettings toolsSettings , IFileSystem fileSystem , IThreadHandling threadHandling , ISurveyNewsService surveyNews) { _unconfiguredProject = unconfiguredProject; _cpsIVsProjects = cpsIVsProjects; _workflowProvider = workflowProvider; _componentContainerFactory = componentContainerFactory; _toolsSettings = toolsSettings; _fileSystem = fileSystem; _threadHandling = threadHandling; _surveyNews = surveyNews; _projectDirectory = unconfiguredProject.GetProjectDirectory(); unconfiguredProject.ProjectUnloading += ProjectUnloading; _fileWatcher = new MsBuildFileSystemWatcher(_projectDirectory, "*", 25, 1000, fileSystem, new RMsBuildFileSystemFilter()); _fileWatcher.Error += FileWatcherError; Project = new FileSystemMirroringProject(unconfiguredProject, projectLockService, _fileWatcher); }
public void Start() { var filter = "*"; var delay = 0; var fileSystem = Substitute.For <IFileSystem>(); var fileSystemFilter = Substitute.For <IMsBuildFileSystemFilter>(); MsBuildFileSystemWatcher watcher = new MsBuildFileSystemWatcher(ProjectDirectory, filter, delay, delay, fileSystem, fileSystemFilter, log: NullLog.Instance); fileSystemFilter.Received().Seal(); var fileSystemWatchers = new List <IFileSystemWatcher>(); fileSystem.CreateFileSystemWatcher(ProjectDirectory, filter) .Returns(ci => { var w = Substitute.For <IFileSystemWatcher>(); fileSystemWatchers.Add(w); return(w); }); watcher.Start(); watcher.Dispose(); foreach (var fileSystemWatcher in fileSystemWatchers) { fileSystemWatcher.Received().Dispose(); } }
public FileSystemMirroringProject(UnconfiguredProject unconfiguredProject, IProjectLockService projectLockService, MsBuildFileSystemWatcher fileSystemWatcher, IActionLog log = null) { _unconfiguredProject = unconfiguredProject; _projectLockService = projectLockService; _fileSystemWatcher = fileSystemWatcher; _log = log ?? ProjectSystemActionLog.Default; _unloadCancellationToken = _unconfiguredProject.Services.ProjectAsynchronousTasks.UnloadCancellationToken; _projectDirectory = _unconfiguredProject.GetProjectDirectory(); _inMemoryImportFullPath = _unconfiguredProject.GetInMemoryTargetsFileFullPath(); _fileItems = new Dictionary <string, ProjectItemElement>(StringComparer.OrdinalIgnoreCase); _directoryItems = new Dictionary <string, ProjectItemElement>(StringComparer.OrdinalIgnoreCase); var changesHandler = new Func <MsBuildFileSystemWatcher.Changeset, Task>(FileSystemChanged); _fileSystemWatcher.SourceBlock.LinkTo(new ActionBlock <MsBuildFileSystemWatcher.Changeset>(changesHandler)); }
public LoadHooks(UnconfiguredProject unconfiguredProject , [ImportMany("Microsoft.VisualStudio.ProjectSystem.Microsoft.VisualStudio.Shell.Interop.IVsProject")] IEnumerable <Lazy <IVsProject> > cpsIVsProjects , IProjectLockService projectLockService , IThreadHandling threadHandling) { _unconfiguredProject = unconfiguredProject; _cpsIVsProjects = cpsIVsProjects; _threadHandling = threadHandling; _projectDirectory = unconfiguredProject.GetProjectDirectory(); var log = new DummyLogger(); unconfiguredProject.ProjectUnloading += ProjectUnloading; _fileWatcher = new MsBuildFileSystemWatcher(_projectDirectory, "*", 25, 1000, _fileSystem, new MsBuildFileSystemFilter(), log); _fileWatcher.Error += FileWatcherError; Project = new FileSystemMirroringProject(unconfiguredProject, projectLockService, _fileWatcher, null, log); }
public Delay50MsNoFiltering() { _fileSystem = Substitute.For <IFileSystem>(); var watchers = GetWatchersFromMsBuildFileSystemWatcher(_fileSystem); _fileSystemFilter = Substitute.For <IMsBuildFileSystemFilter>(); _fileSystemFilter.IsFileAllowed(Arg.Any <string>(), Arg.Any <FileAttributes>()).ReturnsForAnyArgs(true); _fileSystemFilter.IsDirectoryAllowed(Arg.Any <string>(), Arg.Any <FileAttributes>()).ReturnsForAnyArgs(true); _taskScheduler = new ControlledTaskScheduler(SynchronizationContext.Current); _fileSystemWatcher = new MsBuildFileSystemWatcher(ProjectDirectory, "*", 50, 50, _fileSystem, _fileSystemFilter, Substitute.For <IActionLog>(), _taskScheduler); _taskScheduler.Link(_fileSystemWatcher.SourceBlock, c => { _changeset = c; }); _fileSystemWatcher.Start(); _fileWatcher = watchers.FileWatcher; _directoryWatcher = watchers.DirectoryWatcher; _attributesWatcher = watchers.AttributesWatcher; }
public NoDelayNoFiltering() { _fileSystem = Substitute.For <IFileSystem>(); _fileSystem.GetFileAttributes(Arg.Any <string>()).Throws <FileNotFoundException>(); var watchers = GetWatchersFromMsBuildFileSystemWatcher(_fileSystem); var fileSystemFilter = Substitute.For <IMsBuildFileSystemFilter>(); fileSystemFilter.IsFileAllowed(Arg.Any <string>(), Arg.Any <FileAttributes>()).ReturnsForAnyArgs(true); fileSystemFilter.IsDirectoryAllowed(Arg.Any <string>(), Arg.Any <FileAttributes>()).ReturnsForAnyArgs(true); _taskScheduler = new ControlledTaskScheduler(SynchronizationContext.Current); DirectoryInfoStubFactory.Create(_fileSystem, ProjectDirectory); _fileSystemWatcher = new MsBuildFileSystemWatcher(ProjectDirectory, "*", 0, 0, _fileSystem, fileSystemFilter, _taskScheduler, NullLog.Instance); _fileSystemWatcher.Start(); _fileWatcher = watchers.FileWatcher; _directoryWatcher = watchers.DirectoryWatcher; _attributesWatcher = watchers.AttributesWatcher; }
public RProjectLoadHooks(UnconfiguredProject unconfiguredProject , [ImportMany("Microsoft.VisualStudio.ProjectSystem.Microsoft.VisualStudio.Shell.Interop.IVsProject")] IEnumerable <Lazy <IVsProject> > cpsIVsProjects , IProjectLockService projectLockService , IThreadHandling threadHandling , [Import(AllowDefault = true)] IProjectItemDependencyProvider dependencyProvider , ICoreShell coreShell) { _unconfiguredProject = unconfiguredProject; _cpsIVsProjects = cpsIVsProjects; _projectLockService = projectLockService; _settings = coreShell.GetService <IRSettings>(); _threadHandling = threadHandling; _coreShell = coreShell; _projectDirectory = unconfiguredProject.GetProjectDirectory(); unconfiguredProject.ProjectRenamedOnWriter += ProjectRenamedOnWriter; unconfiguredProject.ProjectUnloading += ProjectUnloading; _fileWatcher = new MsBuildFileSystemWatcher(_projectDirectory, "*", 25, 1000, _coreShell.FileSystem(), new RMsBuildFileSystemFilter(), coreShell.Log()); _fileWatcher.Error += FileWatcherError; Project = new FileSystemMirroringProject(unconfiguredProject, projectLockService, _fileWatcher, dependencyProvider, coreShell.Log()); }