private void addUnique(List <ChangedFile> projectFiles, ChangedFile changedProject) { if (projectFiles.Find(x => x.FullName.Equals(changedProject.FullName)) == null) { projectFiles.Add(changedProject); } }
private bool handleProject(string extension, ChangedFile file) { var isWatchingSolution = File.Exists(_configuration.WatchToken); if (file.Extension.ToLower().Equals(extension)) { var project = _cache.Get <Project>(file.FullName); if (project == null) { if (!isWatchingSolution) { Debug.WriteDebug("Adding and marking project for rebuild " + file.FullName); _cache.Add <Project>(file.FullName); project = _cache.Get <Project>(file.FullName); } } else { Debug.WriteDebug("Reloading and marking project for rebuild " + file.FullName); _cache.Reload <Project>(file.FullName); project = _cache.Get <Project>(file.FullName); } return(true); } return(false); }
public void Consume(ChangedFile file) { if (!File.Exists(_configuration.WatchToken)) { return; } if (file.Extension.ToLower().Equals(".sln")) { try { tryCrawl(file); } catch (IOException ex) { Debug.WriteException(ex); Thread.Sleep(200); try { tryCrawl(file); } catch { } } catch (Exception ex) { Debug.WriteException(ex); } } }
private void addToBuffer(ChangedFile file) { if (Directory.Exists(file.FullName)) { return; } var fileChangeProdiver = true; _solutionHanlder.Consume(file); _rebuildMarker.HandleProjects(file); if (_bus.BuildProvider != null) { fileChangeProdiver = !_bus.BuildProvider.Equals("NoBuild"); } if (fileChangeProdiver && !_configuration.WatchAllFiles && !((isProjectFile(file.FullName) && _cache.Get <Project>(file.FullName) != null) || _cache.IsProjectFile(file.FullName))) { return; } if (!_validator.ShouldPublish(getRelativePath(file.FullName))) { return; } lock (_padLock) { if (_buffer.FindIndex(0, f => f.FullName.Equals(file.FullName)) < 0) { _buffer.Add(file); reStartTimer(); } } }
public EmittedAssembly StageFile(ChangedFile file, bool silent = false) { var sw = Stopwatch.StartNew(); var syntaxTree = CSharpSyntaxTree.ParseText( file.Contents, CSharpParseOptions.Default .WithLanguageVersion(LanguageVersion.Preview) .WithKind(SourceCodeKind.Regular) .WithPreprocessorSymbols(_options.PreprocessorSymbols.ToArray()), path: file.Path, Encoding.Default); EmittedAssembly emittedAssembly = null; WithCompilation(c => { var newC = RawTrees.TryGetValue(file.Path, out var oldSyntaxTree) ? c.ReplaceSyntaxTree(oldSyntaxTree, syntaxTree) : c.AddSyntaxTrees(syntaxTree); RawTrees[file.Path] = syntaxTree; if (silent) { Logger.LogInformation( "Stage '{FileName}' without emit, Duration: {Duration:N0}ms, Types: [ {Types} ]", file, sw.ElapsedMilliseconds, syntaxTree.GetContainedTypes()); return(newC); } var result = EmitAssembly(newC, out emittedAssembly); if (!String.IsNullOrWhiteSpace(_options.WriteAssembliesPath)) { WriteEmittedAssembly(emittedAssembly); } var elapsed = sw.ElapsedMilliseconds; Logger.LogInformationAsync( "Stage '{FileName}' and emit - Success: {Success}, Duration: {Duration:N0}ms, Types: [ {Types} ], Diagnostics: {@Diagnostics}", Path.GetFileName(file.Path), result.Success, elapsed, syntaxTree.GetContainedTypes(), result.Success ? "" : String.Join( Environment.NewLine, result.Diagnostics .Where(x => x.Severity == DiagnosticSeverity.Error) .Select(x => x.GetMessage()))); return(newC); }); return(emittedAssembly); }
public void Should_serialize_run_started_message() { var files = new ChangedFile[] { new ChangedFile(System.Reflection.Assembly.GetExecutingAssembly().FullName) }; var message = new RunStartedMessage(files); var output = serializeDeserialize <RunStartedMessage>(message); output.Files.Length.ShouldEqual(1); output.Files[0].Name.ShouldEqual(files[0].Name); output.Files[0].FullName.ShouldEqual(files[0].FullName); output.Files[0].Extension.ShouldEqual(files[0].Extension); }
public void Should_serialize_file_change_message() { var file = new ChangedFile(System.Reflection.Assembly.GetExecutingAssembly().FullName); var message = new FileChangeMessage(); message.AddFile(file); var output = serializeDeserialize <FileChangeMessage>(message); output.Files.Length.ShouldEqual(1); output.Files[0].Name.ShouldEqual(file.Name); output.Files[0].FullName.ShouldEqual(file.FullName); output.Files[0].Extension.ShouldEqual(file.Extension); }
public void Should_never_handle_realtime_tests() { var project = new Project("", new ProjectDocument(ProjectType.VisualBasic)); var cache = MockRepository.GenerateMock <ICache>(); var config = MockRepository.GenerateMock <IConfiguration>(); var file = new ChangedFile(string.Format("TestResources{0}VS2008{0}_rltm_build_fl_Bleh.csproj", Path.DirectorySeparatorChar)); cache.Stub(c => c.Get <Project>(file.FullName)).Return(null).Repeat.Once(); cache.Stub(c => c.Get <Project>(file.FullName)).Return(project).Repeat.Once(); var marker = new ProjectRebuildMarker(cache, config); marker.HandleProjects(file); cache.AssertWasNotCalled(c => c.Add <Project>(file.FullName)); }
public void Should_add_projects_that_doesnt_exist() { var project = new Project("", new ProjectDocument(ProjectType.VisualBasic)); var cache = MockRepository.GenerateMock <ICache>(); var config = MockRepository.GenerateMock <IConfiguration>(); var file = new ChangedFile(string.Format("TestResources{0}VS2008{0}NUnitTestProjectVisualBasic.vbproj", Path.DirectorySeparatorChar)); cache.Stub(c => c.Get <Project>(file.FullName)).Return(null).Repeat.Once(); cache.Stub(c => c.Get <Project>(file.FullName)).Return(project).Repeat.Once(); var marker = new ProjectRebuildMarker(cache, config); marker.HandleProjects(file); cache.AssertWasCalled(c => c.Add <Project>(file.FullName)); }
private ChangedFile[] getProjectsClosestToChangedFile(ChangedFile file, ILocateProjects[] locators) { var closestProjects = new List <ChangedFile>(); var currentLocation = 0; foreach (var locator in locators) { var files = locator.Locate(file.FullName); if (files.Length == 0) { continue; } currentLocation = addIfCloser(files, currentLocation, closestProjects); } return(closestProjects.ToArray()); }
public void HandleProjects(ChangedFile file) { try { if (file.FullName.Contains("_rltm_build_fl_")) { return; } handleProject(".csproj", file); handleProject(".vbproj", file); handleProject(".fsproj", file); } catch (Exception ex) { Debug.WriteException(ex); } }
/// <summary> /// Add a new fileinfo to the list of changed files. /// </summary> /// <param name="change"></param> internal void AddNewChange(ChangedFile change) { if (Application.Current == null) { return; } if (Application.Current.Dispatcher.CheckAccess()) { if (!ChangedFiles.Contains(change)) { ChangedFiles.Add(change); } } else { AddChangeDelegate del = new AddChangeDelegate(AddNewChange); Application.Current.Dispatcher.Invoke(del, new object[] { change }); } }
/// <summary> /// Cambia el elemento seleccionado /// </summary> private void ChangeSelectedItem() { FileNodeViewModel file = GetSelectedFile(); if (file != null) { // Obtiene el directorio y archivo if (!file.IsFolder) { SelectedPath = System.IO.Path.GetDirectoryName(file.File); SelectedFile = file.File; } else { SelectedPath = file.File; SelectedFile = null; } // Lanza el evento de cambio de archivo ChangedFile?.Invoke(this, new EventArguments.FileEventArgs(file.File)); } }
private void addToBuffer(ChangedFile file) { if (Directory.Exists(file.FullName)) { return; } if (!_configuration.WatchAllFiles && !(isProjectFile(file.FullName) || _cache.IsProjectFile(file.FullName))) { return; } if (!_validator.ShouldPublish(getRelativePath(file.FullName))) { return; } lock (_padLock) { if (_buffer.FindIndex(0, f => f.FullName.Equals(file.FullName)) < 0) { _buffer.Add(file); reStartTimer(); } } }
private void tryCrawl(ChangedFile file) { _crawler.Crawl(file.FullName); }
public FakeProjectLocator(ChangedFile[] files) { _files = files; }
private void addToBuffer(ChangedFile file) { if (Directory.Exists(file.FullName)) return; if (!_validator.ShouldPublish(getRelativePath(file.FullName))) return; lock (_padLock) { if (_buffer.FindIndex(0, f => f.FullName.Equals(file.FullName)) < 0) { _buffer.Add(file); reStartTimer(); } } }
private void addToBuffer(ChangedFile file) { if (Directory.Exists(file.FullName)) return; var fileChangeProdiver = true; _solutionHanlder.Consume(file); _rebuildMarker.HandleProjects(file); if (_bus.BuildProvider != null) fileChangeProdiver = !_bus.BuildProvider.Equals("NoBuild"); if (fileChangeProdiver && !_configuration.WatchAllFiles && !((isProjectFile(file.FullName) && _cache.Get<Project>(file.FullName) != null) || _cache.IsProjectFile(file.FullName))) return; if (!_validator.ShouldPublish((file.FullName))) return; _buffer.Push(file); reStartTimer(); }
private int getLocation(ChangedFile suggestedProjects) { return(suggestedProjects.FullName.Split(Path.DirectorySeparatorChar).Length); }
public FakeProjectFileCrawler(ChangedFile[] projects) { _projects = projects; }
/// <summary> /// Add a new fileinfo to the list of changed files. /// </summary> /// <param name="change"></param> internal void AddNewChange(ChangedFile change) { if (Application.Current == null) return; if (Application.Current.Dispatcher.CheckAccess()) { if (!ChangedFiles.Contains(change)) ChangedFiles.Add(change); } else { AddChangeDelegate del = new AddChangeDelegate(AddNewChange); Application.Current.Dispatcher.Invoke(del, new object[] { change }); } }