Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

File watcher integration #5040

Merged
merged 58 commits into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
594e27b
[Core] Use .dylib for native file watcher
mrward Apr 25, 2018
f799628
[Core] Ensure native file watcher is used in tests
mrward Apr 26, 2018
488bacb
[Core] Allow a solution to be monitored by the file watcher
mrward Apr 26, 2018
09288dc
[Core] Add debug logging for file watcher events
mrward Apr 27, 2018
46aa507
[Core] Support file deletion notifications from file watcher
mrward Apr 27, 2018
fce1c38
[Core] Treat temp file rename as a change event in file watcher
mrward Apr 27, 2018
a988e9d
[Core] WorkspaceItem now registers itself with the file watcher
mrward Apr 27, 2018
7c2e513
[Ide] Use file watcher to detect changes instead of checking all files
mrward Apr 27, 2018
34a011f
[Ide] Fix file open in text editor being reloaded on save
mrward Apr 27, 2018
526186e
[Core] Fix invalid cast after thawing FileService events
mrward Apr 27, 2018
aedbd57
[Core] Watch files outside the solution directory
mrward Apr 30, 2018
cb7a257
[Tests] Dispose solution in file watcher test instead of removing it
mrward Apr 30, 2018
4247c99
[Core] Handle multiple solutions opened with file watchers
mrward Apr 30, 2018
1fc0361
[Core] Normalize file watchers for multiple solutions
mrward Apr 30, 2018
9c2ccfb
[Core] Re-normalize file watcher directories on solution close
mrward Apr 30, 2018
f853afc
[Core] Allow directories to be watched
mrward May 2, 2018
5180437
[Ide] Monitor documents open in workbench with file watcher
mrward May 2, 2018
7762eb3
[Core] RootWorkspace now adds solutions to the file watcher
mrward May 2, 2018
921a37e
[Core] File watcher now handles adhoc solutions being disposed
mrward May 2, 2018
1d1891b
[Ide] Handle filename being changed with save as when being watched
mrward May 2, 2018
55fdc6e
[Core] Update file watchers on project added/removed to/from solution
mrward May 3, 2018
b8857f5
[Core] Update file watchers when solution added to workspace
mrward May 3, 2018
cf094b7
[Core] Update file watchers after adding file to project
mrward May 3, 2018
9ec5506
[Core] Fix no file reload when file modified externally
mrward May 4, 2018
257395b
[Core] Fix missing file change events
mrward May 4, 2018
8ba6603
[Core] Mark RootWorkspace.GetFileStatusTracker as obsolete
mrward May 4, 2018
81c2083
[Git] Stop using FileStatusTracker when working with stashes
mrward May 4, 2018
84d167a
[Core] Fix file removed event fired when file not deleted
mrward May 4, 2018
1ed62bd
[Core] Fix failure to open Git Status window
mrward May 14, 2018
904180e
[Core] Fix file not being closed when deleted externally
mrward May 14, 2018
98b9bd4
[Core] Improve speed of file watcher tests
mrward May 14, 2018
f3d4850
[Core] FileStatusTracker now uses FileService.FileChanged events
mrward May 15, 2018
91cadcd
[Core] Fix file watchers not being disposed
mrward May 15, 2018
f23b71c
[Core] Fix crash when trying to watch missing directory
mrward May 15, 2018
23f6e7c
[Core] Handle saving file externally generating events out of order
mrward May 15, 2018
fd56afd
[Core] Fix project not being reloaded when changed externally
mrward May 15, 2018
8324211
[Core] RootWorkspace now uses ReloadRequired events
mrward May 16, 2018
11e9704
[Core] File watcher now uses tasks
mrward May 16, 2018
1f2aa30
[Core] Rely on file watcher for change events in PerformGeneratorAsync
mrward May 23, 2018
7fdb2d4
[NuGet] Remove FileService notify calls
mrward May 29, 2018
b8bffba
[Core] Fix packages.config file not always being reloaded
mrward May 29, 2018
fc5fb37
[ConnectedServices] Remove use of FileService notify method
mrward May 29, 2018
e860c92
[Core] Rely on file watcher for file change notifications
mrward May 30, 2018
ed27a6f
[Ide] Rely on file watcher for file change events
mrward May 30, 2018
704e89c
[DesignerSupport] Rely on file watcher for file change events
mrward May 30, 2018
2c47d11
[WebReferences] Rely on file watcher for file change events
mrward May 30, 2018
56c0978
[Refactoring] Rely on file watcher for file change events
mrward May 30, 2018
9e58661
[C#] Rely on file watcher for file change events
mrward May 30, 2018
4aa1cf0
[Ide] Fix UI hang when many files are deleted
mrward May 30, 2018
0895d38
[Git] Rely on file watcher for file change events
mrward Jun 1, 2018
b417d4b
[Autotools] Rely on file watcher for file change events
mrward Jun 11, 2018
12ab30c
[GtkCore] Rely on file watcher for file change events
mrward Jun 11, 2018
63302cf
[Subversion] Rely on file watcher for file change events
mrward Jun 11, 2018
5cc345d
[Core] Remove file watcher debug logging
mrward Jun 12, 2018
85e867f
[Core] Make FileService.ThawEvents thread safe.
mrward Jun 13, 2018
98a2508
[Git] No need to call FileService.ThawEvents on UI thread
mrward Jun 13, 2018
a3d9526
[Git] Reload files when they are reverted
mrward Jun 13, 2018
6066964
Merge branch 'master' into file-watcher-integration
mrward Jun 13, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ obj/
/main/build/MacOSX/monostub
/main/build/MacOSX/monostub-nogui
/main/build/MacOSx/monostub-test
/main/build/MacOSX/libsystemnative.dylib
/local-libs
/main/build/tests
/main/monodevelop_version
Expand Down
10 changes: 7 additions & 3 deletions main/build/MacOSX/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ EXTRA_DIST = dmg-bg.png DS_Store Info.plist.in make-dmg-bundle.sh render.cs

MONOSTUB_EXTRA_SOURCES = monostub-utils.h

all: monostub monostub-nogui monostub-test
all: monostub monostub-nogui monostub-test libsystemnative.dylib

render.exe: render.cs
mcs -r:System.Drawing render.cs
Expand All @@ -34,17 +34,21 @@ dmg: render.exe app
System_Native.o: System_Native.cpp
g++ -std=c++14 -c -Wall -mmacosx-version-min=10.10 -o $@ $^

libsystemnative.dylib: System_Native.o
clang++ -dynamiclib -undefined dynamic_lookup $^ -o $@
cp $@ ../bin

monostub.o: monostub.mm $(MONOSTUB_EXTRA_SOURCES)
g++ -g $(EXTERN_C_XM_REGISTRAR_DEFINE) $(MONOSTUB_DEFINES) -c -Wall -mmacosx-version-min=10.10 -m$(MONOSTUB_ARCH) -o $@ monostub.mm

monostub-nogui.o: monostub.mm $(MONOSTUB_EXTRA_SOURCES)
g++ -g $(EXTERN_C_XM_REGISTRAR_DEFINE) $(MONOSTUB_DEFINES) -DNOGUI -c -Wall -mmacosx-version-min=10.10 -m$(MONOSTUB_ARCH) -o $@ monostub.mm

monostub: monostub.o System_Native.o $(MONOSTUB_STATIC_LINK)
monostub: monostub.o $(MONOSTUB_STATIC_LINK)
clang++ -g -Wall -mmacosx-version-min=10.10 -m$(MONOSTUB_ARCH) -o $@ -Wl,-all_load $^ -framework AppKit -framework Quartz -undefined dynamic_lookup
cp $@ ../bin/MonoDevelop

monostub-nogui: monostub-nogui.o System_Native.o $(MONOSTUB_STATIC_LINK)
monostub-nogui: monostub-nogui.o $(MONOSTUB_STATIC_LINK)
clang++ -g -Wall -mmacosx-version-min=10.10 -m$(MONOSTUB_ARCH) -o $@ -Wl,-all_load $^ -framework AppKit -framework Quartz -undefined dynamic_lookup
cp $@ ../bin/mdtool

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ public static ITypeSymbol AddType (DotNetProject project, string folder, string
using (var sw = new StreamWriter (fileName)) {
sw.WriteLine (ns.ToString ());
}
FileService.NotifyFileChanged (fileName);
var roslynProject = MonoDevelop.Ide.TypeSystem.TypeSystemService.GetCodeAnalysisProject (project);
var id = MonoDevelop.Ide.TypeSystem.TypeSystemService.GetDocumentId (roslynProject.Id, fileName);
if (id == null)
Expand Down
1 change: 0 additions & 1 deletion main/src/addins/MonoDevelop.Autotools/CustomMakefile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ public void Save ()
sw.Write (content);

UpdatedMakefiles++;
FileService.NotifyFileChanged (fileName);
}

void ThrowMakefileVarNotFound (string var)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ static string FormatFile (ICSharpCode.NRefactory.CSharp.SyntaxTree file)
static void SaveFile (string file, string content)
{
TextFile.WriteFile (file, content, null, null, true);
FileService.NotifyFileChanged (file, true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ public void WriteFile (FilePath path, Action<TextWriter> write)
write (sw);
}
FileService.SystemRename (tempPath, path);
//mark the file as changed so it gets reparsed
Gtk.Application.Invoke ((o, args) => {
FileService.NotifyFileChanged (path);
});
WrittenCount++;
} catch (IOException ex) {
if (monitor != null)
Expand Down Expand Up @@ -146,9 +142,6 @@ public void WriteFile (FilePath path, string contents)
File.WriteAllText (tempPath, contents);
FileService.SystemRename (tempPath, path);
//mark the file as changed so it gets reparsed
Gtk.Application.Invoke ((o, args) => {
FileService.NotifyFileChanged (path);
});
WrittenCount++;
} catch (IOException ex) {
if (monitor != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void UpdateBindings (string fileName)
{
if (targetObject == null)
return;
FileService.NotifyFileChanged (fileName);

classFile = fileName;

var cls = GetClass ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,6 @@ static string GenerateSteticCodeStructure (DotNetProject project, Stetic.Project
if (saveToFile)
File.WriteAllText (fileName, text);
TypeSystemService.NotifyFileChange (fileName, text);
//
// if (ProjectDomService.HasDom (project)) {
// // Only update the parser database if the project is actually loaded in the IDE.
// ProjectDomService.Parse (project, fileName, text);
// if (saveToFile)
// FileService.NotifyFileChanged (fileName);
// }

return fileName;
}
Expand Down Expand Up @@ -534,8 +527,7 @@ await Task.Run (delegate {
timer.Trace ("Writing code");
File.WriteAllText (fname, content);
} finally {
timer.Trace ("Notifying changes");
FileService.NotifyFileChanged (fname);
timer.Trace ("Code written to file");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ public bool UpdateGtkFolder ()
StreamWriter sw = new StreamWriter (SteticFile);
sw.WriteLine ("<stetic-interface />");
sw.Close ();
FileService.NotifyFileChanged (SteticFile);
}

if (!project.IsFileInProject (SteticFile)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ public override async Task<bool> AddToProjectAsync (SolutionFolderItem policyPar
string fileName = fileTemplate.GetFileName (policyParent, project, language, directory, name);
await fileTemplate.AddToProjectAsync (policyParent, project, language, directory, name);

FileService.NotifyFileChanged (fileName);

DotNetProject netProject = project as DotNetProject;
string ns = netProject != null ? netProject.GetDefaultNamespace (fileName) : "";
string cname = Path.GetFileNameWithoutExtension (fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ public TestablePackageManagementEventsMonitor (
{
}

public List<FilePath> FilesChanged = new List<FilePath> ();

protected override void NotifyFilesChanged (FilePath[] files)
{
FilesChanged.AddRange (files);
}

protected override void GuiSyncDispatch (Action action)
{
action.Invoke ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,25 +407,6 @@ public void Run_ActionLogsPackageOperationMessage_ProgressMonitorLogsMessage ()
progressMonitor.AssertMessageIsLogged ("Message");
}

[Test]
public void Run_ActionChangesTwoFiles_FileServiceNotifiedOfFileChanges ()
{
CreateRunner ();
string file1 = @"d:\projects\MyProject\packages.config".ToNativePath ();
string file2 = @"d:\projects\MyProject\Scripts\jquery.js".ToNativePath ();
AddInstallActionWithCustomExecuteAction (() => {
packageManagementEvents.OnFileChanged (file1);
packageManagementEvents.OnFileChanged (file2);
});

Run ();

List<FilePath> filesChanged = runner.EventsMonitor.FilesChanged;
Assert.AreEqual (2, filesChanged.Count);
Assert.That (filesChanged, Contains.Item (new FilePath (file1)));
Assert.That (filesChanged, Contains.Item (new FilePath (file2)));
}

[Test]
public void IsRunning_NothingRunning_IsRunningIsFalse ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,23 +273,6 @@ public async Task GetInstalledPackagesAsync_FloatingVersion_ReturnsOnePackageRef
Assert.AreEqual ("2.6.0-*", packageReference.AllowedVersions.Float.ToString ());
}

[Test]
public async Task PostProcessAsync_ProjectAssetsFile_NotifyChangeInAssetsFile ()
{
CreateNuGetProject ();
AddDotNetProjectPackageReference ("NUnit", "2.6.0");
dotNetProject.BaseIntermediateOutputPath = @"d:\projects\MyProject\obj".ToNativePath ();
string fileNameChanged = null;
PackageManagementServices.PackageManagementEvents.FileChanged += (sender, e) => {
fileNameChanged = e.Single ().FileName;
};

await project.PostProcessAsync (context, CancellationToken.None);

string expectedFileNameChanged = @"d:\projects\MyProject\obj\project.assets.json".ToNativePath ();
Assert.AreEqual (expectedFileNameChanged, fileNameChanged);
}

[Test]
public async Task PostProcessAsync_References_NotifyReferencesChangedEventFired ()
{
Expand Down Expand Up @@ -324,25 +307,6 @@ public async Task PostProcessAsync_RestoreRunLockFileNotChanged_NotifyReferences
Assert.AreEqual ("References", modifiedHint);
}

[Test]
public async Task PostProcessAsync_RestoreRunLockFileNotChanged_NotifyChangeInAssetsFile ()
{
CreateNuGetProject ();
AddDotNetProjectPackageReference ("NUnit", "2.6.0");
dotNetProject.BaseIntermediateOutputPath = @"d:\projects\MyProject\obj".ToNativePath ();
string fileNameChanged = null;
PackageManagementServices.PackageManagementEvents.FileChanged += (sender, e) => {
fileNameChanged = e.Single ().FileName;
};
OnAfterExecuteActions ("NUnit", "2.6.3", NuGetProjectActionType.Install);

await project.PostProcessAsync (context, CancellationToken.None);

string expectedFileNameChanged = @"d:\projects\MyProject\obj\project.assets.json".ToNativePath ();
Assert.AreEqual (expectedFileNameChanged, fileNameChanged);
Assert.AreEqual (project, buildIntegratedRestorer.ProjectRestored);
}

/// <summary>
/// Build restorer would trigger the notification itself.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,19 +270,6 @@ public void Run_OnePackageInProjectNeedingReinstallButFindingPackageThrowsExcept
progressMonitor.AssertMessageIsLogged ("error message");
}

[Test]
public void Run_OnePackageNeedsReinstalling_NotifyPackagesConfigFileIsChanged ()
{
CreateRunner ();
ProjectHasOnePackageReferenceNeedingReinstall ("MyPackageId");
FilePath expectedFilePath = ConfigurePackagesConfigFilePath ("packages.config");

Run ();

Assert.AreEqual (1, runner.EventsMonitor.FilesChanged.Count);
Assert.AreEqual (expectedFilePath, runner.EventsMonitor.FilesChanged [0]);
}

[Test]
public void Run_OnePackageNeedsReinstalling_PackageIsMarkedForReinstallationInPackagesConfigFile ()
{
Expand Down Expand Up @@ -315,41 +302,6 @@ public void Run_PackagesConfigFileHasReinstallationAttributeSetButPackageDoesNot
AssertPackageNotMarkedForReinstallationInPackagesConfigFile ("MyPackageId");
}

[Test]
public void Run_PackagesConfigFileHasReinstallationAttributeSetButPackageDoesNotRequireReinstall_PackageConfigFileChangedNotificationIsGenerated ()
{
CreateRunner ();
ProjectHasOnePackageReferenceCompatibleWithCurrentProjectTargetFramework ("MyPackageId");
var packageReference = new PackageReference (
new PackageIdentity ("MyPackageId", NuGetVersion.Parse ("1.2.3.4")),
NuGetFramework.Parse ("net40"),
false,
false,
requireReinstallation: true);

runner.PackageCompatibilityChecker.NuGetProject.InstalledPackages.Clear ();
runner.PackageCompatibilityChecker.NuGetProject.InstalledPackages.Add (packageReference);

FilePath expectedFilePath = ConfigurePackagesConfigFilePath ("packages.config");

Run ();

Assert.AreEqual (1, runner.EventsMonitor.FilesChanged.Count);
Assert.AreEqual (expectedFilePath, runner.EventsMonitor.FilesChanged [0]);
}

[Test]
public void Run_PackageDoesNotRequireReinstall_PackagesConfigIsNotUpdated ()
{
CreateRunner ();
ProjectHasOnePackageReferenceCompatibleWithCurrentProjectTargetFramework ("MyPackageId");
runner.PackageCompatibilityChecker.NuGetProject.TargetFramework = NuGetFramework.Parse ("net40");

Run ();

Assert.AreEqual (0, runner.EventsMonitor.FilesChanged.Count);
}

[Test]
public void Run_OnePackageInProjectIncompatibleWithNewProjectTargetFramework_IncompatiblePackageErrorMessageDisplayed ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,6 @@ public override Task PostProcessAsync (INuGetProjectContext nuGetProjectContext,
DotNetProject.DotNetCoreNotifyReferencesChanged ();
});

packageManagementEvents.OnFileChanged (project.GetNuGetAssetsFilePath ());

return base.PostProcessAsync (nuGetProjectContext, token);
}

Expand All @@ -314,7 +312,6 @@ async Task RestorePackages (INuGetProjectContext nuGetProjectContext, Cancellati
// Need to refresh the references since the restore did not.
await Runtime.RunInMainThread (() => {
DotNetProject.DotNetCoreNotifyReferencesChanged ();
packageManagementEvents.OnFileChanged (project.GetNuGetAssetsFilePath ());
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ async Task OnProjectsRestored (IEnumerable<BuildIntegratedNuGetProject> projects
if (changedLocks.Count > 0) {
LockFileChanged = true;
await Runtime.RunInMainThread (() => {
FileService.NotifyFilesChanged (changedLocks);
foreach (var project in affectedProjects) {
// Restoring the entire solution so do not refresh references for
// transitive project references since they should be refreshed anyway.
Expand All @@ -162,9 +161,7 @@ public async Task RestorePackages (
await ReloadProject (projectToReload, changedLock, refreshTransitiveReferences: true);
} else if (changedLock != null) {
LockFileChanged = true;
await Runtime.RunInMainThread (() => {
FileService.NotifyFileChanged (changedLock);

await Runtime.RunInMainThread (() => {
// Restoring a single project so ensure references are refreshed for
// transitive project references.
NotifyProjectReferencesChanged (project, includeTransitiveProjectReferences: true);
Expand Down Expand Up @@ -245,7 +242,6 @@ Task ReloadProject (DotNetProject projectToReload, string changedLock, bool refr
return Runtime.RunInMainThread (async () => {
if (changedLock != null) {
LockFileChanged = true;
FileService.NotifyFileChanged (changedLock);
}
await projectToReload.ReevaluateProject (new ProgressMonitor ());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ async Task AddFileToProject (string path)
if (ShouldAddFileToProject (path)) {
await AddFileProjectItemToProject (path);
}
OnFileChanged (path);
LogAddedFileToProject (path);
}

Expand All @@ -166,11 +165,6 @@ bool ShouldAddFileToProject (string path)
return !IsBinDirectory (path) && !FileExistsInProject (path);
}

void OnFileChanged (string path)
{
GuiSyncDispatch (() => fileService.OnFileChanged (GetFullPath (path)));
}

bool IsBinDirectory(string path)
{
string directoryName = Path.GetDirectoryName (path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ protected virtual PackageCompatibilityChecker CreatePackageCompatibilityChecker
void MarkPackagesForReinstallation (PackageCompatibilityChecker checker)
{
checker.MarkPackagesForReinstallation ();
packageManagementEvents.OnFileChanged (checker.PackageReferenceFileName);
}

void ReportPackageReinstallationWarning (PackageCompatibilityChecker checker)
Expand Down
Loading