private async Task TrackPackage(PackageViewModel package) { if (!package.IsLoaded) { return; } foreach (var loadedAssembly in package.LoadedAssemblies) { // Track the assembly binary if (trackBinaries) { directoryWatcher.Track(loadedAssembly.Path); } // Track the project file directoryWatcher.Track(loadedAssembly.ProjectReference.Location); var trackedAssembly = new TrackedAssembly { Package = package, LoadedAssembly = loadedAssembly }; // Track project source code if (await UpdateProject(trackedAssembly)) { trackedAssemblies.Add(trackedAssembly); } } // TODO: Detect changes to loaded assemblies? }
// TODO: Properly untrack removed documents private async Task <bool> UpdateProject(TrackedAssembly trackedAssembly) { var location = trackedAssembly.LoadedAssembly.ProjectReference.Location; if (location.IsRelative) { location = UPath.Combine(trackedAssembly.Package.PackagePath.GetFullDirectory(), location); } var project = await OpenProject(location); if (project == null) { return(false); } trackedAssembly.Project = project; var packageDirectory = trackedAssembly.Package.PackagePath.GetFullDirectory(); var projectDirectory = location.GetFullDirectory(); foreach (var document in project.Documents) { // Limit ourselves to our package subfolders or project folders if (!packageDirectory.Contains(new UFile(document.FilePath)) && !projectDirectory.Contains(new UFile(document.FilePath))) { continue; } directoryWatcher.Track(document.FilePath); } return(true); }
public void Initialization() { TrackedAssembly assembly = new TrackedAssembly(_assemblyDefinition); Assert.That(assembly.AssemblyDefinition, Is.SameAs(_assemblyDefinition)); Assert.That(assembly.IsModified, Is.False); Assert.That(assembly.ReverseReferences, Is.Empty); }
public void AddReverseReference() { TrackedAssembly assembly = new TrackedAssembly(_assemblyDefinition); TrackedAssembly assembly2 = new TrackedAssembly(_assemblyDefinition); assembly.AddReverseReference(assembly2); Assert.That(assembly.ReverseReferences, Has.Member(assembly2)); }
public void MarkModified() { TrackedAssembly assembly = new TrackedAssembly(_assemblyDefinition); Assert.That(assembly.IsModified, Is.False); assembly.MarkModified(); Assert.That(assembly.IsModified, Is.True); }
public void MarkModified_AlsoMarksReverseReference() { TrackedAssembly assembly = new TrackedAssembly(_assemblyDefinition); TrackedAssembly assembly2 = new TrackedAssembly(_assemblyDefinition); assembly.AddReverseReference(assembly2); Assert.That(assembly.IsModified, Is.False); Assert.That(assembly2.IsModified, Is.False); assembly.MarkModified(); Assert.That(assembly.IsModified, Is.True); Assert.That(assembly2.IsModified, Is.True); }
public void MarkModified_CanHandleCyclicReferences() { TrackedAssembly assembly = new TrackedAssembly(_assemblyDefinition); TrackedAssembly assembly2 = new TrackedAssembly(_assemblyDefinition); TrackedAssembly assembly3 = new TrackedAssembly(_assemblyDefinition); assembly.AddReverseReference(assembly2); assembly2.AddReverseReference(assembly3); assembly3.AddReverseReference(assembly); Assert.That(assembly.IsModified, Is.False); Assert.That(assembly2.IsModified, Is.False); Assert.That(assembly3.IsModified, Is.False); assembly.MarkModified(); Assert.That(assembly.IsModified, Is.True); Assert.That(assembly2.IsModified, Is.True); Assert.That(assembly3.IsModified, Is.True); }