diff options
author | Matt Ward <matt.ward@xamarin.com> | 2015-08-26 12:58:36 +0300 |
---|---|---|
committer | Matt Ward <matt.ward@xamarin.com> | 2015-08-26 12:58:36 +0300 |
commit | 2e2d15ac59daf1079c5e3912307875521c45d7f6 (patch) | |
tree | 3f7fa41a09fd6f2ee8ea08c92a39ffc93b31b459 /main/src/addins/MonoDevelop.PackageManagement | |
parent | 590696a50c48dc10b67af234c2764431331729e9 (diff) | |
parent | fe6223ba409ebe2d9a27a00431ba0f5300dfdaa8 (diff) |
Merge branch 'nuget-remove-check-for-updates-from-status-bar'
Diffstat (limited to 'main/src/addins/MonoDevelop.PackageManagement')
11 files changed, 30 insertions, 523 deletions
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableCheckForUpdatesProgressMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableCheckForUpdatesProgressMonitor.cs deleted file mode 100644 index d35e6aefe5..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableCheckForUpdatesProgressMonitor.cs +++ /dev/null @@ -1,49 +0,0 @@ -//
-// TestableCheckForUpdatesProgressMonitor.cs
-//
-// Author:
-// Matt Ward <matt.ward@xamarin.com>
-//
-// Copyright (c) 2014 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;
-using ICSharpCode.PackageManagement;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- public class TestableCheckForUpdatesProgressMonitor : CheckForUpdatesProgressMonitor
- {
- public TestableCheckForUpdatesProgressMonitor (
- IPackageManagementProgressMonitorFactory progressMonitorFactory,
- IPackageManagementEvents packageEvents)
- : base (progressMonitorFactory, packageEvents)
- {
- }
-
- public bool IsPackageConsoleShown;
-
- protected override void ShowPackageConsole ()
- {
- IsPackageConsoleShown = true;
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/TestableCheckForUpdatesTaskRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableCheckForUpdatesTaskRunner.cs index 548db011cc..6744012901 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/TestableCheckForUpdatesTaskRunner.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableCheckForUpdatesTaskRunner.cs @@ -25,36 +25,32 @@ // THE SOFTWARE.
using System;
+using System.Collections.Generic;
using ICSharpCode.PackageManagement;
using MonoDevelop.Ide;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-namespace MonoDevelop.PackageManagement.Tests
+namespace MonoDevelop.PackageManagement.Tests.Helpers
{
public class TestableCheckForUpdatesTaskRunner : CheckForUpdatesTaskRunner
{
- public TestableCheckForUpdatesTaskRunner (
- ITaskFactory taskFactory,
- IPackageManagementProgressMonitorFactory progressMonitorFactory,
- IPackageManagementEvents packageManagementEvents)
- : base (taskFactory, progressMonitorFactory, packageManagementEvents)
- {
- }
+ public List<string> LoggedErrorMessages = new List<string> ();
+ public List<Exception> LoggedExceptions = new List<Exception> ();
- protected override CheckForUpdatesProgressMonitor CreateProgressMonitor (
- IPackageManagementProgressMonitorFactory progressMonitorFactory,
- IPackageManagementEvents packageManagementEvents)
+ public TestableCheckForUpdatesTaskRunner (ITaskFactory taskFactory)
+ : base (taskFactory)
{
- ProgressMonitorCreated = new TestableCheckForUpdatesProgressMonitor (progressMonitorFactory, packageManagementEvents);
- return ProgressMonitorCreated;
}
- public TestableCheckForUpdatesProgressMonitor ProgressMonitorCreated { get; set; }
-
protected override void GuiBackgroundDispatch (MessageHandler handler)
{
handler.Invoke ();
}
+
+ protected override void LogError (string message, Exception ex)
+ {
+ LoggedErrorMessages.Add (message);
+ LoggedExceptions.Add (ex);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.csproj b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.csproj index ec5a0df98e..0ac0580ef8 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.csproj +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.csproj @@ -204,14 +204,12 @@ <Compile Include="MonoDevelop.PackageManagement.Tests\MSBuildTargetsRestoredMonitorTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\EnsureNuGetPackageBuildImportsTargetUpdaterTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\ExceptionThrowingSolutionPackageRepository.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\CheckForUpdatesProgressMonitorTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableCheckForUpdatesProgressMonitor.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\TestableCheckForUpdatesTaskRunner.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\OpenPackageReadMeMonitorTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableInstallPackageAction.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableUpdatePackageAction.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\FilePathExtensionsTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\DotNetProjectExtensionsTests.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableCheckForUpdatesTaskRunner.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj"> diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/CheckForUpdatesProgressMonitorTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/CheckForUpdatesProgressMonitorTests.cs deleted file mode 100644 index 56abc52484..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/CheckForUpdatesProgressMonitorTests.cs +++ /dev/null @@ -1,148 +0,0 @@ -//
-// CheckForUpdatesProgressMonitorTests.cs
-//
-// Author:
-// Matt Ward <matt.ward@xamarin.com>
-//
-// Copyright (c) 2014 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;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using MonoDevelop.Core;
-using ICSharpCode.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class CheckForUpdatesProgressMonitorTests
- {
- TestableCheckForUpdatesProgressMonitor progressMonitor;
- FakeProgressMonitorFactory progressMonitorFactory;
- FakeProgressMonitor fakeProgressMonitor;
- PackageManagementEvents packageEvents;
-
- void CreateProgressMonitor ()
- {
- progressMonitorFactory = new FakeProgressMonitorFactory ();
- fakeProgressMonitor = progressMonitorFactory.ProgressMonitor;
- packageEvents = new PackageManagementEvents ();
- progressMonitor = new TestableCheckForUpdatesProgressMonitor (progressMonitorFactory, packageEvents);
- }
-
- [Test]
- public void Constructor_NewInstance_CreatesProgressMonitor ()
- {
- CreateProgressMonitor ();
-
- Assert.AreEqual (GettextCatalog.GetString ("Checking for package updates..."), progressMonitorFactory.StatusText);
- }
-
- [Test]
- public void Dispose_NewInstance_ProgressMonitorIsDisposed ()
- {
- CreateProgressMonitor ();
-
- progressMonitor.Dispose ();
-
- Assert.IsTrue (fakeProgressMonitor.IsDisposed);
- }
-
- [Test]
- public void Constructor_PackageManagementMessageEventFired_MessageLoggedToProgressMonitor ()
- {
- CreateProgressMonitor ();
-
- packageEvents.OnPackageOperationMessageLogged (MessageLevel.Info, "MyMessage");
-
- fakeProgressMonitor.AssertMessageIsLogged ("MyMessage");
- }
-
- [Test]
- public void Dispose_MessageLoggedAfterDispose_MessageNotLoggedToProgressMonitor ()
- {
- CreateProgressMonitor ();
- progressMonitor.Dispose ();
-
- packageEvents.OnPackageOperationMessageLogged (MessageLevel.Info, "MyMessage");
-
- fakeProgressMonitor.AssertMessageIsNotLogged ("MyMessage");
- }
-
- [Test]
- public void ReportError_ReportException_ExceptionReportedToProgressMonitor ()
- {
- CreateProgressMonitor ();
- var exception = new Exception ("Error");
-
- progressMonitor.ReportError (exception);
-
- fakeProgressMonitor.AssertMessageIsLogged ("Error");
- Assert.AreEqual (GettextCatalog.GetString ("Could not check for package updates."), fakeProgressMonitor.ReportedErrorMessage);
- Assert.IsTrue (progressMonitor.IsPackageConsoleShown);
- }
-
- [Test]
- public void ReportError_ReportDispatchServiceException_UnderlyingExceptionReported ()
- {
- CreateProgressMonitor ();
- var exception = new Exception ("Error");
- string message = "An exception was thrown while dispatching a method call in the UI thread.";
- var dispatchServiceException = new Exception (message, exception);
-
- progressMonitor.ReportError (dispatchServiceException);
-
- fakeProgressMonitor.AssertMessageIsLogged ("Error");
- }
-
- [Test]
- public void ReportSuccess_UpdatesAvailable_UpdatesAvailableMessageShownByProgressMonitor ()
- {
- CreateProgressMonitor ();
-
- progressMonitor.ReportSuccess (true);
-
- Assert.AreEqual (GettextCatalog.GetString ("Package updates are available."), fakeProgressMonitor.ReportedSuccessMessage);
- }
-
- [Test]
- public void ReportSuccess_NoUpdatesAvailable_NoUpdatesAvailableMessageShownByProgressMonitor ()
- {
- CreateProgressMonitor ();
-
- progressMonitor.ReportSuccess (false);
-
- Assert.AreEqual (GettextCatalog.GetString ("Packages are up to date."), fakeProgressMonitor.ReportedSuccessMessage);
- }
-
- [Test]
- public void ReportSuccess_NoUpdatesAvailableButWarningLogged_NoUpdatesAvailableWithWarningMessageShownByProgressMonitor ()
- {
- CreateProgressMonitor ();
- packageEvents.OnPackageOperationMessageLogged (MessageLevel.Warning, "WarningMessage");
-
- progressMonitor.ReportSuccess (false);
-
- Assert.AreEqual (GettextCatalog.GetString ("No updates found but warnings were reported."), fakeProgressMonitor.ReportedWarningMessage);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedPackagesInSolutionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedPackagesInSolutionTests.cs index 0469b53d99..a67593fd7c 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedPackagesInSolutionTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedPackagesInSolutionTests.cs @@ -54,10 +54,7 @@ namespace MonoDevelop.PackageManagement.Tests taskFactory = new FakeTaskFactory ();
taskFactory.RunTasksSynchronously = true;
progressMonitorFactory = new FakeProgressMonitorFactory ();
- checkForUpdatesTaskRunner = new TestableCheckForUpdatesTaskRunner (
- taskFactory,
- progressMonitorFactory,
- packageManagementEvents);
+ checkForUpdatesTaskRunner = new TestableCheckForUpdatesTaskRunner (taskFactory);
updatedPackagesInSolution = new TestableUpdatedPackagesInSolution (
solution,
registeredPackageRepositories,
@@ -387,61 +384,7 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void CheckForUpdates_OnePackageUpdated_ProgressMonitorCreatedAndDisposedAfterCheckForUpdatesReturned ()
- {
- CreateUpdatedPackagesInSolution ();
- taskFactory.RunTasksSynchronously = false;
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- updatedPackagesInSolution.CheckForUpdates ();
- bool progressMonitorCreated = checkForUpdatesTaskRunner.ProgressMonitorCreated != null;
- bool disposedBeforeTaskRun = progressMonitorFactory.ProgressMonitor.IsDisposed;
-
- taskFactory.ExecuteAllTasks<CheckForUpdatesTask> ();
-
- Assert.IsTrue (progressMonitorCreated);
- Assert.IsFalse (disposedBeforeTaskRun);
- Assert.IsTrue (progressMonitorFactory.ProgressMonitor.IsDisposed);
- }
-
- [Test]
- public void CheckForUpdates_OnePackageUpdatedButSolutionClosedBeforeResultsReturned_ProgressMonitorIsDisposed ()
- {
- CreateUpdatedPackagesInSolution ();
- taskFactory.RunTasksSynchronously = false;
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- updatedPackagesInSolution.CheckForUpdates ();
- bool progressMonitorCreated = checkForUpdatesTaskRunner.ProgressMonitorCreated != null;
- bool disposedBeforeTaskRun = progressMonitorFactory.ProgressMonitor.IsDisposed;
- var task = taskFactory.FakeTasksCreated [0] as FakeTask<CheckForUpdatesTask>;
- task.ExecuteTaskButNotContinueWith ();
- updatedPackagesInSolution.Clear ();
-
- task.ExecuteContinueWith ();
-
- Assert.IsTrue (progressMonitorCreated);
- Assert.IsFalse (disposedBeforeTaskRun);
- Assert.IsTrue (progressMonitorFactory.ProgressMonitor.IsDisposed);
- }
-
- [Test]
- public void CheckForUpdates_OnePackageUpdated_SuccessReportedToProgressMonitor ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
-
- updatedPackagesInSolution.CheckForUpdates ();
-
- Assert.AreEqual (GettextCatalog.GetString ("Package updates are available."), progressMonitorFactory.ProgressMonitor.ReportedSuccessMessage);
- }
-
- [Test]
- public void CheckForUpdates_NoPackagesUpdated_SuccessReportedToProgressMonitor ()
+ public void CheckForUpdates_NoPackagesUpdated_NoUpdates ()
{
CreateUpdatedPackagesInSolution ();
FakePackageManagementProject project = AddProjectToSolution ();
@@ -451,11 +394,10 @@ namespace MonoDevelop.PackageManagement.Tests UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
Assert.IsFalse (updatedPackagesInSolution.AnyUpdates ());
- Assert.AreEqual (GettextCatalog.GetString ("Packages are up to date."), progressMonitorFactory.ProgressMonitor.ReportedSuccessMessage);
}
[Test]
- public void CheckForUpdates_ExceptionThrownWhilstCheckingForUpdates_ErrorReportedToProgressMonitorWhichIsDisposed ()
+ public void CheckForUpdates_ExceptionThrownWhilstCheckingForUpdates_ExceptionLogged ()
{
CreateUpdatedPackagesInSolution ();
taskFactory.RunTasksSynchronously = false;
@@ -471,14 +413,12 @@ namespace MonoDevelop.PackageManagement.Tests task.Result = null;
task.ExecuteContinueWith ();
- Assert.AreEqual (GettextCatalog.GetString ("Could not check for package updates."), progressMonitorFactory.ProgressMonitor.ReportedErrorMessage);
- Assert.IsTrue (checkForUpdatesTaskRunner.ProgressMonitorCreated.IsPackageConsoleShown);
- progressMonitorFactory.ProgressMonitor.AssertMessageIsLogged ("Inner exception error message");
- Assert.IsTrue (progressMonitorFactory.ProgressMonitor.IsDisposed);
+ Assert.AreEqual ("Current check for updates task error.", checkForUpdatesTaskRunner.LoggedErrorMessages[0]);
+ Assert.AreEqual (task.Exception, checkForUpdatesTaskRunner.LoggedExceptions[0]);
}
[Test]
- public void CheckForUpdates_ExceptionThrownWhilstCheckingForUpdatesButSolutionClosedBeforeCheckForUpdatesReturns_ErrorIsNotReportedButProgressMonitorIsDisposed ()
+ public void CheckForUpdates_ExceptionThrownWhilstCheckingForUpdatesButSolutionClosedBeforeCheckForUpdatesReturns_ErrorIsLogged ()
{
CreateUpdatedPackagesInSolution ();
taskFactory.RunTasksSynchronously = false;
@@ -494,13 +434,12 @@ namespace MonoDevelop.PackageManagement.Tests task.Result = null;
task.ExecuteContinueWith ();
- Assert.IsNull (progressMonitorFactory.ProgressMonitor.ReportedErrorMessage);
- progressMonitorFactory.ProgressMonitor.AssertMessageIsNotLogged ("Error message");
- Assert.IsTrue (progressMonitorFactory.ProgressMonitor.IsDisposed);
+ Assert.AreEqual ("Check for updates task error.", checkForUpdatesTaskRunner.LoggedErrorMessages[0]);
+ Assert.AreEqual (task.Exception, checkForUpdatesTaskRunner.LoggedExceptions[0]);
}
[Test]
- public void CheckForUpdates_ExceptionThrownWhilstCheckingForUpdatesButSolutionClosedBeforeCheckForUpdatesReturnsAndSecondCheckForUpdatesIsStarted_ErrorIsNotReported ()
+ public void CheckForUpdates_ExceptionThrownWhilstCheckingForUpdatesButSolutionClosedBeforeCheckForUpdatesReturnsAndSecondCheckForUpdatesIsStarted_ErrorIsLogged ()
{
CreateUpdatedPackagesInSolution ();
taskFactory.RunTasksSynchronously = false;
@@ -516,9 +455,8 @@ namespace MonoDevelop.PackageManagement.Tests task.Result = null;
task.ExecuteContinueWith ();
- Assert.IsNull (progressMonitorFactory.ProgressMonitor.ReportedErrorMessage);
- progressMonitorFactory.ProgressMonitor.AssertMessageIsNotLogged ("Error message");
- Assert.IsTrue (progressMonitorFactory.ProgressMonitor.IsDisposed);
+ Assert.AreEqual ("Check for updates task error.", checkForUpdatesTaskRunner.LoggedErrorMessages[0]);
+ Assert.AreEqual (task.Exception, checkForUpdatesTaskRunner.LoggedExceptions[0]);
}
[Test]
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj index 2ef5d70c2c..50427e9d71 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj @@ -342,7 +342,6 @@ <Compile Include="MonoDevelop.PackageManagement\IUpdatedPackagesInSolution.cs" /> <Compile Include="MonoDevelop.PackageManagement\FallbackRepository.cs" /> <Compile Include="MonoDevelop.PackageManagement.Commands\PackageManagementStartupHandler.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageUpdatesEventMonitor.cs" /> <Compile Include="MonoDevelop.PackageManagement\UpdatedPackagesMonitor.cs" /> <Compile Include="MonoDevelop.PackageManagement\UpdatePackagesProgressMonitorStatusMessage.cs" /> <Compile Include="MonoDevelop.PackageManagement\CheckForUpdatedPackagesAction.cs" /> @@ -364,7 +363,6 @@ <Compile Include="MonoDevelop.PackageManagement\MSBuildTargetsRestoredMonitor.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementMSBuildExtension.cs" /> <Compile Include="MonoDevelop.PackageManagement\EnsureNuGetPackageBuildImportsTargetUpdater.cs" /> - <Compile Include="MonoDevelop.PackageManagement\CheckForUpdatesProgressMonitor.cs" /> <Compile Include="MonoDevelop.PackageManagement\CheckForUpdatesTaskRunner.cs" /> <Compile Include="MonoDevelop.PackageManagement\CheckForUpdatesTask.cs" /> <Compile Include="MonoDevelop.PackageManagement\ProjectReloadedEventArgs.cs" /> diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesProgressMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesProgressMonitor.cs deleted file mode 100644 index dbcb6fe501..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesProgressMonitor.cs +++ /dev/null @@ -1,104 +0,0 @@ -//
-// CheckForUpdatesProgressMonitor.cs
-//
-// Author:
-// Matt Ward <matt.ward@xamarin.com>
-//
-// Copyright (c) 2014 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;
-using ICSharpCode.PackageManagement;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.PackageManagement
-{
- public class CheckForUpdatesProgressMonitor : IDisposable
- {
- ProgressMonitorStatusMessage progressMessage;
- IProgressMonitor progressMonitor;
- PackageUpdatesEventMonitor eventMonitor;
-
- public CheckForUpdatesProgressMonitor ()
- : this (
- PackageManagementServices.ProgressMonitorFactory,
- PackageManagementServices.PackageManagementEvents)
- {
- }
-
- public CheckForUpdatesProgressMonitor (
- IPackageManagementProgressMonitorFactory progressMonitorFactory,
- IPackageManagementEvents packageEvents)
- {
- progressMessage = ProgressMonitorStatusMessageFactory.CreateCheckingForPackageUpdatesMessage ();
- this.progressMonitor = progressMonitorFactory.CreateProgressMonitor (progressMessage.Status);
-
- eventMonitor = new PackageUpdatesEventMonitor (progressMonitor, packageEvents);
- }
-
- public void Dispose ()
- {
- eventMonitor.Dispose ();
- progressMonitor.Dispose ();
- }
-
- public void ReportError (Exception ex)
- {
- LoggingService.LogInternalError (ex);
- if (IsGuiDispatchException (ex)) {
- progressMonitor.Log.WriteLine (ex.InnerException.Message);
- } else if (ex is AggregateException) {
- LogAggregateException ((AggregateException)ex);
- } else {
- progressMonitor.Log.WriteLine (ex.Message);
- }
- progressMonitor.ReportError (progressMessage.Error, null);
- ShowPackageConsole ();
- }
-
- static bool IsGuiDispatchException (Exception ex)
- {
- return (ex.InnerException != null) &&
- (ex.Message == "An exception was thrown while dispatching a method call in the UI thread.");
- }
-
- void LogAggregateException (AggregateException ex)
- {
- progressMonitor.Log.WriteLine (new AggregateExceptionErrorMessage (ex));
- }
-
- protected virtual void ShowPackageConsole ()
- {
- progressMonitor.ShowPackageConsole ();
- }
-
- public void ReportSuccess (bool anyUpdates)
- {
- if (anyUpdates) {
- progressMonitor.ReportSuccess (GettextCatalog.GetString ("Package updates are available."));
- } else if (eventMonitor.WarningReported) {
- progressMonitor.ReportWarning (progressMessage.Warning);
- } else {
- progressMonitor.ReportSuccess (progressMessage.Success);
- }
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTask.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTask.cs index 45d7c73716..d59e6517f8 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTask.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTask.cs @@ -65,7 +65,6 @@ namespace MonoDevelop.PackageManagement public void CheckForUpdatesCompleted ()
{
- ProgressMonitor.ReportSuccess (projectsWithUpdatedPackages.Any ());
updatedPackagesInSolution.CheckForUpdatesCompleted (this);
}
@@ -73,23 +72,12 @@ namespace MonoDevelop.PackageManagement get { return projectsWithUpdatedPackages; }
}
- public CheckForUpdatesProgressMonitor ProgressMonitor { get; set; }
-
public void Dispose ()
{
if (!disposed) {
disposed = true;
- if (ProgressMonitor != null) {
- ProgressMonitor.Dispose ();
- ProgressMonitor = null;
- }
}
}
-
- public void ReportError (Exception ex)
- {
- ProgressMonitor.ReportError (ex);
- }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTaskRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTaskRunner.cs index 0a01ea6163..192ca4823f 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTaskRunner.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTaskRunner.cs @@ -25,7 +25,6 @@ // THE SOFTWARE.
using System;
-using System.Collections.Generic;
using ICSharpCode.PackageManagement;
using MonoDevelop.Core;
using MonoDevelop.Ide;
@@ -35,26 +34,16 @@ namespace MonoDevelop.PackageManagement public class CheckForUpdatesTaskRunner : IDisposable
{
ITaskFactory taskFactory;
- IPackageManagementProgressMonitorFactory progressMonitorFactory;
- IPackageManagementEvents packageManagementEvents;
CheckForUpdatesTask currentCheckForUpdatesTask;
ITask<CheckForUpdatesTask> task;
- public CheckForUpdatesTaskRunner (
- ITaskFactory taskFactory,
- IPackageManagementProgressMonitorFactory progressMonitorFactory,
- IPackageManagementEvents packageManagementEvents)
+ public CheckForUpdatesTaskRunner (ITaskFactory taskFactory)
{
this.taskFactory = taskFactory;
- this.progressMonitorFactory = progressMonitorFactory;
- this.packageManagementEvents = packageManagementEvents;
}
public CheckForUpdatesTaskRunner ()
- : this (
- new PackageManagementTaskFactory (),
- PackageManagementServices.ProgressMonitorFactory,
- PackageManagementServices.PackageManagementEvents)
+ : this (new PackageManagementTaskFactory ())
{
}
@@ -74,7 +63,6 @@ namespace MonoDevelop.PackageManagement void CreateCheckForUpdatesTask (CheckForUpdatesTask checkForUpdatesTask)
{
currentCheckForUpdatesTask = checkForUpdatesTask;
- checkForUpdatesTask.ProgressMonitor = CreateProgressMonitor ();
task = taskFactory.CreateTask (
() => CheckForUpdates (checkForUpdatesTask),
@@ -108,9 +96,9 @@ namespace MonoDevelop.PackageManagement {
if (task.IsFaulted) {
if (IsCurrentTask (task)) {
- ReportError (task.Exception);
+ LogError ("Current check for updates task error.", task.Exception);
} else {
- LoggingService.LogInternalError ("Check for updates task error.", task.Exception);
+ LogError ("Check for updates task error.", task.Exception);
}
} else if (task.IsCancelled) {
// Ignore.
@@ -134,13 +122,9 @@ namespace MonoDevelop.PackageManagement return currentCheckForUpdatesTask == task;
}
- void ReportError (Exception ex)
+ protected virtual void LogError (string message, Exception ex)
{
- CheckForUpdatesTask task = currentCheckForUpdatesTask;
- task.ReportError (ex);
- GuiBackgroundDispatch (() => {
- task.Dispose ();
- });
+ LoggingService.LogInternalError (message, ex);
}
bool IsCurrentTask (ITask<CheckForUpdatesTask> taskToCompare)
@@ -148,18 +132,6 @@ namespace MonoDevelop.PackageManagement return taskToCompare == task;
}
- CheckForUpdatesProgressMonitor CreateProgressMonitor ()
- {
- return CreateProgressMonitor (progressMonitorFactory, packageManagementEvents);
- }
-
- protected virtual CheckForUpdatesProgressMonitor CreateProgressMonitor (
- IPackageManagementProgressMonitorFactory progressMonitorFactory,
- IPackageManagementEvents packageManagementEvents)
- {
- return new CheckForUpdatesProgressMonitor (progressMonitorFactory, packageManagementEvents);
- }
-
protected virtual void GuiBackgroundDispatch (MessageHandler handler)
{
DispatchService.BackgroundDispatch (handler);
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageUpdatesEventMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageUpdatesEventMonitor.cs deleted file mode 100644 index cfb21f91da..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageUpdatesEventMonitor.cs +++ /dev/null @@ -1,73 +0,0 @@ -//
-// PackageUpdatesEventMonitor.cs
-//
-// Author:
-// Matt Ward <matt.ward@xamarin.com>
-//
-// Copyright (c) 2014 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;
-using ICSharpCode.PackageManagement;
-using MonoDevelop.Core;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- public class PackageUpdatesEventMonitor : IDisposable
- {
- IPackageManagementEvents packageEvents;
- IProgressMonitor progressMonitor;
-
- public PackageUpdatesEventMonitor (IProgressMonitor progressMonitor)
- : this (
- progressMonitor,
- PackageManagementServices.PackageManagementEvents)
- {
- }
-
- public PackageUpdatesEventMonitor (
- IProgressMonitor progressMonitor,
- IPackageManagementEvents packageEvents)
- {
- this.progressMonitor = progressMonitor;
- this.packageEvents = packageEvents;
-
- packageEvents.PackageOperationMessageLogged += PackageOperationMessageLogged;
- }
-
- void PackageOperationMessageLogged (object sender, PackageOperationMessageLoggedEventArgs e)
- {
- progressMonitor.Log.WriteLine (e.Message.ToString ());
-
- if (e.Message.Level == MessageLevel.Warning) {
- WarningReported = true;
- }
- }
-
- public void Dispose ()
- {
- packageEvents.PackageOperationMessageLogged -= PackageOperationMessageLogged;
- }
-
- public bool WarningReported { get; private set; }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorStatusMessageFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorStatusMessageFactory.cs index 6bc99bf3f8..6c42dbef5f 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorStatusMessageFactory.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorStatusMessageFactory.cs @@ -213,15 +213,6 @@ namespace MonoDevelop.PackageManagement );
}
- public static ProgressMonitorStatusMessage CreateCheckingForPackageUpdatesMessage ()
- {
- return new ProgressMonitorStatusMessage (
- GetString ("Checking for package updates..."),
- GetString ("Packages are up to date."),
- GetString ("Could not check for package updates."),
- GetString ("No updates found but warnings were reported."));
- }
-
static string GetString (string phrase)
{
return GettextCatalog.GetString (phrase);
|