diff options
author | Matt Ward <ward.matt@gmail.com> | 2015-05-08 13:30:49 +0300 |
---|---|---|
committer | Matt Ward <ward.matt@gmail.com> | 2015-05-08 13:30:49 +0300 |
commit | 2e84735c4737b53a678404edbf34545691f278ff (patch) | |
tree | 0d3934d8b5c2c18fa2ff869553a19ac9be687acf /main/src/addins/MonoDevelop.PackageManagement | |
parent | bf2e20257ef663d78064886a0b7c56d392c9889b (diff) |
[NuGet] Do not open readme.txt if package fails to install.
Fixed bug #29848 - On adding RestSharp package to Android project,
readme.txt file is opened however package is not added.
https://bugzilla.xamarin.com/show_bug.cgi?id=29848
The readme.txt file will no longer be opened if the NuGet package
fails to be added to a project.
Diffstat (limited to 'main/src/addins/MonoDevelop.PackageManagement')
13 files changed, 228 insertions, 39 deletions
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 84bdf214f6..3c7b19962e 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 @@ -51,6 +51,13 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers return FakePackages.FirstOrDefault (package => package.Id == packageId);
};
+ InstallPackageAction = (package, installAction) => {
+ PackagePassedToInstallPackage = package;
+ PackageOperationsPassedToInstallPackage = installAction.Operations;
+ IgnoreDependenciesPassedToInstallPackage = installAction.IgnoreDependencies;
+ AllowPrereleaseVersionsPassedToInstallPackage = installAction.AllowPrereleaseVersions;
+ };
+
UpdatePackageAction = (package, updateAction) => {
PackagePassedToUpdatePackage = package;
PackageOperationsPassedToUpdatePackage = updateAction.Operations;
@@ -117,12 +124,11 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public bool IgnoreDependenciesPassedToInstallPackage;
public bool AllowPrereleaseVersionsPassedToInstallPackage;
+ public Action<IPackage, InstallPackageAction> InstallPackageAction;
+
public void InstallPackage (IPackage package, InstallPackageAction installAction)
{
- PackagePassedToInstallPackage = package;
- PackageOperationsPassedToInstallPackage = installAction.Operations;
- IgnoreDependenciesPassedToInstallPackage = installAction.IgnoreDependencies;
- AllowPrereleaseVersionsPassedToInstallPackage = installAction.AllowPrereleaseVersions;
+ InstallPackageAction (package, installAction);
}
public FakePackageOperation AddFakeInstallOperation ()
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 641c2f72b6..03147f9886 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 @@ -36,16 +36,20 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers IPackageManagementEvents packageManagementEvents)
: base (project, packageManagementEvents)
{
+ CreateOpenPackageReadMeMonitorAction = packageId => {
+ IOpenPackageReadMeMonitor monitor = base.CreateOpenPackageReadMeMonitor (packageId);
+ OpenPackageReadMeMonitor = monitor as OpenPackageReadMeMonitor;
+ NullOpenPackageReadMeMonitorIsCreated = monitor is NullOpenPackageReadMeMonitor;
+ return monitor;
+ };
}
public OpenPackageReadMeMonitor OpenPackageReadMeMonitor;
+ public Func<string, IOpenPackageReadMeMonitor> CreateOpenPackageReadMeMonitorAction;
- protected override IDisposable CreateOpenPackageReadMeMonitor (string packageId)
+ protected override IOpenPackageReadMeMonitor CreateOpenPackageReadMeMonitor (string packageId)
{
- IDisposable monitor = base.CreateOpenPackageReadMeMonitor (packageId);
- OpenPackageReadMeMonitor = monitor as OpenPackageReadMeMonitor;
- NullOpenPackageReadMeMonitorIsCreated = monitor is NullDisposable;
- return monitor;
+ return CreateOpenPackageReadMeMonitorAction (packageId);
}
public bool NullOpenPackageReadMeMonitorIsCreated;
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdatePackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdatePackageAction.cs index ef2a984f74..01cb896f23 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdatePackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdatePackageAction.cs @@ -37,14 +37,18 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers IFileRemover fileRemover)
: base (project, packageManagementEvents, fileRemover)
{
+ CreateOpenPackageReadMeMonitorAction = packageId => {
+ OpenPackageReadMeMonitor = base.CreateOpenPackageReadMeMonitor (packageId) as OpenPackageReadMeMonitor;
+ return OpenPackageReadMeMonitor;
+ };
}
public OpenPackageReadMeMonitor OpenPackageReadMeMonitor;
+ public Func<string, IOpenPackageReadMeMonitor> CreateOpenPackageReadMeMonitorAction;
- protected override IDisposable CreateOpenPackageReadMeMonitor (string packageId)
+ protected override IOpenPackageReadMeMonitor CreateOpenPackageReadMeMonitor (string packageId)
{
- OpenPackageReadMeMonitor = base.CreateOpenPackageReadMeMonitor (packageId) as OpenPackageReadMeMonitor;
- return OpenPackageReadMeMonitor;
+ return CreateOpenPackageReadMeMonitorAction (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 6a9212d7cc..82737da569 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 @@ -26,6 +26,7 @@ using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using ICSharpCode.PackageManagement;
using NuGet;
@@ -41,6 +42,7 @@ namespace MonoDevelop.PackageManagement.Tests FakePackageManagementProject fakeProject;
TestableInstallPackageAction action;
InstallPackageHelper installPackageHelper;
+ FakeFileService fileService;
void CreateAction ()
{
@@ -61,6 +63,12 @@ namespace MonoDevelop.PackageManagement.Tests PackageOperationHelper.CreateListWithOneInstallOperationWithFile (fileName);
}
+ IOpenPackageReadMeMonitor CreateReadMeMonitor (string packageId)
+ {
+ fileService = new FakeFileService (fakeProject.FakeDotNetProject);
+ return new OpenPackageReadMeMonitor (packageId, fakeProject, fileService);
+ }
+
[Test]
public void Execute_PackageIsSet_InstallsPackageIntoProject ()
{
@@ -547,5 +555,54 @@ namespace MonoDevelop.PackageManagement.Tests Assert.IsTrue (action.NullOpenPackageReadMeMonitorIsCreated);
}
+
+ [Test]
+ public void Execute_PackageInstalledSuccessfullyWithReadmeTxt_ReadmeTxtFileIsOpened ()
+ {
+ CreateAction ();
+ installPackageHelper.TestPackage.Id = "Test";
+ installPackageHelper.TestPackage.AddFile ("readme.txt");
+ action.CreateOpenPackageReadMeMonitorAction = packageId => {
+ return CreateReadMeMonitor (packageId);
+ };
+ string installPath = @"d:\projects\myproject\packages\Test.1.0".ToNativePath ();
+ string readmeFileName = Path.Combine (installPath, "readme.txt");
+ fakeProject.InstallPackageAction = (package, installAction) => {
+ var eventArgs = new PackageOperationEventArgs (package, null, installPath);
+ fakeProject.FirePackageInstalledEvent (eventArgs);
+ fileService.ExistingFileNames.Add (readmeFileName);
+ };
+ installPackageHelper.InstallTestPackage ();
+
+ Assert.IsTrue (fileService.IsOpenFileCalled);
+ Assert.AreEqual (readmeFileName, fileService.FileNamePassedToOpenFile);
+ }
+
+ [Test]
+ public void Execute_PackageWithReadmeTxtIsInstalledButExceptionThrownWhenAddingPackageToProject_ReadmeFileIsNotOpened ()
+ {
+ CreateAction ();
+ installPackageHelper.TestPackage.Id = "Test";
+ installPackageHelper.TestPackage.AddFile ("readme.txt");
+ OpenPackageReadMeMonitor monitor = null;
+ action.CreateOpenPackageReadMeMonitorAction = packageId => {
+ monitor = CreateReadMeMonitor (packageId) as OpenPackageReadMeMonitor;
+ return monitor;
+ };
+ string installPath = @"d:\projects\myproject\packages\Test.1.0".ToNativePath ();
+ string readmeFileName = Path.Combine (installPath, "readme.txt");
+ fakeProject.InstallPackageAction = (package, installAction) => {
+ var eventArgs = new PackageOperationEventArgs (package, null, installPath);
+ fakeProject.FirePackageInstalledEvent (eventArgs);
+ fileService.ExistingFileNames.Add (readmeFileName);
+ throw new ApplicationException ();
+ };
+ Assert.Throws<ApplicationException> (() => {
+ installPackageHelper.InstallTestPackage ();
+ });
+
+ Assert.IsFalse (fileService.IsOpenFileCalled);
+ Assert.IsTrue (monitor.IsDisposed);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/OpenPackageReadMeMonitorTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/OpenPackageReadMeMonitorTests.cs index 386197d56d..637b41bf47 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/OpenPackageReadMeMonitorTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/OpenPackageReadMeMonitorTests.cs @@ -58,86 +58,107 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void Dispose_PackageInstalledWithReadmeTxt_ReadmeTxtIsOpened ()
+ public void OpenReadMeFile_PackageInstalledWithReadmeTxt_ReadmeTxtIsOpened ()
{
const string installPath = @"d:\projects\myproject\packages\Test.1.2.0";
string expectedFileOpened = Path.Combine (installPath, "readme.txt");
- using (IDisposable monitor = CreateMonitor ("Test")) {
+ using (OpenPackageReadMeMonitor monitor = CreateMonitor ("Test")) {
fileService.ExistingFileNames.Add (expectedFileOpened);
FakePackage package = CreatePackageWithFile ("Test", "readme.txt");
PackageOperationEventArgs e = CreatePackageInstallEventWithFile (installPath, package);
project.FirePackageInstalledEvent (e);
+ monitor.OpenReadMeFile ();
}
Assert.AreEqual (expectedFileOpened, fileService.FileNamePassedToOpenFile);
}
[Test]
- public void Dispose_PackageDependencyIsInstalledWithReadmeTxt_ReadmeTxtIsNotOpened ()
+ public void Dispose_PackageInstalledWithReadmeTxtButOpenReadMeFileMethodIsNotCalled_ReadmeTxtIsNotOpened ()
+ {
+ const string installPath = @"d:\projects\myproject\packages\Test.1.2.0";
+ string expectedFileOpened = Path.Combine (installPath, "readme.txt");
+
+ using (OpenPackageReadMeMonitor monitor = CreateMonitor ("Test")) {
+ fileService.ExistingFileNames.Add (expectedFileOpened);
+ FakePackage package = CreatePackageWithFile ("Test", "readme.txt");
+ PackageOperationEventArgs e = CreatePackageInstallEventWithFile (installPath, package);
+ project.FirePackageInstalledEvent (e);
+ }
+
+ Assert.IsFalse (fileService.IsOpenFileCalled);
+ }
+
+ [Test]
+ public void OpenReadMeFile_PackageDependencyIsInstalledWithReadmeTxt_ReadmeTxtIsNotOpened ()
{
const string installPath = @"d:\projects\myproject\packages\Test.Dependency.1.2.0";
string expectedFileOpened = Path.Combine (installPath, "readme.txt");
- using (IDisposable monitor = CreateMonitor ("Test")) {
+ using (OpenPackageReadMeMonitor monitor = CreateMonitor ("Test")) {
fileService.ExistingFileNames.Add (expectedFileOpened);
FakePackage package = CreatePackageWithFile ("Test.Dependency", "readme.txt");
PackageOperationEventArgs e = CreatePackageInstallEventWithFile (installPath, package);
project.FirePackageInstalledEvent (e);
+ monitor.OpenReadMeFile ();
}
Assert.IsFalse (fileService.IsOpenFileCalled);
}
[Test]
- public void Dispose_PackageInstalledWithoutReadmeTxt_ReadmeTxtIsNotOpened ()
+ public void OpenReadMeFile_PackageInstalledWithoutReadmeTxt_ReadmeTxtIsNotOpened ()
{
const string installPath = @"d:\projects\myproject\packages\Test.1.2.0";
string expectedFileOpened = Path.Combine (installPath, "readme.txt");
- using (IDisposable monitor = CreateMonitor ("Test")) {
+ using (OpenPackageReadMeMonitor monitor = CreateMonitor ("Test")) {
fileService.ExistingFileNames.Add (expectedFileOpened);
var package = new FakePackage ("Test");
PackageOperationEventArgs e = CreatePackageInstallEventWithFile (installPath, package);
project.FirePackageInstalledEvent (e);
+ monitor.OpenReadMeFile ();
}
Assert.IsFalse (fileService.IsOpenFileCalled);
}
[Test]
- public void Dispose_PackageDependencyIsInstalledWithReadmeTxtWithDifferentCase_ReadmeTxtIsOpened ()
+ public void OpenReadMeFile_PackageDependencyIsInstalledWithReadmeTxtWithDifferentCase_ReadmeTxtIsOpened ()
{
const string installPath = @"d:\projects\myproject\packages\Test.1.2.0";
string expectedFileOpened = Path.Combine (installPath, "ReadMe.TXT");
- using (IDisposable monitor = CreateMonitor ("Test")) {
+ using (OpenPackageReadMeMonitor monitor = CreateMonitor ("Test")) {
fileService.ExistingFileNames.Add (expectedFileOpened);
FakePackage package = CreatePackageWithFile ("Test", "ReadMe.TXT");
PackageOperationEventArgs e = CreatePackageInstallEventWithFile (installPath, package);
project.FirePackageInstalledEvent (e);
+ monitor.OpenReadMeFile ();
}
Assert.AreEqual (expectedFileOpened, fileService.FileNamePassedToOpenFile);
}
[Test]
- public void Dispose_PackageInstalledWithReadmeTxtButFileDoesNotExistOnFileSystem_ReadmeTxtIsNotOpened ()
+ public void OpenReadMeFile_PackageInstalledWithReadmeTxtButFileDoesNotExistOnFileSystem_ReadmeTxtIsNotOpened ()
{
const string installPath = @"d:\projects\myproject\packages\Test.1.2.0";
string readmeFileName = Path.Combine (installPath, "readme.txt");
- using (IDisposable monitor = CreateMonitor ("Test")) {
+ using (OpenPackageReadMeMonitor monitor = CreateMonitor ("Test")) {
FakePackage package = CreatePackageWithFile ("Test", "readme.txt");
PackageOperationEventArgs e = CreatePackageInstallEventWithFile (installPath, package);
project.FirePackageInstalledEvent (e);
+ monitor.OpenReadMeFile ();
}
Assert.IsFalse (fileService.IsOpenFileCalled);
}
[Test]
- public void Constructor_PackageDependencyIsInstalledWithReadmeTxt_ReadmeTxtIsNotOpenedUntilDisposeIsCalled ()
+ public void Constructor_PackageDependencyIsInstalledWithReadmeTxt_ReadmeTxtIsNotOpenedUntilOpenReadMeFileMethodIsCalled ()
{
const string installPath = @"d:\projects\myproject\packages\Test.1.2.0";
string expectedFileOpened = Path.Combine (installPath, "ReadMe.TXT");
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatePackageActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatePackageActionTests.cs index dbb47c720c..4ea15a6e07 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatePackageActionTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatePackageActionTests.cs @@ -26,6 +26,7 @@ using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using ICSharpCode.PackageManagement;
using NuGet;
@@ -43,6 +44,7 @@ namespace MonoDevelop.PackageManagement.Tests UpdatePackageHelper updatePackageHelper;
FakeFileRemover fileRemover;
List<PackageOperationMessage> messagesLogged;
+ FakeFileService fileService;
void CreateSolution ()
{
@@ -78,6 +80,12 @@ namespace MonoDevelop.PackageManagement.Tests Assert.That (messages, Contains.Item (expectedMessage));
}
+ IOpenPackageReadMeMonitor CreateReadMeMonitor (string packageId)
+ {
+ fileService = new FakeFileService (fakeProject.FakeDotNetProject);
+ return new OpenPackageReadMeMonitor (packageId, fakeProject, fileService);
+ }
+
[Test]
public void Execute_PackageAndRepositoryPassed_PackageIsUpdated ()
{
@@ -485,6 +493,55 @@ namespace MonoDevelop.PackageManagement.Tests Assert.AreEqual ("Test", action.OpenPackageReadMeMonitor.PackageId);
Assert.IsTrue (action.OpenPackageReadMeMonitor.IsDisposed);
}
+
+ [Test]
+ public void Execute_PackageInstalledSuccessfullyWithReadmeTxt_ReadmeTxtFileIsOpened ()
+ {
+ CreateSolution ();
+ updatePackageHelper.TestPackage.Id = "Test";
+ updatePackageHelper.TestPackage.AddFile ("readme.txt");
+ action.CreateOpenPackageReadMeMonitorAction = packageId => {
+ return CreateReadMeMonitor (packageId);
+ };
+ string installPath = @"d:\projects\myproject\packages\Test.1.0".ToNativePath ();
+ string readmeFileName = Path.Combine (installPath, "readme.txt");
+ fakeProject.UpdatePackageAction = (package, updateAction) => {
+ var eventArgs = new PackageOperationEventArgs (package, null, installPath);
+ fakeProject.FirePackageInstalledEvent (eventArgs);
+ fileService.ExistingFileNames.Add (readmeFileName);
+ };
+ updatePackageHelper.UpdateTestPackage ();
+
+ Assert.IsTrue (fileService.IsOpenFileCalled);
+ Assert.AreEqual (readmeFileName, fileService.FileNamePassedToOpenFile);
+ }
+
+ [Test]
+ public void Execute_PackageWithReadmeTxtIsInstalledButExceptionThrownWhenAddingPackageToProject_ReadmeFileIsNotOpened ()
+ {
+ CreateSolution ();
+ updatePackageHelper.TestPackage.Id = "Test";
+ updatePackageHelper.TestPackage.AddFile ("readme.txt");
+ OpenPackageReadMeMonitor monitor = null;
+ action.CreateOpenPackageReadMeMonitorAction = packageId => {
+ monitor = CreateReadMeMonitor (packageId) as OpenPackageReadMeMonitor;
+ return monitor;
+ };
+ string installPath = @"d:\projects\myproject\packages\Test.1.0".ToNativePath ();
+ string readmeFileName = Path.Combine (installPath, "readme.txt");
+ fakeProject.UpdatePackageAction = (package, updateAction) => {
+ var eventArgs = new PackageOperationEventArgs (package, null, installPath);
+ fakeProject.FirePackageInstalledEvent (eventArgs);
+ fileService.ExistingFileNames.Add (readmeFileName);
+ throw new ApplicationException ();
+ };
+ Assert.Throws<ApplicationException> (() => {
+ updatePackageHelper.UpdateTestPackage ();
+ });
+
+ Assert.IsFalse (fileService.IsOpenFileCalled);
+ Assert.IsTrue (monitor.IsDisposed);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj index fbb0606e38..e2ec817117 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj @@ -369,7 +369,8 @@ <Compile Include="MonoDevelop.PackageManagement\CheckForUpdatesTask.cs" /> <Compile Include="MonoDevelop.PackageManagement\ProjectReloadedEventArgs.cs" /> <Compile Include="MonoDevelop.PackageManagement\OpenPackageReadmeMonitor.cs" /> - <Compile Include="MonoDevelop.PackageManagement\NullDisposable.cs" /> + <Compile Include="MonoDevelop.PackageManagement\IOpenPackageReadMeMonitor.cs" /> + <Compile Include="MonoDevelop.PackageManagement\NullOpenPackageReadMeMonitor.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="MonoDevelop.PackageManagement.addin.xml" /> diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NullDisposable.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IOpenPackageReadMeMonitor.cs index 0cb8d52d93..d24baf45c4 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NullDisposable.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IOpenPackageReadMeMonitor.cs @@ -1,5 +1,5 @@ //
-// NullDisposable.cs
+// IOpenPackageReadMeMonitor.cs
//
// Author:
// Matt Ward <matt.ward@xamarin.com>
@@ -28,13 +28,9 @@ using System; namespace MonoDevelop.PackageManagement
{
- public class NullDisposable : IDisposable
+ public interface IOpenPackageReadMeMonitor : IDisposable
{
- public static readonly IDisposable Null = new NullDisposable ();
-
- public void Dispose ()
- {
- }
+ void OpenReadMeFile ();
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs index af7c6d545f..2f7dffa50d 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs @@ -53,8 +53,9 @@ namespace ICSharpCode.PackageManagement protected override void ExecuteCore()
{
- using (IDisposable monitor = CreateOpenPackageReadMeMonitor (Package.Id)) {
+ using (IOpenPackageReadMeMonitor monitor = CreateOpenPackageReadMeMonitor (Package.Id)) {
Project.InstallPackage (Package, this);
+ monitor.OpenReadMeFile ();
OnParentPackageInstalled ();
}
}
@@ -63,12 +64,12 @@ namespace ICSharpCode.PackageManagement get { return "Adding {0}..."; }
}
- protected override IDisposable CreateOpenPackageReadMeMonitor (string packageId)
+ protected override IOpenPackageReadMeMonitor CreateOpenPackageReadMeMonitor (string packageId)
{
if (OpenReadMeText) {
return base.CreateOpenPackageReadMeMonitor (packageId);
}
- return NullDisposable.Null;
+ return NullOpenPackageReadMeMonitor.Null;
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NullOpenPackageReadMeMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NullOpenPackageReadMeMonitor.cs new file mode 100644 index 0000000000..51414a77f0 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NullOpenPackageReadMeMonitor.cs @@ -0,0 +1,42 @@ +//
+// NullOpenPackageReadMeMonitor.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.
+
+namespace MonoDevelop.PackageManagement
+{
+ public class NullOpenPackageReadMeMonitor : IOpenPackageReadMeMonitor
+ {
+ public static readonly IOpenPackageReadMeMonitor Null = new NullOpenPackageReadMeMonitor ();
+
+ public void Dispose ()
+ {
+ }
+
+ public void OpenReadMeFile ()
+ {
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/OpenPackageReadmeMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/OpenPackageReadmeMonitor.cs index f2c4612759..dcef59e884 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/OpenPackageReadmeMonitor.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/OpenPackageReadmeMonitor.cs @@ -32,7 +32,7 @@ using NuGet; namespace MonoDevelop.PackageManagement
{
- public class OpenPackageReadMeMonitor : IDisposable
+ public class OpenPackageReadMeMonitor : IOpenPackageReadMeMonitor
{
IPackageManagementProject project;
IPackageManagementFileService fileService;
@@ -70,7 +70,6 @@ namespace MonoDevelop.PackageManagement IsDisposed = true;
project.PackageInstalled -= PackageInstalled;
- OpenReadMeFile ();
}
void PackageInstalled (object sender, PackageOperationEventArgs e)
@@ -90,7 +89,7 @@ namespace MonoDevelop.PackageManagement .FirstOrDefault ();
}
- void OpenReadMeFile ()
+ public void OpenReadMeFile ()
{
if ((ReadMeFile != null) && fileService.FileExists (ReadMeFile)) {
fileService.OpenFile (ReadMeFile);
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageAction.cs index 5ecc13cd24..cf1e92ac1c 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageAction.cs @@ -249,7 +249,7 @@ namespace ICSharpCode.PackageManagement return PackageVersion;
}
- protected virtual IDisposable CreateOpenPackageReadMeMonitor (string packageId)
+ protected virtual IOpenPackageReadMeMonitor CreateOpenPackageReadMeMonitor (string packageId)
{
return new OpenPackageReadMeMonitor (packageId, Project, packageManagementEvents);
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageAction.cs index 3cce200b0a..3cd7a8bbd4 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageAction.cs @@ -74,9 +74,10 @@ namespace ICSharpCode.PackageManagement protected override void ExecuteCore()
{
if (ShouldUpdatePackage ()) {
- using (IDisposable readmeMonitor = CreateOpenPackageReadMeMonitor (Package.Id)) {
+ using (IOpenPackageReadMeMonitor readmeMonitor = CreateOpenPackageReadMeMonitor (Package.Id)) {
using (IDisposable monitor = CreateFileMonitor ()) {
Project.UpdatePackage (Package, this);
+ readmeMonitor.OpenReadMeFile ();
}
}
OnParentPackageInstalled ();
|