diff options
author | Matt Ward <ward.matt@gmail.com> | 2015-04-26 16:37:31 +0300 |
---|---|---|
committer | Matt Ward <ward.matt@gmail.com> | 2015-04-26 16:43:19 +0300 |
commit | bf2e20257ef663d78064886a0b7c56d392c9889b (patch) | |
tree | 6e039124cefea763f25187e5dd5c8c05b625828b /main/src/addins/MonoDevelop.PackageManagement | |
parent | aa27f086b0aad8a432a06628ac4b93d8cb41cd0c (diff) |
[NuGet] Do not open readme.txt when retargeting a NuGet package.
Retargeting a NuGet package after the project's target framework has
changed was opening the NuGet package's readme.txt as though the NuGet
package was being installed again.
Diffstat (limited to 'main/src/addins/MonoDevelop.PackageManagement')
7 files changed, 89 insertions, 3 deletions
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 cd981cf0fb..641c2f72b6 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 @@ -42,9 +42,13 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers protected override IDisposable CreateOpenPackageReadMeMonitor (string packageId)
{
- OpenPackageReadMeMonitor = base.CreateOpenPackageReadMeMonitor (packageId) as OpenPackageReadMeMonitor;
- return OpenPackageReadMeMonitor;
+ IDisposable monitor = base.CreateOpenPackageReadMeMonitor (packageId);
+ OpenPackageReadMeMonitor = monitor as OpenPackageReadMeMonitor;
+ NullOpenPackageReadMeMonitorIsCreated = monitor is NullDisposable;
+ return monitor;
}
+
+ public bool NullOpenPackageReadMeMonitorIsCreated;
}
}
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 c14c836dfd..6a9212d7cc 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 @@ -529,5 +529,23 @@ namespace MonoDevelop.PackageManagement.Tests Assert.AreEqual ("Test", action.OpenPackageReadMeMonitor.PackageId);
Assert.IsTrue (action.OpenPackageReadMeMonitor.IsDisposed);
}
+
+ [Test]
+ public void OpenReadMeText_DefaultValue_IsTrue ()
+ {
+ CreateAction ();
+ Assert.IsTrue (action.OpenReadMeText);
+ }
+
+ [Test]
+ public void Execute_OpenReadMeTextSetToFalse_NullOpenPackageReadmeMonitorCreated ()
+ {
+ CreateAction ();
+ action.OpenReadMeText = false;
+ installPackageHelper.TestPackage.Id = "Test";
+ installPackageHelper.InstallTestPackage();
+
+ Assert.IsTrue (action.NullOpenPackageReadMeMonitorIsCreated);
+ }
}
}
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 a29f34d06c..cb5e9e8fd4 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 @@ -90,6 +90,18 @@ namespace MonoDevelop.PackageManagement.Tests Assert.IsTrue (project.FakeUninstallPackageAction.ForceRemove);
}
+
+ [Test]
+ public void Execute_PackageExistsInSourceRepository_PackageIsInstalledWithoutOpeningReadmeTxt ()
+ {
+ CreateAction ("MyPackage", "1.2.3.4");
+ FakePackage package = AddPackageToSourceRepository ("MyPackage", "1.2.3.4");
+
+ action.Execute ();
+
+ Assert.IsTrue (project.LastInstallPackageCreated.IsExecuteCalled);
+ Assert.IsFalse (project.LastInstallPackageCreated.OpenReadMeText);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj index e97d869732..fbb0606e38 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj @@ -369,6 +369,7 @@ <Compile Include="MonoDevelop.PackageManagement\CheckForUpdatesTask.cs" /> <Compile Include="MonoDevelop.PackageManagement\ProjectReloadedEventArgs.cs" /> <Compile Include="MonoDevelop.PackageManagement\OpenPackageReadmeMonitor.cs" /> + <Compile Include="MonoDevelop.PackageManagement\NullDisposable.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="MonoDevelop.PackageManagement.addin.xml" /> diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs index 571910841c..af7c6d545f 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs @@ -28,7 +28,7 @@ using System;
using System.Collections.Generic;
-using System.IO;
+using MonoDevelop.PackageManagement;
using NuGet;
namespace ICSharpCode.PackageManagement
@@ -40,9 +40,11 @@ namespace ICSharpCode.PackageManagement IPackageManagementEvents packageManagementEvents)
: base(project, packageManagementEvents)
{
+ OpenReadMeText = true;
}
public bool IgnoreDependencies { get; set; }
+ public bool OpenReadMeText { get; set; }
protected override IEnumerable<PackageOperation> GetPackageOperations()
{
@@ -60,5 +62,13 @@ namespace ICSharpCode.PackageManagement protected override string StartingMessageFormat {
get { return "Adding {0}..."; }
}
+
+ protected override IDisposable CreateOpenPackageReadMeMonitor (string packageId)
+ {
+ if (OpenReadMeText) {
+ return base.CreateOpenPackageReadMeMonitor (packageId);
+ }
+ return NullDisposable.Null;
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NullDisposable.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NullDisposable.cs new file mode 100644 index 0000000000..0cb8d52d93 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NullDisposable.cs @@ -0,0 +1,40 @@ +//
+// NullDisposable.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+namespace MonoDevelop.PackageManagement
+{
+ public class NullDisposable : IDisposable
+ {
+ public static readonly IDisposable Null = new NullDisposable ();
+
+ public void Dispose ()
+ {
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageAction.cs index f9974f0d08..6be4d46d97 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageAction.cs @@ -67,6 +67,7 @@ namespace MonoDevelop.PackageManagement {
InstallPackageAction action = Project.CreateInstallPackageAction ();
action.Package = Package;
+ action.OpenReadMeText = false;
action.Execute ();
}
}
|