private void WatchLaunchSettingsFile() { if (FileWatcher == null) { FileChangeScheduler?.Dispose(); // Create our scheduler for processing file changes FileChangeScheduler = new TaskDelayScheduler(FileChangeProcessingDelay, _commonProjectServices.ThreadingService, _projectServices.ProjectAsynchronousTasks.UnloadCancellationToken); try { FileWatcher = new SimpleFileWatcher(Path.GetDirectoryName(_commonProjectServices.Project.FullPath), true, NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite, LaunchSettingsFilename, LaunchSettingsFile_Changed, LaunchSettingsFile_Changed); } catch (Exception ex) when(ex is IOException || ex is ArgumentException) { // If the project folder is no longer available this will throw, which can happen during branch switching } } }
// ECan pass null for all and a default will be crewated public LaunchSettingsUnderTest(UnconfiguredProject project, IUnconfiguredProjectServices projectServices, IFileSystem fileSystem, IUnconfiguredProjectCommonServices commonProjectServices, IActiveConfiguredProjectSubscriptionService projectSubscriptionService, ActiveConfiguredProject <AppDesignerFolderSpecialFileProvider> appDesignerFolderSpecialFileProvider) : base(project, projectServices, fileSystem, commonProjectServices, projectSubscriptionService, appDesignerFolderSpecialFileProvider) { // Block the code from setting up one on the real file system. Since we block, it we need to set up the fileChange scheduler manually FileWatcher = new SimpleFileWatcher(); // Make the unit tests run faster FileChangeProcessingDelay = TimeSpan.FromMilliseconds(50); FileChangeScheduler = new TaskDelayScheduler(FileChangeProcessingDelay, commonProjectServices.ThreadingService, CancellationToken.None); }
/// <summary> /// Sets up a file system watcher to look for changes to the launchsettings.json file. It watches at the root of the /// project oltherwise we force the project to have a properties folder. /// </summary> private void WatchLaunchSettingsFile() { if (FileWatcher == null) { // Create our scheduler for processing file chagnes FileChangeScheduler = new TaskDelayScheduler(FileChangeProcessingDelay, CommonProjectServices.ThreadingService, ProjectServices.ProjectAsynchronousTasks.UnloadCancellationToken); FileWatcher = new SimpleFileWatcher(Path.GetDirectoryName(CommonProjectServices.Project.FullPath), true, NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite, LaunchSettingsFilename, LaunchSettingsFile_Changed, LaunchSettingsFile_Changed); } }