Exemplo n.º 1
0
        private async Task ProjectUnloading(object sender, EventArgs args)
        {
            VsAppShell.Current.AssertIsOnMainThread();

            _unconfiguredProject.ProjectUnloading -= ProjectUnloading;
            _fileWatcher.Dispose();

            if (!_fileSystem.DirectoryExists(_projectDirectory))
            {
                return;
            }

            if (_toolsSettings.AlwaysSaveHistory)
            {
                _history.TrySaveToFile(Path.Combine(_projectDirectory, DefaultRHistoryName));
            }

            var rdataPath            = Path.Combine(_projectDirectory, DefaultRDataName);
            var saveDefaultWorkspace = await GetSaveDefaultWorkspace(rdataPath);

            if (!_session.IsHostRunning)
            {
                return;
            }

            Task.Run(async() => {
                using (var evaluation = await _session.BeginEvaluationAsync()) {
                    if (saveDefaultWorkspace)
                    {
                        await evaluation.SaveWorkspaceAsync(rdataPath);
                    }
                    await evaluation.SetDefaultWorkingDirectoryAsync();
                }
            }).SilenceException <RException>().SilenceException <MessageTransportException>().DoNotWait();
        }
Exemplo n.º 2
0
        private async Task ProjectUnloading(object sender, EventArgs args)
        {
            _coreShell.AssertIsOnMainThread();

            _unconfiguredProject.ProjectRenamedOnWriter -= ProjectRenamedOnWriter;
            _unconfiguredProject.ProjectUnloading       -= ProjectUnloading;
            _fileWatcher.Dispose();

            if (!_coreShell.Services.FileSystem.DirectoryExists(_projectDirectory))
            {
                return;
            }

            if (_toolsSettings.AlwaysSaveHistory)
            {
                _history.TrySaveToFile(Path.Combine(_projectDirectory, DefaultRHistoryName));
            }

            var rdataPath            = Path.Combine(_projectDirectory, DefaultRDataName);
            var saveDefaultWorkspace = await GetSaveDefaultWorkspace(rdataPath);

            if (!_session.IsHostRunning)
            {
                return;
            }

            Task.Run(async() => {
                if (saveDefaultWorkspace)
                {
                    await _session.SaveWorkspaceAsync(rdataPath);
                }
                await _session.SetDefaultWorkingDirectoryAsync();
            }).SilenceException <RException>().DoNotWait();
        }
        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.º 4
0
        private Task ProjectUnloading(object sender, EventArgs args)
        {
            //VsAppShell.Current.AssertIsOnMainThread();

            _unconfiguredProject.ProjectUnloading -= ProjectUnloading;
            _fileWatcher.Dispose();
            return(Task.CompletedTask);
        }
Exemplo n.º 5
0
        private async Task ProjectUnloading(object sender, EventArgs args)
        {
            //VsAppShell.Current.AssertIsOnMainThread();

            _unconfiguredProject.ProjectUnloading -= ProjectUnloading;
            _fileWatcher.Dispose();

            if (!_fileSystem.DirectoryExists(_projectDirectory))
            {
                return;
            }
        }
Exemplo n.º 6
0
        private async Task ProjectUnloading(object sender, EventArgs args)
        {
            _unconfiguredProject.ProjectUnloading -= ProjectUnloading;
            _fileWatcher.Dispose();
            if (!_session.IsHostRunning)
            {
                return;
            }

            if (!_fileSystem.DirectoryExists(_projectDirectory))
            {
                return;
            }

            var rdataPath            = Path.Combine(_projectDirectory, DefaultRDataName);
            var saveDefaultWorkspace = await GetSaveDefaultWorkspace(rdataPath);

            Task.Run(async() => {
                try {
                    using (var evaluation = await _session.BeginEvaluationAsync()) {
                        if (saveDefaultWorkspace)
                        {
                            await evaluation.SaveWorkspace(rdataPath);
                        }
                        await evaluation.SetDefaultWorkingDirectory();
                    }
                } catch (OperationCanceledException) {
                    return;
                }

                if (saveDefaultWorkspace || _toolsSettings.AlwaysSaveHistory)
                {
                    await _threadHandling.SwitchToUIThread();
                    _history.TrySaveToFile(Path.Combine(_projectDirectory, DefaultRHistoryName));
                }
            }).DoNotWait();
        }
Exemplo n.º 7
0
        private async Task ProjectUnloadingAsync(object sender, EventArgs args)
        {
            await _coreShell.SwitchToMainThreadAsync(new CancellationTokenSource(10000).Token);

            _unconfiguredProject.ProjectRenamedOnWriter -= ProjectRenamedOnWriter;
            _unconfiguredProject.ProjectUnloading       -= ProjectUnloadingAsync;
            _workflow.RSessions.BeforeDisposed          -= BeforeRSessionsDisposed;

            _fileWatcher.Dispose();

            if (!_coreShell.FileSystem().DirectoryExists(_projectDirectory))
            {
                return;
            }

            if (_settings.AlwaysSaveHistory)
            {
                _history.TrySaveToFile(Path.Combine(_projectDirectory, DefaultRHistoryName));
            }

            var rdataPath            = Path.Combine(_projectDirectory, DefaultRDataName);
            var saveDefaultWorkspace = await GetSaveDefaultWorkspace(rdataPath);

            if (!_session.IsHostRunning)
            {
                return;
            }

            Task.Run(async() => {
                if (saveDefaultWorkspace)
                {
                    await _session.SaveWorkspaceAsync(rdataPath);
                }
                await _session.SetDefaultWorkingDirectoryAsync();
            }).SilenceException <RException>().DoNotWait();
        }
Exemplo n.º 8
0
 public Task DisposeAsync()
 {
     _fileSystemWatcher.Dispose();
     return(Task.CompletedTask);
 }