diff options
author | Greg Munn <greg@sgmunn.com> | 2015-06-05 16:48:11 +0300 |
---|---|---|
committer | Greg Munn <greg@sgmunn.com> | 2015-06-05 16:48:11 +0300 |
commit | 803dc51c2711f7472dc1c87dbd8c4874da5af52f (patch) | |
tree | 8be4791b664c4cbc90f7e67a0f9b7a05b12c85ca /main/src/addins/MonoDevelop.PackageManagement | |
parent | fa95ee072598ad63a57fbef9859f426c2ae95c0e (diff) | |
parent | 9d0a6adc2d869b053641adc2636c58a73328de18 (diff) |
Merge branch 'master' into insights-integration-v1
Conflicts:
version-checks
Diffstat (limited to 'main/src/addins/MonoDevelop.PackageManagement')
10 files changed, 136 insertions, 31 deletions
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesProjectNodeBuilderExtension.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesProjectNodeBuilderExtension.cs index 8f3a8466e4..aecc5d8174 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesProjectNodeBuilderExtension.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesProjectNodeBuilderExtension.cs @@ -31,7 +31,6 @@ using MonoDevelop.Core; using MonoDevelop.Ide;
using MonoDevelop.Ide.Gui.Components;
using MonoDevelop.Projects;
-using NuGet;
namespace MonoDevelop.PackageManagement.NodeBuilders
{
@@ -74,17 +73,12 @@ namespace MonoDevelop.PackageManagement.NodeBuilders void RefreshAllChildNodes ()
{
DispatchService.GuiDispatch (() => {
- foreach (IDotNetProject project in PackageManagementServices.Solution.GetDotNetProjects ()) {
- RefreshChildNodes (project.DotNetProject);
+ foreach (DotNetProject project in IdeApp.Workspace.GetAllSolutionItems<DotNetProject> ()) {
+ RefreshChildNodes (project);
}
});
}
- void RefreshChildNodes (IPackageManagementProject project)
- {
- DispatchService.GuiDispatch (() => RefreshChildNodes (project.DotNetProject));
- }
-
void RefreshChildNodes (DotNetProject project)
{
ITreeBuilder builder = Context.GetTreeBuilder (project);
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementProject.cs index 3c7b19962e..f820f5472e 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementProject.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementProject.cs @@ -66,6 +66,14 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers IsUpdatePackageCalled = true;
};
+ UninstallPackageAction = (package, uninstallAction) => {
+ PackagePassedToUninstallPackage = package;
+ ForceRemovePassedToUninstallPackage = uninstallAction.ForceRemove;
+ RemoveDependenciesPassedToUninstallPackage = uninstallAction.RemoveDependencies;
+ };
+
+ CreateUninstallPackageActionFunc = () => FakeUninstallPackageAction;
+
this.Name = name;
ConstraintProvider = NullConstraintProvider.Instance;
@@ -159,11 +167,11 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public void UninstallPackage (IPackage package, UninstallPackageAction uninstallAction)
{
- PackagePassedToUninstallPackage = package;
- ForceRemovePassedToUninstallPackage = uninstallAction.ForceRemove;
- RemoveDependenciesPassedToUninstallPackage = uninstallAction.RemoveDependencies;
+ UninstallPackageAction (package, uninstallAction);
}
+ public Action<IPackage, UninstallPackageAction> UninstallPackageAction;
+
public IPackage PackagePassedToUpdatePackage;
public IEnumerable<PackageOperation> PackageOperationsPassedToUpdatePackage;
public bool UpdateDependenciesPassedToUpdatePackage;
@@ -187,9 +195,11 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public virtual UninstallPackageAction CreateUninstallPackageAction ()
{
- return FakeUninstallPackageAction;
+ return CreateUninstallPackageActionFunc ();
}
+ public Func<UninstallPackageAction> CreateUninstallPackageActionFunc;
+
public UpdatePackageAction CreateUpdatePackageAction ()
{
var action = new FakeUpdatePackageAction (this);
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableInstallPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableInstallPackageAction.cs index 03147f9886..31cc20bd58 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableInstallPackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableInstallPackageAction.cs @@ -33,8 +33,9 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers {
public TestableInstallPackageAction (
IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents)
- : base (project, packageManagementEvents)
+ IPackageManagementEvents packageManagementEvents,
+ FakeFileRemover fileRemover)
+ : base (project, packageManagementEvents, fileRemover)
{
CreateOpenPackageReadMeMonitorAction = packageId => {
IOpenPackageReadMeMonitor monitor = base.CreateOpenPackageReadMeMonitor (packageId);
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/InstallPackageActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/InstallPackageActionTests.cs index 82737da569..087ecd2b90 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/InstallPackageActionTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/InstallPackageActionTests.cs @@ -43,12 +43,14 @@ namespace MonoDevelop.PackageManagement.Tests TestableInstallPackageAction action;
InstallPackageHelper installPackageHelper;
FakeFileService fileService;
+ FakeFileRemover fileRemover;
void CreateAction ()
{
packageManagementEvents = new PackageManagementEvents ();
fakeProject = new FakePackageManagementProject ();
- action = new TestableInstallPackageAction (fakeProject, packageManagementEvents);
+ fileRemover = new FakeFileRemover ();
+ action = new TestableInstallPackageAction (fakeProject, packageManagementEvents, fileRemover);
installPackageHelper = new InstallPackageHelper (action);
}
@@ -604,5 +606,37 @@ namespace MonoDevelop.PackageManagement.Tests Assert.IsFalse (fileService.IsOpenFileCalled);
Assert.IsTrue (monitor.IsDisposed);
}
+
+ [Test]
+ public void Execute_PackagesConfigFileDeletedDuringInstall_FileServicePackagesConfigFileDeletionIsCancelled ()
+ {
+ CreateAction ();
+ action.Package = new FakePackage ("Test");
+ string expectedFileName = @"d:\projects\MyProject\packages.config".ToNativePath ();
+ bool? fileRemovedResult = null;
+ fakeProject.InstallPackageAction = (p, a) => {
+ fileRemovedResult = packageManagementEvents.OnFileRemoving (expectedFileName);
+ };
+ action.Execute ();
+
+ Assert.AreEqual (expectedFileName, fileRemover.FileRemoved);
+ Assert.IsFalse (fileRemovedResult.Value);
+ }
+
+ [Test]
+ public void Execute_ScriptFileDeletedDuringInstallFileDeletionIsNotCancelled ()
+ {
+ CreateAction ();
+ action.Package = new FakePackage ("Test");
+ string fileName = @"d:\projects\MyProject\scripts\myscript.js".ToNativePath ();
+ bool? fileRemovedResult = null;
+ fakeProject.InstallPackageAction = (p, a) => {
+ fileRemovedResult = packageManagementEvents.OnFileRemoving (fileName);
+ };
+ action.Execute ();
+
+ Assert.IsTrue (fileRemovedResult.Value);
+ Assert.IsNull (fileRemover.FileRemoved);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReinstallPackageActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReinstallPackageActionTests.cs index cb5e9e8fd4..c6a6d53182 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReinstallPackageActionTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReinstallPackageActionTests.cs @@ -24,7 +24,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using ICSharpCode.PackageManagement;
using MonoDevelop.PackageManagement.Tests.Helpers;
using NuGet;
@@ -38,6 +37,7 @@ namespace MonoDevelop.PackageManagement.Tests ReinstallPackageAction action;
PackageManagementEvents packageManagementEvents;
FakePackageManagementProject project;
+ FakeFileRemover fileRemover;
void CreateAction (string packageId = "MyPackage", string packageVersion = "1.2.3.4")
{
@@ -46,7 +46,9 @@ namespace MonoDevelop.PackageManagement.Tests packageManagementEvents = new PackageManagementEvents ();
- action = new ReinstallPackageAction (project, packageManagementEvents);
+ fileRemover = new FakeFileRemover ();
+
+ action = new ReinstallPackageAction (project, packageManagementEvents, fileRemover);
action.PackageId = packageId;
action.PackageVersion = new SemanticVersion (packageVersion);
}
@@ -102,6 +104,44 @@ namespace MonoDevelop.PackageManagement.Tests Assert.IsTrue (project.LastInstallPackageCreated.IsExecuteCalled);
Assert.IsFalse (project.LastInstallPackageCreated.OpenReadMeText);
}
+
+ [Test]
+ public void Execute_PackagesConfigFileDeletedDuringUninstall_FileServicePackagesConfigFileDeletionIsCancelled ()
+ {
+ CreateAction ();
+ action.Package = new FakePackage ("Test");
+ string expectedFileName = @"d:\projects\MyProject\packages.config".ToNativePath ();
+ bool? fileRemovedResult = null;
+ project.UninstallPackageAction = (p, a) => {
+ fileRemovedResult = packageManagementEvents.OnFileRemoving (expectedFileName);
+ };
+ project.CreateUninstallPackageActionFunc = () => {
+ return new UninstallPackageAction (project, packageManagementEvents);
+ };
+ action.Execute ();
+
+ Assert.AreEqual (expectedFileName, fileRemover.FileRemoved);
+ Assert.IsFalse (fileRemovedResult.Value);
+ }
+
+ [Test]
+ public void Execute_ScriptFileDeletedDuringUninstall_FileDeletionIsNotCancelled ()
+ {
+ CreateAction ();
+ action.Package = new FakePackage ("Test");
+ string fileName = @"d:\projects\MyProject\scripts\myscript.js".ToNativePath ();
+ bool? fileRemovedResult = null;
+ project.UninstallPackageAction = (p, a) => {
+ fileRemovedResult = packageManagementEvents.OnFileRemoving (fileName);
+ };
+ project.CreateUninstallPackageActionFunc = () => {
+ return new UninstallPackageAction (project, packageManagementEvents);
+ };
+ action.Execute ();
+
+ Assert.IsTrue (fileRemovedResult.Value);
+ Assert.IsNull (fileRemover.FileRemoved);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs index 2f7dffa50d..7014417ed2 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs @@ -35,14 +35,26 @@ namespace ICSharpCode.PackageManagement {
public class InstallPackageAction : ProcessPackageOperationsAction
{
+ IFileRemover fileRemover;
+
public InstallPackageAction(
IPackageManagementProject project,
IPackageManagementEvents packageManagementEvents)
- : base(project, packageManagementEvents)
+ : this (project, packageManagementEvents, new FileRemover ())
+ {
+ }
+
+ public InstallPackageAction (
+ IPackageManagementProject project,
+ IPackageManagementEvents packageManagementEvents,
+ IFileRemover fileRemover)
+ : base (project, packageManagementEvents)
{
+ this.fileRemover = fileRemover;
+
OpenReadMeText = true;
}
-
+
public bool IgnoreDependencies { get; set; }
public bool OpenReadMeText { get; set; }
@@ -54,7 +66,9 @@ namespace ICSharpCode.PackageManagement protected override void ExecuteCore()
{
using (IOpenPackageReadMeMonitor monitor = CreateOpenPackageReadMeMonitor (Package.Id)) {
- Project.InstallPackage (Package, this);
+ using (IDisposable fileMonitor = CreateFileMonitor (fileRemover)) {
+ Project.InstallPackage (Package, this);
+ }
monitor.OpenReadMeFile ();
OnParentPackageInstalled ();
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageAction.cs index cf1e92ac1c..d5f6229521 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageAction.cs @@ -253,5 +253,12 @@ namespace ICSharpCode.PackageManagement {
return new OpenPackageReadMeMonitor (packageId, Project, packageManagementEvents);
}
+
+ protected IDisposable CreateFileMonitor (IFileRemover fileRemover)
+ {
+ return new PreventPackagesConfigFileBeingRemovedOnUpdateMonitor (
+ packageManagementEvents,
+ fileRemover);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageOperationsAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageOperationsAction.cs index bd4d6da486..8a8d60f691 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageOperationsAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageOperationsAction.cs @@ -30,6 +30,7 @@ using System; using System.Collections.Generic;
using System.Linq;
using NuGet;
+using MonoDevelop.PackageManagement;
namespace ICSharpCode.PackageManagement
{
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageAction.cs index 6be4d46d97..37a52862d8 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageAction.cs @@ -38,11 +38,22 @@ namespace MonoDevelop.PackageManagement {
public class ReinstallPackageAction : ProcessPackageAction
{
+ IFileRemover fileRemover;
+
public ReinstallPackageAction (
IPackageManagementProject project,
IPackageManagementEvents packageManagementEvents)
+ : this (project, packageManagementEvents, new FileRemover ())
+ {
+ }
+
+ public ReinstallPackageAction (
+ IPackageManagementProject project,
+ IPackageManagementEvents packageManagementEvents,
+ IFileRemover fileRemover)
: base (project, packageManagementEvents)
{
+ this.fileRemover = fileRemover;
}
protected override string StartingMessageFormat {
@@ -51,7 +62,9 @@ namespace MonoDevelop.PackageManagement protected override void ExecuteCore ()
{
- UninstallPackage ();
+ using (IDisposable monitor = CreateFileMonitor (fileRemover)) {
+ UninstallPackage ();
+ }
InstallPackage ();
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageAction.cs index 3cd7a8bbd4..6bfd717029 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageAction.cs @@ -35,7 +35,6 @@ namespace ICSharpCode.PackageManagement {
public class UpdatePackageAction : ProcessPackageOperationsAction, IUpdatePackageSettings
{
- IPackageManagementEvents packageManagementEvents;
IFileRemover fileRemover;
public UpdatePackageAction (
@@ -54,7 +53,6 @@ namespace ICSharpCode.PackageManagement IFileRemover fileRemover)
: base (project, packageManagementEvents)
{
- this.packageManagementEvents = packageManagementEvents;
this.fileRemover = fileRemover;
UpdateDependencies = true;
UpdateIfPackageDoesNotExistInProject = true;
@@ -75,7 +73,7 @@ namespace ICSharpCode.PackageManagement {
if (ShouldUpdatePackage ()) {
using (IOpenPackageReadMeMonitor readmeMonitor = CreateOpenPackageReadMeMonitor (Package.Id)) {
- using (IDisposable monitor = CreateFileMonitor ()) {
+ using (IDisposable monitor = CreateFileMonitor (fileRemover)) {
Project.UpdatePackage (Package, this);
readmeMonitor.OpenReadMeFile ();
}
@@ -111,13 +109,6 @@ namespace ICSharpCode.PackageManagement Logger.Log (MessageLevel.Info, message);
}
- IDisposable CreateFileMonitor ()
- {
- return new PreventPackagesConfigFileBeingRemovedOnUpdateMonitor (
- packageManagementEvents,
- fileRemover);
- }
-
protected override string StartingMessageFormat {
get { return "Updating {0}..."; }
}
|