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();
            }
        }
Exemplo n.º 2
0
        public async Task InitializeProjectFromDiskAsync()
        {
            await Project.CreateInMemoryImport();

            _fileWatcher.Start();

            await _threadHandling.SwitchToUIThread();

            // Make sure R package is loaded
            VsAppShell.EnsurePackageLoaded(RGuidList.RPackageGuid);

            // Verify project is not on a network share and give warning if it is
            CheckRemoteDrive(_projectDirectory);

            _workflow = _workflowProvider.GetOrCreate();
            _session  = _workflow.RSession;
            _history  = _workflow.History;

            if (_workflow.ActiveWindow == null)
            {
                var window = await _workflow.GetOrCreateVisualComponent(_componentContainerFactory);

                window.Container.Show(true);
            }

            try {
                await _session.HostStarted;
            } catch (Exception) {
                return;
            }

            // TODO: need to compute the proper paths for remote, but they might not even exist if the project hasn't been deployed.
            // https://github.com/Microsoft/RTVS/issues/2223
            if (!_session.IsRemote)
            {
                var  rdataPath            = Path.Combine(_projectDirectory, DefaultRDataName);
                bool loadDefaultWorkspace = _fileSystem.FileExists(rdataPath) && await GetLoadDefaultWorkspace(rdataPath);

                using (var evaluation = await _session.BeginEvaluationAsync()) {
                    if (loadDefaultWorkspace)
                    {
                        await evaluation.LoadWorkspaceAsync(rdataPath);
                    }

                    await evaluation.SetWorkingDirectoryAsync(_projectDirectory);
                }

                _toolsSettings.WorkingDirectory = _projectDirectory;
            }

            _history.TryLoadFromFile(Path.Combine(_projectDirectory, DefaultRHistoryName));

            CheckSurveyNews();
        }
Exemplo n.º 3
0
//#else
//		[ProjectAutoLoad(startAfter: ProjectLoadCheckpoint.UnconfiguredProjectLocalCapabilitiesEstablished,
//						 completeBy: ProjectLoadCheckpoint.BeforeLoadInitialConfiguration,
//						 RequiresUIThread = false)]
//#endif
        public async Task InitializeProjectFromDiskAsync()
        {
            await Project.CreateInMemoryImport();

            _fileWatcher.Start();

            await _threadHandling.SwitchToUIThread();

            // Make sure package is loaded
            EnsurePackageLoaded(GuidList.VisualRustPkgGuid);

            // TODO: start watching the Cargo manifest
        }
Exemplo n.º 4
0
        public async Task InitializeProjectFromDiskAsync()
        {
            await Project.CreateInMemoryImport();

            _fileWatcher.Start();

            // Force REPL window up and continue only when it is shown
            await _threadHandling.SwitchToUIThread();

            // Make sure R package is loaded
            VsAppShell.EnsurePackageLoaded(RGuidList.RPackageGuid);

            // Verify project is not on a network share and give warning if it is
            CheckRemoteDrive(_projectDirectory);

            _workflow = _workflowProvider.GetOrCreate();
            _session  = _workflow.RSession;
            _history  = _workflow.History;

            if (_workflow.ActiveWindow == null)
            {
                var window = await _workflow.GetOrCreateVisualComponent(_componentContainerFactory);

                window.Container.Show(true);
            }

            try {
                await _session.HostStarted;
            } catch (Exception) {
                return;
            }

            var  rdataPath            = Path.Combine(_projectDirectory, DefaultRDataName);
            bool loadDefaultWorkspace = _fileSystem.FileExists(rdataPath) && await GetLoadDefaultWorkspace(rdataPath);

            using (var evaluation = await _session.BeginEvaluationAsync()) {
                if (loadDefaultWorkspace)
                {
                    await evaluation.LoadWorkspace(rdataPath);
                }

                await evaluation.SetWorkingDirectory(_projectDirectory);
            }

            _toolsSettings.WorkingDirectory = _projectDirectory;
            _history.TryLoadFromFile(Path.Combine(_projectDirectory, DefaultRHistoryName));

            CheckSurveyNews();
        }
Exemplo n.º 5
0
            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;
            }