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

Commit

Permalink
Merge pull request #5040 from mono/file-watcher-integration
Browse files Browse the repository at this point in the history
File watcher integration
  • Loading branch information
slluis committed Jun 14, 2018
2 parents d500e76 + 6066964 commit e88b727
Show file tree
Hide file tree
Showing 73 changed files with 1,828 additions and 641 deletions.
1 change: 1 addition & 0 deletions .gitignore
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
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
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
Expand Up @@ -262,7 +262,6 @@ public void Save ()
sw.Write (content);

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

void ThrowMakefileVarNotFound (string var)
Expand Down
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);
}
}
}
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
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
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 @@ public async static Task<Stetic.CodeGenerationResult> GenerateSteticCode (Progre
timer.Trace ("Writing code");
File.WriteAllText (fname, content);
} finally {
timer.Trace ("Notifying changes");
FileService.NotifyFileChanged (fname);
timer.Trace ("Code written to file");
}
}

Expand Down
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
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
Expand Up @@ -41,13 +41,6 @@ class TestablePackageManagementEventsMonitor : PackageManagementEventsMonitor
{
}

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
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
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
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
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
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 @@ async Task OnProjectsRestored (IEnumerable<BuildIntegratedNuGetProject> projects
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
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
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

0 comments on commit e88b727

Please sign in to comment.