Permalink
Browse files

Show NuGet log messages in Output window.

  • Loading branch information...
mrward committed Feb 22, 2011
1 parent cbe272c commit 3d6c88d5cccc14ebc8b195877fe94f10b9703d92
Showing with 528 additions and 39 deletions.
  1. +1 −1 src/AddIns/Misc/PackageManagement/PackageManagement.sln
  2. +9 −0 src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj
  3. +2 −0 src/AddIns/Misc/PackageManagement/Project/Src/AddPackageReferenceViewModel.cs
  4. +2 −9 src/AddIns/Misc/PackageManagement/{Test/Src/Helpers → Project/Src/Design}/FakeFileSystem.cs
  5. +24 −0 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageManagementOutputMessagesView.cs
  6. +6 −0 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageManagementService.cs
  7. +7 −1 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeProjectManager.cs
  8. +1 −1 src/AddIns/Misc/PackageManagement/{Test/Src/Helpers → Project/Src/Design}/FakeProjectSystem.cs
  9. +14 −0 src/AddIns/Misc/PackageManagement/Project/Src/ICompilerMessageView.cs
  10. +13 −0 src/AddIns/Misc/PackageManagement/Project/Src/IMessageViewCategory.cs
  11. +13 −0 src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementOutputMessagesView.cs
  12. +2 −0 src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementService.cs
  13. +27 −0 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementCompilerMessageView.cs
  14. +28 −0 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementMessageViewCategory.cs
  15. +49 −0 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementOutputMessagesView.cs
  16. +27 −5 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementService.cs
  17. +23 −14 src/AddIns/Misc/PackageManagement/Project/Src/PackageViewModel.cs
  18. +3 −2 src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj
  19. +8 −0 src/AddIns/Misc/PackageManagement/Test/Src/AddPackageReferenceViewModelTests.cs
  20. +33 −0 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeCompilerMessageView.cs
  21. +30 −0 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeMessageCategoryView.cs
  22. +14 −1 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageManager.cs
  23. +1 −0 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeProjectSystemFactory.cs
  24. +4 −2 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/TestablePackageViewModel.cs
  25. +1 −0 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/Tests/PackageReferenceRepositoryTests.cs
  26. +104 −0 src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementOutputMessagesViewTests.cs
  27. +72 −1 src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementServiceTests.cs
  28. +10 −0 src/AddIns/Misc/PackageManagement/Test/Src/PackageViewModelTests.cs
  29. +0 −2 src/AddIns/Misc/PackageManagement/Test/Src/SharpDevelopPackageManagerTests.cs
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-# SharpDevelop 4.1.0.7222-alpha
+# SharpDevelop 4.1.0.7289-alpha
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement", "Project\PackageManagement.csproj", "{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement.Tests", "Test\PackageManagement.Tests.csproj", "{56E98A01-8398-4A08-9578-C7337711A52B}"
@@ -75,12 +75,21 @@
<Compile Include="Src\Design\DesignTimePackageManagementOptionsViewModel.cs" />
<Compile Include="Src\Design\DesignTimePackageManagementService.cs" />
<Compile Include="Src\Design\DesignTimePackagesViewModel.cs" />
+ <Compile Include="Src\Design\FakeFileSystem.cs" />
<Compile Include="Src\Design\FakePackage.cs" />
+ <Compile Include="Src\Design\FakePackageManagementOutputMessagesView.cs" />
<Compile Include="Src\Design\FakePackageManagementService.cs" />
<Compile Include="Src\Design\FakePackageRepository.cs" />
<Compile Include="Src\Design\FakeProjectManager.cs" />
+ <Compile Include="Src\Design\FakeProjectSystem.cs" />
<Compile Include="Src\Design\WpfDesigner.cs" />
+ <Compile Include="Src\ICompilerMessageView.cs" />
+ <Compile Include="Src\IMessageViewCategory.cs" />
+ <Compile Include="Src\IPackageManagementOutputMessagesView.cs" />
<Compile Include="Src\IPackageRepositoryCache.cs" />
+ <Compile Include="Src\PackageManagementCompilerMessageView.cs" />
+ <Compile Include="Src\PackageManagementMessageViewCategory.cs" />
+ <Compile Include="Src\PackageManagementOutputMessagesView.cs" />
<Compile Include="Src\PackageRepositoryCache.cs" />
<Compile Include="Src\PackagesForSelectedPageResult.cs" />
<Compile Include="Src\ILicenseAcceptanceService.cs" />
@@ -20,6 +20,8 @@ public class AddPackageReferenceViewModel : ViewModelBase<AddPackageReferenceVie
ITaskFactory taskFactory)
{
this.packageManagementService = packageManagementService;
+ this.packageManagementService.OutputMessagesView.Clear();
+
installedPackagesViewModel = new InstalledPackagesViewModel(packageManagementService, taskFactory);
availablePackagesViewModel = new AvailablePackagesViewModel(packageManagementService, taskFactory);
packageUpdatesViewModel = new PackageUpdatesViewModel(packageManagementService, taskFactory);
@@ -7,22 +7,15 @@
using System.Text;
using NuGet;
-namespace PackageManagement.Tests.Helpers
+namespace ICSharpCode.PackageManagement.Design
{
public class FakeFileSystem : IFileSystem
{
public bool FileExistsReturnValue;
public string FileToReturnFromOpenFile;
public string PathToReturnFromGetFullPath;
- public ILogger Logger {
- get {
- throw new NotImplementedException();
- }
- set {
- throw new NotImplementedException();
- }
- }
+ public ILogger Logger { get; set; }
public string Root {
get {
@@ -0,0 +1,24 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using ICSharpCode.PackageManagement;
+using NuGet;
+
+namespace ICSharpCode.PackageManagement.Design
+{
+ public class FakePackageManagementOutputMessagesView : IPackageManagementOutputMessagesView
+ {
+ public bool IsClearCalled;
+
+ public void Clear()
+ {
+ IsClearCalled = true;
+ }
+
+ public void Log(MessageLevel level, string message, params object[] args)
+ {
+
+ }
+ }
+}
@@ -127,5 +127,11 @@ public IPackageRepository CreateAggregatePackageRepository()
}
public Exception ActiveProjectManagerExeptionToThrow { get; set; }
+
+ public FakePackageManagementOutputMessagesView FakeOutputMessagesView = new FakePackageManagementOutputMessagesView();
+
+ public IPackageManagementOutputMessagesView OutputMessagesView {
+ get { return FakeOutputMessagesView; }
+ }
}
}
@@ -43,9 +43,15 @@ protected virtual void OnPackageReferenceAdded(IPackage package)
public IPackageRepository LocalRepository { get; set; }
public ILogger Logger { get; set; }
- public IProjectSystem Project { get; set; }
public IPackageRepository SourceRepository { get; set; }
public IPackagePathResolver PathResolver { get; set; }
+
+ public IProjectSystem Project {
+ get { return FakeProjectSystem; }
+ set { FakeProjectSystem = value as FakeProjectSystem; }
+ }
+
+ public FakeProjectSystem FakeProjectSystem = new FakeProjectSystem();
public void AddPackageReference(string packageId, Version version, bool ignoreDependencies)
{
@@ -6,7 +6,7 @@
using System.Runtime.Versioning;
using NuGet;
-namespace PackageManagement.Tests.Helpers
+namespace ICSharpCode.PackageManagement.Design
{
public class FakeProjectSystem : FakeFileSystem, IProjectSystem
{
@@ -0,0 +1,14 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace ICSharpCode.PackageManagement
+{
+ public interface ICompilerMessageView
+ {
+ IMessageViewCategory Create(string categoryName, string categoryDisplayName);
+
+ IMessageViewCategory GetExisting(string name);
+ }
+}
@@ -0,0 +1,13 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace ICSharpCode.PackageManagement
+{
+ public interface IMessageViewCategory
+ {
+ void AppendLine(string text);
+ void Clear();
+ }
+}
@@ -0,0 +1,13 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using NuGet;
+
+namespace ICSharpCode.PackageManagement
+{
+ public interface IPackageManagementOutputMessagesView : ILogger
+ {
+ void Clear();
+ }
+}
@@ -23,5 +23,7 @@ public interface IPackageManagementService
bool HasMultiplePackageSources { get; }
PackageSource ActivePackageSource { get; set; }
+
+ IPackageManagementOutputMessagesView OutputMessagesView { get; }
}
}
@@ -0,0 +1,27 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using ICSharpCode.SharpDevelop.Gui;
+
+namespace ICSharpCode.PackageManagement
+{
+ public class PackageManagementCompilerMessageView : ICompilerMessageView
+ {
+ public IMessageViewCategory Create(string categoryName, string categoryDisplayName)
+ {
+ MessageViewCategory view = null;
+ MessageViewCategory.Create(ref view, categoryName, categoryDisplayName);
+ return new PackageManagementMessageViewCategory(view);
+ }
+
+ public IMessageViewCategory GetExisting(string categoryName)
+ {
+ MessageViewCategory view = CompilerMessageView.Instance.GetCategory(categoryName);
+ if (view != null) {
+ return new PackageManagementMessageViewCategory(view);
+ }
+ return null;
+ }
+ }
+}
@@ -0,0 +1,28 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using ICSharpCode.SharpDevelop.Gui;
+
+namespace ICSharpCode.PackageManagement
+{
+ public class PackageManagementMessageViewCategory : IMessageViewCategory
+ {
+ MessageViewCategory messageViewCategory;
+
+ public PackageManagementMessageViewCategory(MessageViewCategory messageViewCategory)
+ {
+ this.messageViewCategory = messageViewCategory;
+ }
+
+ public void AppendLine(string text)
+ {
+ messageViewCategory.AppendLine(text);
+ }
+
+ public void Clear()
+ {
+ messageViewCategory.ClearText();
+ }
+ }
+}
@@ -0,0 +1,49 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using NuGet;
+
+namespace ICSharpCode.PackageManagement
+{
+ public class PackageManagementOutputMessagesView : IPackageManagementOutputMessagesView
+ {
+ public static readonly string CategoryName = "PackageManagement";
+
+ IMessageViewCategory messageViewCategory;
+
+ public PackageManagementOutputMessagesView()
+ : this(new PackageManagementCompilerMessageView())
+ {
+ }
+
+ public PackageManagementOutputMessagesView(ICompilerMessageView compilerMessageView)
+ {
+ CreatePackageManagementMessageCategoryIfNoneExists(compilerMessageView);
+ }
+
+ void CreatePackageManagementMessageCategoryIfNoneExists(ICompilerMessageView compilerMessageView)
+ {
+ messageViewCategory = compilerMessageView.GetExisting(CategoryName);
+ if (messageViewCategory == null) {
+ CreatePackageManagementMessageCategory(compilerMessageView);
+ }
+ }
+
+ void CreatePackageManagementMessageCategory(ICompilerMessageView compilerMessageView)
+ {
+ messageViewCategory = compilerMessageView.Create(CategoryName, "Package Management");
+ }
+
+ public void Clear()
+ {
+ messageViewCategory.Clear();
+ }
+
+ public void Log(MessageLevel level, string message, params object[] args)
+ {
+ string formattedMessage = String.Format(message, args);
+ messageViewCategory.AppendLine(formattedMessage);
+ }
+ }
+}
@@ -12,32 +12,42 @@ namespace ICSharpCode.PackageManagement
{
public class PackageManagementService : IPackageManagementService
{
+ IPackageManagementOutputMessagesView outputMessagesView;
PackageManagementOptions options;
IPackageRepositoryCache packageRepositoryCache;
IPackageManagerFactory packageManagerFactory;
IPackageManagementProjectService projectService;
IPackageRepository activePackageRepository;
PackageSource activePackageSource;
- public PackageManagementService(PackageManagementOptions options,
+ public PackageManagementService(
+ PackageManagementOptions options,
IPackageRepositoryCache packageRepositoryCache,
IPackageManagerFactory packageManagerFactory,
- IPackageManagementProjectService projectService)
+ IPackageManagementProjectService projectService,
+ IPackageManagementOutputMessagesView outputMessagesView)
{
this.options = options;
this.packageRepositoryCache = packageRepositoryCache;
this.packageManagerFactory = packageManagerFactory;
this.projectService = projectService;
+ this.outputMessagesView = outputMessagesView;
}
public PackageManagementService()
- : this(new PackageManagementOptions(),
+ : this(
+ new PackageManagementOptions(),
new PackageRepositoryCache(),
new SharpDevelopPackageManagerFactory(),
- new PackageManagementProjectService())
+ new PackageManagementProjectService(),
+ new PackageManagementOutputMessagesView())
{
}
+ public IPackageManagementOutputMessagesView OutputMessagesView {
+ get { return outputMessagesView; }
+ }
+
public PackageManagementOptions Options {
get { return options; }
}
@@ -97,7 +107,19 @@ IProjectManager GetActiveProjectManager()
ISharpDevelopPackageManager CreatePackageManager(IPackageRepository packageRepository)
{
MSBuildBasedProject project = projectService.CurrentProject as MSBuildBasedProject;
- return packageManagerFactory.CreatePackageManager(packageRepository, project);
+ ISharpDevelopPackageManager packageManager = packageManagerFactory.CreatePackageManager(packageRepository, project);
+ ConfigureLogger(packageManager);
+ return packageManager;
+ }
+
+ void ConfigureLogger(ISharpDevelopPackageManager packageManager)
+ {
+ packageManager.Logger = outputMessagesView;
+ packageManager.FileSystem.Logger = outputMessagesView;
+
+ IProjectManager projectManager = packageManager.ProjectManager;
+ projectManager.Logger = outputMessagesView;
+ projectManager.Project.Logger = outputMessagesView;
}
public void UninstallPackage(IPackageRepository repository, IPackage package)
Oops, something went wrong.

0 comments on commit 3d6c88d

Please sign in to comment.